Maven configuration pom file add PMD check, add checkstyle check, Jdepend etc check function

Source: Internet
Author: User
Tags checkstyle

One, PMD is scanning Java source code and find the following potential problems:
local variables that have never been used
empty snap block (catch block)
parameters that have never been used
empty if Declaration
Duplicate Import Declarations
private methods that have never been used
Orphaned classes
short or Long variable and method name

To join the PMD check, the following code if joined in the reporting node is executed in the MVN site, and if added in the Build node, the check is run automatically at build. Detailed configuration of reference PMD plug-in usage instructions

<plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId> Maven-pmd-plugin</artifactid><version>2.5</version></plugin></plugins>

Add Checkstyle Check, detailed configuration reference Checkstyle plug-in instructions, also note the differences placed in the reporting and build nodes (all report class plug-ins should be the same note):

<plugin><groupid>org.apache.maven.plugins</groupid><artifactid>maven-checkstyle-plugin </artifactId><version>2.5</version></plugin>

With support for simian, Simian is a tool that supports code similarity checking, and currently has maven plugins and Checkstyle plugins. Not only can it check Java, it can even support checking of text files. For more help information refer here. Simian's maven plugin is here

<plugins> <plugin> <groupId>org.codehaus.mojo</groupId>               <artifactId>simian-maven-plugin</artifactId> <version>1.6.1</version> </plugin> </plugins>

Add Jdepend Check, detailed configuration reference jdepend usage instructions

<plugin><groupid>org.codehaus.mojo</groupid><artifactid>jdepend-maven-plugin</ Artifactid><version>2.0-beta-2</version></plugin>

Add Findbugz Check, detailed configuration reference Findbugz usage instructions,

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactid>findbugs-maven-plugin< ;/artifactid> <version>2.0.1</version> </plugin>

Add Javadoc generation, detailed configuration reference Javadoc usage

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactid>maven-javadoc-plu Gin</artifactid> <version>2.7</version> <configuration> ... < /configuration> </plugin>

With JXR support, JXR is an HTML-formatted tool that generates Java code cross-references and source code, with detailed configuration information referenced JXR usage. Note that JXR is not necessary to run in the build phase.

<reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jxr-plugin</artifactId> <version>2.1</version> </plugi N> </plugins> </reporting>

join Cobertura support, which is a code coverage tool that can be used to evaluate the ratio of source code with corresponding tests. Detailed help is here. Another feature similar to the software is Emma, with detailed help here. Two product comparison articles here, personal inclination to use, because the indicators given are different, all have a reference role.

      <plugin>         < groupid>org.codehaus.mojo</groupid>         < artifactid>cobertura-maven-plugin</artifactid>          <version>2.4</version>         <configuration>            <check>              <branchRate>85</branchRate>              <lineRate>85</lineRate>              

<reporting> ... <plugin> <groupid>org.codehaus.mojo</<plugins> ... Groupid> <artifactId>emma-maven-plugin</artifactId> <version>1.0-alpha-3-SNAPSHOT< /version> </plugin> </plugins> ... </reporting>

Add the JavaNCSS plugin, which is a metric tool for Java code, detailed reference here.

<reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>javancss-maven-plugin</artifactId> <version>2.0-beta-2</version> </ Plugin> </plugins> </reporting>


Maven configuration pom file add PMD check, add checkstyle check, Jdepend etc check function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.