Java development environment memo I am building a development environment with CheckStyle, but since a lot of alerts are issued with CheckStyle, I will investigate and describe how to deal with it.
1.CheckStyle
pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.37</version>
</dependency>
</dependencies>
<configuration>
<configLocation>google_checks.xml</configLocation>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<violationSeverity>error</violationSeverity>
<consoleOutput>true</consoleOutput>
</configuration>
<executions>
<execution>
<id>checkstyle</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Download from below?
https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
The pom.xml file has the following sites set for selection. https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/custom-checker-config.html
https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
There may be a difference between the rule file and library versions.
If the package of your own class is at the beginning of the alphabet than org (jp etc.), you will be warned.
Before correction
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
Change the above rule to INFO instead of warning.
Revised
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
<property name="severity" value="info" />
</module>
Share rules such as CheckStyle with multiple modules https://ssogabe.hatenadiary.org/entry/20091219/1261196056