Automatically check Java files for standard coding compliance

I am working on Java development. Recently, I came to a situation where I had to adhere to coding standards: the order of members and methods, naming conventions, a sequence of modifiers. I am thinking of methods to either automate compliance checking or create some kind of mechanism that performs reordering.

We are developing with Eclipse, but the technology will be open. One way this might work is to create an external builder tool and add it to projects. The downside would be that it automatically applies to all files that might run into problems with legacy code, blowing up the number of errors to the point where it is no longer a reasonable metric of compliance. In addition, it greatly facilitates code verification, which is not required.

Another way could be some kind of parser with only informative capabilities. We could have started the process inside Jenkins, and that would certainly work, but it would also mean that the code had already gone through the review, which, as a rule, was a bit late for checking the code correspondence.

Are there any suggested or even simple methods for integrating such functions into an IDE, version control system (Mercurial), or even Jenkins? How is this applied elsewhere?

+5
source share
5 answers

I would not recommend making such changes automatically. Although most of the / pmd checks are true, it seems to me that I need to ignore some warnings / errors. Moreover - there is a very small pool of such easy questions. Most notifications require more complex operations and probably cannot be completed without human interaction.

Sonar . , PMD, CPD, Checkstyle, Findbugs , Cobertura ( ). , Sonar / , .

Eclipse findbugs. , , , . Sonar , ( ) , .

+3

JCSC/checkstyle , . . .

Jenkins ( ),

+1

@Jayan Jenkins CheckStyle plugin, CheckStyle , . , :

+1

Jayan , .

, Jalopy .

, , . , checkstyle , - . - , . , . .
0

All Articles