mirror of
https://github.com/valitydev/java-checkstyle-config.git
synced 2024-11-06 01:35:20 +00:00
add @SuppressWarnings and checkstyle-suppressions.xml opportunity (#13)
update README
This commit is contained in:
parent
20871f6696
commit
35e07bf52e
50
README.md
50
README.md
@ -2,22 +2,31 @@
|
|||||||
Our check style config based on Google style
|
Our check style config based on Google style
|
||||||
|
|
||||||
Usage example:
|
Usage example:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.1.2</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.puppycrawl.tools</groupId>
|
||||||
|
<artifactId>checkstyle</artifactId>
|
||||||
|
<version>8.41</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>validate</id>
|
<id>validate</id>
|
||||||
<phase>validate</phase>
|
<phase>validate</phase>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configLocation>https://raw.githubusercontent.com/rbkmoney/java-checkstyle-config/master/conf/rbkmoney_google_checkstyle.xml</configLocation>
|
<configLocation>${checkstyle.config.path}</configLocation>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<failsOnError>true</failsOnError>
|
<failsOnError>true</failsOnError>
|
||||||
<consoleOutput>true</consoleOutput>
|
<consoleOutput>true</consoleOutput>
|
||||||
<violationSeverity>warning</violationSeverity>
|
<violationSeverity>warning</violationSeverity>
|
||||||
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||||
|
<suppressionsLocation>${checkstyle.config.suppressions.path}</suppressionsLocation>
|
||||||
</configuration>
|
</configuration>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>check</goal>
|
<goal>check</goal>
|
||||||
@ -26,3 +35,40 @@ Usage example:
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### SuppressWarnings examples
|
||||||
|
|
||||||
|
First path — override `${checkstyle.config.suppressions.path}` in project with `checkstyle-suppressions.xml` file and fill with your filters
|
||||||
|
|
||||||
|
pom.xml:
|
||||||
|
```xml
|
||||||
|
<properties>
|
||||||
|
<checkstyle.config.suppressions.path>checkstyle-suppressions.xml</checkstyle.config.suppressions.path>
|
||||||
|
</properties>
|
||||||
|
```
|
||||||
|
|
||||||
|
checkstyle-suppressions.xml:
|
||||||
|
```xml
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<!DOCTYPE suppressions PUBLIC
|
||||||
|
"-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN"
|
||||||
|
"https://checkstyle.org/dtds/suppressions_1_0.dtd">
|
||||||
|
|
||||||
|
<suppressions>
|
||||||
|
<!-- EXAMPLE -->
|
||||||
|
<!-- <suppress checks="LineLength"-->
|
||||||
|
<!-- files="AppConfig.java"-->
|
||||||
|
<!-- lines="0-9999"/>-->
|
||||||
|
</suppressions>
|
||||||
|
```
|
||||||
|
|
||||||
|
Other path — use:
|
||||||
|
```java
|
||||||
|
@SuppressWarnings({"checkstyle:%module_name%", "checkstyle:%module_name%""})
|
||||||
|
```
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```java
|
||||||
|
@SuppressWarnings({"checkstyle:parametername", "checkstyle:localvariablename"})
|
||||||
|
```
|
||||||
|
12
conf/checkstyle-suppressions.xml
Normal file
12
conf/checkstyle-suppressions.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<!DOCTYPE suppressions PUBLIC
|
||||||
|
"-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN"
|
||||||
|
"https://checkstyle.org/dtds/suppressions_1_0.dtd">
|
||||||
|
|
||||||
|
<suppressions>
|
||||||
|
<!-- EXAMPLE -->
|
||||||
|
<!-- <suppress checks="LineLength"-->
|
||||||
|
<!-- files="AppConfig.java"-->
|
||||||
|
<!-- lines="0-9999"/>-->
|
||||||
|
</suppressions>
|
@ -33,6 +33,7 @@
|
|||||||
default="checkstyle-suppressions.xml" />
|
default="checkstyle-suppressions.xml" />
|
||||||
<property name="optional" value="true"/>
|
<property name="optional" value="true"/>
|
||||||
</module>
|
</module>
|
||||||
|
<module name="SuppressWarningsFilter"/>
|
||||||
|
|
||||||
<!-- Checks for whitespace -->
|
<!-- Checks for whitespace -->
|
||||||
<!-- See http://checkstyle.org/config_whitespace.html -->
|
<!-- See http://checkstyle.org/config_whitespace.html -->
|
||||||
@ -48,6 +49,7 @@
|
|||||||
</module>
|
</module>
|
||||||
|
|
||||||
<module name="TreeWalker">
|
<module name="TreeWalker">
|
||||||
|
<module name="SuppressWarningsHolder"/>
|
||||||
<module name="OuterTypeFilename"/>
|
<module name="OuterTypeFilename"/>
|
||||||
<module name="IllegalTokenText">
|
<module name="IllegalTokenText">
|
||||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user