Accepted answer

yeah, i ran into this issue when started using sonarqube

there are two xml rules, one for formatter and one for source clean-up. you can import at eclipse and intellij idea (using a plugin)

it worked for me, as it reduced my issues at this 70k loc project :

|                 | before | after |
| issues          | 4.306  | 2.977 |
| blocker issues  | 0      | 0     |
| critical issues | 257    | 257   |
| major issues    | 2.402  | 1.994 |
| minor issues    | 1.642  | 721   |
| info issues     | 5      | 5     |

here are the formatter.xml and cleanup.xml rules. credit goes to this github repo and it's authors.

blog post automating such task on eclipse here. it states a important caveat

not everything can be automated

please note that although a lot of coding standards can be applied retroactively and automatically, some violations cannot be automatically eradicated. nonetheless, checkstyle, eclipse and sonar can identify the problematic code and guide developers towards coding standard compliance.

yes, i'm aware you're using only checkstyle, but i'm sure it applies, since sonarqube uses checkstyle to raise it's issues.


i do not know of a way to do that using the cleanup feature, but eclipse-cs (the eclipse checkstyle plugin) offers eclipse quick fixes for many checkstyle findings. you can have it run all applicable by selecting apply checkstyle fixes from the right-click context menu.

screenshots here. hope this helps!

Related Query

More Query from same tag