I don't think the dress code should be imposed because "it's distracting to the boys." I think there are better reasons that should be the ones driving policy. But I do think the policy of dress codes is correct.
First, I have worked in inner city middle schools since before dress codes and uniforms became commonplace. The girls would need to take public transportation to and from school, and often in middle school they are 12, but they look like they are 25, so they attract adult attention that they are not yet equipped to deal with. We DO have a rape culture. At 12 years old, a girl still needs to be protected from it.
Second, There is a look that in my youth was described as "the girl at her first disco." (That's how old I am!) It is an over the top, very flashy look, complete with bad experimental makeup and clothing that shows off all those new body parts that just appeared. Today it's got nothing to do with disco, but it is still the look that some 12 year olds will adopt if they have no one at home guiding the way they dress. That look really IS distracting, and not just to the boys, and not really for sexual reasons. Imagine if Dame Edna walked into your 9th grade Algebra class. It's like that.
And last, in middle schools, there is a lot more sex going on than I think most adults know. And it just isn't appropriate among 11 and 12 year olds. They are too young. I have worked with the babies of pre-teen mothers, and it's a bad situation. I think it is appropriate to discourage any sexual activities and behaviors among both sexes at that age in school. The imposition of uniforms and dress codes has helped with this. I have noted fewer pre-teen and early teen pregnancies since the uniforms came in. Just anecdotal, but it is my experience.