You may infer this but Doniphon never expresses any “personal code”, and in fact he has no problem with Pompey taking aim on Valance and his crew in the steakhouse from concealment. In fact, Doniphon seems to be highly pragmatic in his affairs up until the point that he makes the decision to tacitly grant Ranse the credit for killing Liberty Valance, which gives the latter the celebrity to run for office (which Doniphon later spurs him onto when admitting that he, and not Ranse, bears responsibility for the death) and campaign for statehood.
In fact, there is a dual paradox here: Doniphon, who likes the way things are and has no problem with the lawlessness of the ‘Old West’ where his strength and cunning give him advantage, recognizes that the inevitable future of statehood that Ranse is bringing: law and order, education and literacy, and ultimately ‘giving’ Hallie over to Ranse; while Ranse forgoes his strongly stated beliefs that the law must prevail, provoking and then (in his mistaken belief) killing Valance in a street duel. Even when he learns the truth, he is cajoled into accepting the credit so that he may be “the legend” and carries with him the guilt of taking from Doniphon everything he values. He bears the ‘lie’ that he is the man who shot Liberty Valance, an act that ironically gives him credence for bringing law and order to Shinbone.
As for the legality of the shooting, Valance is clearly a public menace who not only brutally beats an unarmed and unresisting Ranse but routinely robs stagecoaches, attacks smallholders at the behest of free range cattle barons, and nearly kills the newspaper owner and destroys his press. Dueling, while not uncommon in the West (although not to the extent that movies would have you believe), was at best extra-legal and often explicitly illegal inside of municipalities, and so both participants would be in the wrong. However, Valance had already disarmed Ranse who ineffectually provoked him (as Valance could have ignored the taunts and just walked out the back), and compelled Ranse to pick up the pistol he had already shot out of his hand, so he could scarcely claim to be acting in self-defense.
On the other hand, Doniphon would have a strong case (especially under ‘Western’ defense law) that he was acting in exigent circumstances and in absence of the presence of law enforcement to prevent homicide and further violence and bloodshed, and that he had no other effective recourse as Valance had a pistol in hand and was out of grappling range. A intercessor in such circumstances has no duty to announce or expose themselves in a ‘fair’ fight.
The film is steeped in the false mythologizing of the “Old West” which director John Ford was substantially responsible for creating, and is an essential precursor to films like The Wild Bunch and Unforgiven. That he got John Wayne—one of the most arrogant, self-absorbed actors of that generation—to appear in it as a supporting player to Jimmy Stewart adds yet another layer of metatextural commentary.
Stranger