The only difference is on line 584/611. One neeeds if and the other one
576/603 are different as well.
Isn't this a massive injure of the DRY principle?
DRY is a great principle. We should all follow it. However it is a principle, not a law. As a principle it exists so as to reduce the complexity of the application with particular regard to maintenance.
However, sometimes you can push it to the point where maintaining the code would be far more complicated than if you just did a cut and paste. Sometimes it's just easier for all concerned.
Let me give you an analogy to explain the principle better. Think about the principles of normalisation within data modelling. In theory, you should normalise all data to the maximum extent. That would mean instead of having this schema:
I should, according to the theorists who see normalisation as a law to eliminate ALL duplication of data in the database, and not a principle to help simplify the model, re-structure it as follows:
Names: # Two people might have the same name! Can't duplicate data!
Notes: # What if two people have the same notes?! That would be duplication!
Line1_id: # Two people might have the same first line!
Line2_id # and second line! CAN'T DUPLICATE!
City_id: # Surely, more than one person lives in a city?!
Postcode_id: # Two people in the same area! Agghh! Duplication!
Country_id: # and the same country!
You get the idea. If you take normalisation to its maximum point to completely and totally eliminate duplication, the result is a model that is harder to code against, harder to maintain, a right PITA. The simple truth is, DRY has to be sometimes seen in the same light. At what point are you just normalising to the point of silliness?
In this particular example, we're not talking about the same method doing roughly the same thing - we're actually talking about two different methods, each just 10 lines long, with currently similar internal behaviour but that may need to be extended in the future to do rather different things regarding their behaviour.
Couldn't this have been coded much cleaner by using the same method for both and only switch if to unless when using the one or the other validation?
I'm sure they'd be happy to consider a patch if you think it worthwhile, but to say because of this one overlap that 'Rails isn't DRY' is a bit extreme in my opinion.
DRY is a principle. It is not a God to be worshipped, a law to be observed on pain of ridicule, a boss to which you are a condemned slave. It's just a good idea, that's all.