Generating code quality reports for a site

We have seen how to use various code quality tools to perform static code analysis. Let us now see how we can update our site documentation with reports from these tools.

How to do it...

Use the following steps to generate code quality reports for a site:

  1. Open the project for which we want to generate the site report.
  2. Add the following code to the reporting section of the pom.xml file:
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-pmd-plugin</artifactId>
            <version>3.3</version>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.13</version>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>3.0.0</version>
          </plugin>>
  3. Run the following Maven command:
    mvn test site
    
  4. Open the generated site report:
    How to do it...

How it works...

For each of the code quality tools specified in the reporting section of the pom.xml file, the site goal runs the specified tool, generates the report, and links to the site documentation.

Clicking on each of the links takes the user to the specific report.

There's more...

If you have chosen to use SonarQube for analysis and want to link the Sonar report to the site documentation, then you can do the following:

  1. Add the following code in the reporting section of the pom.xml file:
    <plugin>
      <groupId>org.codehaus.sonar-plugins</groupId>
      <artifactId>maven-report</artifactId>
      <version>0.1</version>
    </plugin>
  2. Generate the site by running the following Maven command:
    mvn test site
    
  3. Open the site report:
    There's more...

A new Sonar link is present in Project Reports, which automatically redirects to the default Sonar installation. The link can be customized to the appropriate URL, if it is different.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.198.94