I want to reduce the number of sonar violations in a large legacy java code-base, and it seems a "quick win" would be to update all these conditional statements to have curly brackets. This seems like an easy thing to do and I can't see why it wouldn't be readily automatable.
Does anybody know of a tool that could perform a bulk operation like this? Or why to do such a thing might be a bad idea before I go and spend the time writing something myself? If I were to write one myself what would be the best tools to use? Ideally something that is java language aware, so that I don't have to deal with formatting corner-cases and the like.
The rule is non-negotiable by the way, so this really is the best approach.
解决方案
The easiest thing would be to use Eclipse and click Clean-up on the whole project. In Clean-up profile configuration select Code style tab. There you can select Use blocks in if/while/for/do statements as Always.