CheckStyle verification is not ignored

I set my checkstyle checks in my pom.xml as follows

<reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.10</version> <configuration> <suppressionsLocation> checkstyle-suppressions.xml </suppressionsLocation> <suppressionsFileExpression> checkstyle-suppressions.xml </suppressionsFileExpression> </configuration> </plugin> </plugins> </reporting> 

my checkstyle-supressions.xml file contains the following

 <?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="JavadocStyleCheck" files="**/*.java" /> <suppress checks="JavadocTypeCheck" files="**/*.java" /> <suppress checks="JavadocVariableCheck" files="**/*.java" /> <suppress checks="FileTabCharacterCheck" files="**/*.java" /> </suppressions> 

I want the style check plugin not to report any JavaDoc comments or tab-related errors when starting the mvn site. But that does not work. How can I achieve this?

respectfully

+6
source share
1 answer

CheckStyle: SuppressionFilter told us how

An XML suppression XML document contains a set of suppress elements, where each suppress element can have the following attributes:

  • files - a regular expression that matches the file name associated with the audit event. It is necessary.
  • Validates — The regular expression matched against the validation name associated with the audit event. Optional if an identifier is specified.
  • id is a string associated with the verification identifier associated with the audit event. Optional if validations are specified.
  • strings - a list of values ​​separated by commas, where each value is an integer or a range of integers denoted by integer-integer. It's not obligatory.
  • columns - a list of values ​​separated by commas, where each value is an integer or a range of integers denoted by integer-integer. It's not obligatory.

Since files is regular expression , you can check the network configuration on the regular expression page for Java .

If files is **/*.java when regular expression is applied with com.test.My.java , the result is a crash like Dangling meta character '*' near index 0 **/*.java ^

The solution then sets the files as .*\.java , when regular expression with com.test.My.java , the result is matches (): yes , lookAt (): yes , find (): yes and group (0): com. test.My.java .

The plugin configuration should be as follows: -

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.10</version> <configuration> <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation> <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression> </configuration> </plugin> 

checkstyle: checkstyle told us how

  • suppressionsLocation . Specifies the location of the suppression XML file. This parameter is resolved as a resource, URL, and then a file . If successfully resolved, the contents of the XML suppression files will be copied to the ${project.build.directory}/checkstyle-supressions.xml before ${project.build.directory}/checkstyle-supressions.xml it to Checkstyle for download.

  • suppressionionsFileExpression The key to be used in the suppression file properties. The default value is checkstyle.suppressions.file .

For more information, see Maven Checkstyle Plugin: Using the Prohibition Filter .

Hope this helps.

+3
source

All Articles