Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fully disable javadoc checking with checkstyle maven plugin

i want to use the Maven Checkstyle plugin with a custom configuration that tells Checkstyle to not warn or error on missing Javadoc. Is there a way to do this?

like image 902
Wim Deblauwe Avatar asked May 26 '14 10:05

Wim Deblauwe


People also ask

How do I skip a Checkstyle error?

If you want to disable checkstyle from your pom, you can add the checkstyle plugin to the pom and set the skip flag to prevent the check.

How do I fix Checkstyle violation in IntelliJ?

Go to Settings|Editor|Code Style, choose a code style you want to import CheckStyle configuration to. Click on the gear, then 'import scheme', choose "CheckStyle Configuration" and select a corresponding CheckStyle configuration file. Click OK.

Is a goal that performs Checkstyle analysis during compilation to be configured with Checkstyle plugin with Maven?

Goals Overviewcheckstyle:check is a goal that performs Checkstyle analysis and outputs violations or a count of violations to the console, potentially failing the build. It can also be configured to re-use an earlier analysis.


2 Answers

Just found it myself. To fully ignore all javadoc checking for everthing, add this to your checkstyle configuration:

    <!-- No need for Javadoc -->
    <module name="JavadocType">
        <property name="severity" value="ignore"/>
    </module>
    <module name="JavadocMethod">
        <property name="severity" value="ignore"/>
    </module>
    <module name="JavadocVariable">
        <property name="severity" value="ignore"/>
    </module>
like image 62
Wim Deblauwe Avatar answered Oct 11 '22 13:10

Wim Deblauwe


One good option would be configuring a suppressions filter.

Plugin configuration:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <!-- ... -->
  <build>
    <plugins>
      <!-- ... -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.17</version>
        <executions>
          <execution>
            <id>verify</id>
            <phase>verify</phase>
            <configuration>
              <encoding>UTF-8</encoding>
              <consoleOutput>true</consoleOutput>
              <failsOnError>true</failsOnError>
              <linkXRef>false</linkXRef>
              <suppressionsLocation>
                checkstyle-suppressions.xml
              </suppressionsLocation>
              <suppressionsFileExpression>
                checkstyle.suppressions.file
              </suppressionsFileExpression>
            </configuration>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <!-- ... -->
</project>

checkstyle-suppressions.xml file:

<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
     "-//Puppy Crawl//DTD Suppressions 1.0//EN"
     "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">

<suppressions>
  <suppress checks="Javadoc" files="."/>
</suppressions>

Then running

$ mvn verify

Does not output any Javadoc-related Checkstyle errors.

Many other examples on suppressions filters may be found in checkstyle repository.

like image 33
Matheus Santana Avatar answered Oct 11 '22 14:10

Matheus Santana