Of unknown origin, the British-English informal noun codswallop means nonsense.
Much having already been written on the subject, I will only mention facts that don’t seem to have been noted yet.
The earliest instance of codswallop in the Oxford English Dictionary (2nd edition, 1989) dates from 1959; I have found an earlier one in the Alton Evening Telegraph (Alton, Illinois) of Monday 7th July 1958, with a pun on cod in the sense of a fish:
IT’S KIPPER NO MORE
Maurice Arthur Fish, a Bournemouth, England, butcher, has changed his name to Carrington-Fisher. Said his wife: “We’ve been called Fishy, Kipper, and Codswallop. For our daughter Sandra’s sake we hoped to put a stop to it.” Sandra already is being called “Little Sprat.”
Perhaps codswallop is a development on the earlier noun cod in the sense of a joke, a hoax; in his column Motley Notes, published in The Sketch (London) of 11th October 1905, Keble Howard mentioned a
really shocking advertisement that appeared in a recent issue of the Times—
A HOPELESSLY INCOMPETENT FOOL, with no qualifications, social or intellectual, totally devoid of knowledge on any conceivable subject, thoroughly indolent and untrustworthy, is desirous of obtaining a remunerative post in any capacity.
Incomprehensible, you say, but why shocking? Shocking, I reply, but by no means incomprehensible. Cannot you conceive any set of circumstances under which such an advertisement as that might wickedly be penned? I can, then. I can imagine a ne’er-do-well nephew being severely lectured by a rich maiden aunt. I can hear her saying: “But other young men get useful employment, and so could you.” And I can hear the rascal replying: “I can’t. I’ve tried, and I can’t.” Says she: “Are you willing to work?” Says he: “Quite willing. I’d do any mortal thing.” “Done!” she cries. “Put an advertisement in the Times offering to do any kind of work so long as you get paid for it.” Says the cunning one: “Suppose I still fail? Will you persist in cutting off supplies?” “No,” says the simple Auntie. “If you insert an advertisement such as I have suggested, and nobody answers it, I shall consider that you are cursed of Fate, and shall be willing to help you, as heretofore, so far as my means allow.” Says he: “Is that an absolute bargain—no cod?” Says she: “I don’t know what the fish has to do with it, but I am perfectly sincere.” Then the wretch goes away and draws up that advertisement. Tell me, is this a reasonable explanation or is it not?
This noun, which originally meant a fool, is perhaps an abbreviation of cod’s head, literally the head of a cod-fish and figuratively a fool. Also used as a verb, cod was thus defined in The Slang Dictionary Etymological, Historical and Anecdotal (London, 1873 edition):
Cod, to hoax, to take a “rise” out of one. Used as a noun, a fool.
The second element of codswallop represents perhaps wallop, which, as a verb, means to move clumsily or convulsively, and, as a noun, means a heavy, clumsy, noisy movement of the body (the primary meaning of the noun wallop is a horse’s gallop, from which arose the senses bubbling noise of a bubbling liquid and then sound of a clumsy movement, leading to the current sense hard blow).
Perhaps therefore, the images underlying the word codswallop are foolery and bumbling clumsiness.