Go to file
2021-03-11 19:33:12 +07:00
conf add @SuppressWarnings and checkstyle-suppressions.xml opportunity (#13) 2021-03-11 19:33:12 +07:00
.gitignore Initial commit (#1) 2021-01-21 16:07:57 +03:00
LICENSE Cleanup from maven (#5) 2021-01-28 18:43:43 +03:00
README.md add @SuppressWarnings and checkstyle-suppressions.xml opportunity (#13) 2021-03-11 19:33:12 +07:00

java-checkstyle-config

Our check style config based on Google style

Usage example:

<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>8.41</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <id>validate</id>
      <phase>validate</phase>
      <configuration>
        <configLocation>${checkstyle.config.path}</configLocation>
        <encoding>UTF-8</encoding>
        <failsOnError>true</failsOnError>
        <consoleOutput>true</consoleOutput>
        <violationSeverity>warning</violationSeverity>
        <includeTestSourceDirectory>true</includeTestSourceDirectory>
        <suppressionsLocation>${checkstyle.config.suppressions.path}</suppressionsLocation>
      </configuration>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>

SuppressWarnings examples

First path — override ${checkstyle.config.suppressions.path} in project with checkstyle-suppressions.xml file and fill with your filters

pom.xml:

<properties>
    <checkstyle.config.suppressions.path>checkstyle-suppressions.xml</checkstyle.config.suppressions.path>
</properties>

checkstyle-suppressions.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:

@SuppressWarnings({"checkstyle:%module_name%", "checkstyle:%module_name%""})

Example:

@SuppressWarnings({"checkstyle:parametername", "checkstyle:localvariablename"})