I am working on fixing issues caught by sonar on a very old Java project(8 years old approximately ). It is a huge project with a lot of faulty code that is caught by sonar. Although they are very trivial fixes but there are a number of them. Is there a way to automatically fix a series of similar issues ? Like i have around 1200 cases of "statements should be on separate lines" , to do it manually would take ages. Can i automate these fixes somehow ?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Currently there are no tools available for automatic fixing of sonarube bugs. There is walkmod, but it is only for trivial code-smells.
I am currently writing an automatic repair tool for sonarube bugs in java. It uses INRIA's spoon to fix the bugs. The github repo is sonarqube-repair. It has fixes for five bugs: rule numbers 1854, 1948, 2055, 2259 and 2095. I will update this answer once there is some significant progress.
I don't think I would want Sonar to change source. It's a code analyzer.
You could configure your IDE to format on save and do an initial format of all afflicted source files, so that it puts the satements on separate lines.
Also, you might want to review the importance of the problem and change/edit the Quality Profile.
Do it step by step (for Eclipse IDE):
If you want to apply the same resolution to a big number of issues, you can use the Bulk Change feature (introduced in SonarQube 3.7 LTS).
In your particular case, you could also define issue exclusion rules to prevent these issues from being raised on selected parts of the code (introduced in SonarQube 4.0).
Finally, if a particular rule annoys you to the point that it prevents you from working on real issues, you can disable this rule altogether in your quality profile.