maven-definitive-guideBetterBuildsWithMavenAn important aspect of any project is the quality of the code written by developers.Usually the quality of code is reviewed manually but nevertheless it’s time consuming and sometimes the review process becomes stressfull due to tight schedule of the projects.
To address this issue a good number of automated code review & analysis tools are available in the market.
We explored some of the popular open source tools being used by large community of devlelopers.And found out below listed tools to measure – 1.Code Review 2.Static Code Analysis 3.Code Coverage
1.Code Review Tool:
Checkstyle
Checkstyle looks for these things:
Javadoc comments
Naming conventions
Headers
Imports
Size violations
White space
Modifiers
Blocks
Miscellaneous checks (including some useful checks like unnecessary System.out and printstackTrace)
2.Static Code Analysis Tools:
PMD
CPD
FindBugs
The tool checks for the following things in code:
Unused local variables
Empty catch blocks
Unused parameters
Empty if statements
Duplicate import statements
Unused private methods
Classes that could be Singletons
Short/long variable and method names
Cyclometic complexity
3.Code Coverage Tool
Clover
Cobertura
These tools checks for the following issues-
calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage.
Poorly tested, highly complex code
Coverage lost due to recent changes
Precise per test coverage to ensure relevance of your tests
Most of these code review and analysis tools are integrated with the popular IDEs e.g. Eclipse,NetBeans etc and thus it simplies the process for checking the quality of self written code by a developer.
But we were looking for a platform where we can consolidate all the reports generated by these tools and display in a graphical interface.We found out a nice tool called Sonar.
Sonar is a continuous quality control tool for Java applications. Its basic purpose is to enhance the existing continuous integration tools to place all the development projects under quality control.
Some of the important features of these platform are-
1.We can review the reports(generated by PMD,FindBugs,CheckStyle,Clover etc ) of all projects at a glance
2.We can drill down to source code step by step from module->package->class->lines to find why a project has for instance so many coding rules violations?
3.There are 600 coding rules offered inside the platform.
4.Measuring all classical metrics related to Lines of Code, Cyclomatic Complexity, Duplicated code, Comments etc
5.Display unit tests result and associated metrics like code coverage
An important point is Sonar uses Maven as internal build tool.So projects needs to be build using Maven.Maven is a new & advanced open source build tool available in market and it is available as a pug in for the IDEs(Eclipse,Netbeans etc).But there is a option for non Maven projects also in Sonar and it is available in Sonar Light version.Sonar can be integrated with a continous integration build server like Cruise Control,Hudson(available as plugin).
To sum up thsese tools/platform are leveraging a great utility in the entire developement & release phase of a project, starting from coding to release the build of a project and thus can be used to enhance the existing
development process.
Useful link-
http://sonar.codehaus.org/features/
http://docs.codehaus.org/display/SONAR/Sonar+in+a+nutshell#Sonarinanutshell-TheDashboard
http://docs.codehaus.org/display/SONAR/Collect+data
http://maven.apache.org/index.html
An important aspect of any project is the quality of the code written by developers.Usually the quality of code is reviewed manually but nevertheless it’s time consuming and sometimes the review process becomes stressfull due to tight schedule of the projects.
To address this issue a good number of automated code review & analysis tools are available in the market.
We explored some of the popular open source tools being used by large community of devlelopers.And found out below listed tools to measure – 1.Code Review 2.Static Code Analysis 3.Code Coverage
1.Code Review Tool:
Checkstyle
Checkstyle looks for these things:
- Javadoc comments
- Naming conventions
- Headers
- Imports
- Size violations
- White space
- Modifiers
- Blocks
- Miscellaneous checks (including some useful checks like unnecessary System.out and printstackTrace)
2.Static Code Analysis Tools:
PMD
CPD
FindBugs
The tool checks for the following things in code:
- Unused local variables
- Empty catch blocks
- Unused parameters
- Empty if statements
- Duplicate import statements
- Unused private methods
- Classes that could be Singletons
- Short/long variable and method names
- Cyclometic complexity
3.Code Coverage Tool
Clover
Cobertura
These tools checks for the following issues-
- calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage.
- Poorly tested, highly complex code
- Coverage lost due to recent changes
- Precise per test coverage to ensure relevance of your tests
Most of these code review and analysis tools are integrated with the popular IDEs e.g. Eclipse,NetBeans etc and thus it simplies the process for checking the quality of self written code by a developer.
But we were looking for a platform where we can consolidate all the reports generated by these tools and display in a graphical interface.We found out a nice tool called Sonar.
Sonar is a continuous quality control tool for Java applications. Its basic purpose is to enhance the existing continuous integration tools to place all the development projects under quality control.
Some of the important features of this platform are-
1.We can review the reports(generated by PMD,FindBugs,CheckStyle,Clover etc ) of all projects at a glance
2.We can drill down to source code step by step from module->package->class->lines to find why a project has for instance so many coding rules violations?
3.There are 600 coding rules offered inside the platform.
4.Measuring all classical metrics related to Lines of Code, Cyclomatic Complexity, Duplicated code, Comments etc
5.Display unit tests result and associated metrics like code coverage
An important point is it uses Maven as internal build tool.So projects needs to be build using Maven.Maven is a new & advanced open source build tool available in market and it is available as a plug in for the IDEs(Eclipse,Netbeans etc).But there is a option for non Maven projects also in Sonar and it is available in Sonar Light version.Sonar can be integrated with a continous integration build server like Cruise Control,Hudson(available as plugin).
To sum up these tools/platform are leveraging a great utility in the entire development & release phase of a project, starting from coding to release the build of a project and thus can be used to enhance the existing development process.
Useful link-
http://sonar.codehaus.org/features/
http://docs.codehaus.org/display/SONAR/Sonar+in+a+nutshell#Sonarinanutshell-TheDashboard
http://docs.codehaus.org/display/SONAR/Collect+data
http://maven.apache.org/index.html
Maven Help Guide: