Maven Checkstyle Plugin: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==References== {| | valign="top" | * [https://stackoverflow.com/questions/27688426/ Ignoring of Checkstyle warnings with <code>@SuppressWarnings</code>] * [https://maven.apach...") |
No edit summary |
||
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<syntaxhighlight lang="xml"> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-checkstyle-plugin</artifactId> | |||
<version>3.1.2</version> | |||
<dependencies> | |||
<dependency> | |||
<groupId>com.puppycrawl.tools</groupId> | |||
<artifactId>checkstyle</artifactId> | |||
<version>10.0</version> | |||
</dependency> | |||
</dependencies> | |||
<configuration> | |||
<suppressionsLocation>configs/checkstyle/suppressions.xml</suppressionsLocation> | |||
<configLocation>configs/checkstyle/checkstyle.xml</configLocation> | |||
<consoleOutput>true</consoleOutput> | |||
<failsOnError>true</failsOnError> | |||
<encoding>UTF-8</encoding> | |||
<linkXRef>false</linkXRef> | |||
</configuration> | |||
<executions> | |||
<execution> | |||
<id>validate</id> | |||
<phase>validate</phase> | |||
<goals> | |||
<goal>check</goal> | |||
</goals> | |||
</execution> | |||
</executions> | |||
</plugin> | |||
</syntaxhighlight> | |||
==Suppressions== | |||
<syntaxhighlight lang="xml"> | |||
<?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 files="Service.java" checks="HideUtilityClassConstructor"/> | |||
<suppress files="DataService.java" checks="HideUtilityClassConstructor"/> | |||
<suppress files="UserService.java" checks="HideUtilityClassConstructor"/> | |||
<suppress files="PolicyService.java" checks="HideUtilityClassConstructor"/> | |||
</suppressions> | |||
</syntaxhighlight> | |||
==Checkstyle== | |||
<syntaxhighlight lang="xml"> | |||
<!DOCTYPE module PUBLIC | |||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN" | |||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> | |||
<module name="Checker"> | |||
<property name="severity" value="warning"/> | |||
<module name="SuppressWarningsFilter"/> | |||
<module name="TreeWalker"> | |||
<module name="HiddenField"> | |||
<property name="ignoreSetter" value="true"/> | |||
<property name="ignoreConstructorParameter" value="true"/> | |||
</module> | |||
<module name="SuppressWarnings"> | |||
<property name="id" value="checkstyle:suppresswarnings"/> | |||
</module> | |||
</module> | |||
</module> | |||
</syntaxhighlight> | |||
==Knowledge== | |||
{| | |||
|valign='top' colspan='2'| | |||
mvn -Dcheckstyle.skip=true -Dmaven.test.skip=true clean install | |||
mvn -Dcheckstyle.skip=true verify | |||
|valign='top'| | |||
mvn checkstyle:check -rf :<module_name> | |||
mvn checkstyle:check | |||
|- | |||
|colspan='3'| | |||
---- | |||
|- | |||
|valign='top'| | |||
|valign='top'| | |||
|valign='top'| | |||
|} | |||
==References== | ==References== | ||
{| | {| | ||
| valign="top" | | | valign="top" | | ||
* [https://stackoverflow.com/questions/27688426/ Ignoring of Checkstyle warnings with <code>@SuppressWarnings</code>] | * [https://stackoverflow.com/questions/27688426/ Ignoring of Checkstyle warnings with <code>@SuppressWarnings</code>] | ||
* [https://www.multidots.com/importance-of-code-quality-and-coding-standard-in-software-development/ Importance of Coding Standard and Code Quality] | |||
* [https://maven.apache.org/plugins/maven-checkstyle-plugin/ Apache Maven Checkstyle Plugin] | * [https://maven.apache.org/plugins/maven-checkstyle-plugin/ Apache Maven Checkstyle Plugin] | ||
* [https://www.developer.com/design/top-10-java-coding-guidelines/ Top 10 Java Coding Standards] | |||
* [https://www.oracle.com/technetwork/java/codeconventions-150003.pdf Java Code Conventions 1997] | |||
* [https://google.github.io/styleguide/javaguide.html Google Java Style Guide] | |||
* [https://en.wikipedia.org/wiki/SonarQube SonarQube » Wiki] | |||
* [https://www.sonarqube.org/ SonarQube] | |||
* [[Maven]] | |||
* [[Java]] | * [[Java]] | ||
| valign="top" | | | valign="top" | | ||
* [[Maven Deploy External JAR]] | |||
| valign="top" | | | valign="top" | |
Latest revision as of 19:20, 1 April 2024
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.0</version>
</dependency>
</dependencies>
<configuration>
<suppressionsLocation>configs/checkstyle/suppressions.xml</suppressionsLocation>
<configLocation>configs/checkstyle/checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<encoding>UTF-8</encoding>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Suppressions
<?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 files="Service.java" checks="HideUtilityClassConstructor"/>
<suppress files="DataService.java" checks="HideUtilityClassConstructor"/>
<suppress files="UserService.java" checks="HideUtilityClassConstructor"/>
<suppress files="PolicyService.java" checks="HideUtilityClassConstructor"/>
</suppressions>
Checkstyle
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="severity" value="warning"/>
<module name="SuppressWarningsFilter"/>
<module name="TreeWalker">
<module name="HiddenField">
<property name="ignoreSetter" value="true"/>
<property name="ignoreConstructorParameter" value="true"/>
</module>
<module name="SuppressWarnings">
<property name="id" value="checkstyle:suppresswarnings"/>
</module>
</module>
</module>
Knowledge
mvn -Dcheckstyle.skip=true -Dmaven.test.skip=true clean install mvn -Dcheckstyle.skip=true verify |
mvn checkstyle:check -rf :<module_name> mvn checkstyle:check | |
| ||
References
|
||
| ||