Linting - Maven
If the pipeline is not working for the chosen linter or the chosen linter is not implemented, please open a help desk ticket .
Configuration for Checkstyle Linter
SIMPLE sample xml that can be added to your pom.xml file to customize the checkstyle plugin is displayed below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<configLocation>maven_checks.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<violationSeverity>warning</violationSeverity>
<failOnViolation>true</failOnViolation>
<linkXRef>false</linkXRef>
</configuration>
</plugin>
See additional notes below concerning the configuration options for checkstyle.
More Complex Configuration.
NOTE: Use of config folder 'config/checkstyle.'
example config/checkstyle directory attached as tar.gz
maven pom plugin section
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<configLocation>config/checkstyle/checkstyle.xml</configLocation>
<suppressionsLocation>config/checkstyle/suppressions.xml</suppressionsLocation>
<propertyExpansion>config_loc=${basedir}/config/checkstyle</propertyExpansion>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Additional Notes Concerning the Java (Maven) Checkstyle Plugin
Documentation Configuration: https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/custom-checker-config.html
The configLocation parameter is the path to the file that defines the lint rules that will be used. In the example above, it is looking for a file named maven_checks.xml located at the project root. If the file is located elsewhere in the project, the path to the file needs to be included.
For projects that have their source files in a directory other than the src directory, there is an optional parameter named sourceDirectory that will need to be set to the directory with the source files.
The violationSeverity parameter and the failOnViolation parameter together set the minimum violation level that must be found before the stage fails. Different checkstyle lint rules set their violation severity differently, some using "error" as their maximum and others using "warning" as their maximum. We suggest setting violationSeverity to match the maximum violation severity available in the ruleset that is chosen.
There is also an optional parameter named suppressionsLocation, which would contain a link to the file containing the lint suppressions filter.
There is also the option to bind checkstyle to run as a part of the standard Maven lifecycle phases. Doing this is discouraged as this may cause unintended behavior, such as checkstyle accidentally running during the unit test phase or the package phase compiling the code a second time during the lint phase.