Excluding classes in Maven Checkstyle plugin reports

If, like me, you arrived here searching for a way to exclude generated sources from checkstyle, do this: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.15</version> <configuration> <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> </configuration> </plugin> By default, the checkstyle:checkstyle goal of the checkstyle plugin uses ${project.compileSourceRoots}, which apparently includes generated source directories. If you change it to ${project.build.sourceDirectory}, it will use only the source … Read more

IntelliJ IDEA code format from checkstyle configuration

finally there is something: checkstyle-IDEA since 4.24.0 features import of checkstyle config. A solution is available now: Please install CheckStyle-IDEA plugin (http://plugins.jetbrains.com/plugin/1065?pr=idea), it can be found via plug-in repository (Settings|Plugins|Browse repositories). Go to Settings|Editor|Code Style, choose a code style you want to import CheckStyle configuration to. Click Manage…|Import.., choose “CheckStyle Configuration” and select a corresponding … Read more

Checkstyle, Unable to create Root Module

This happened to me when I updated Android Gradle Plugin to 3.3.0 Please run this: ./gradlew checkstyle –stacktrace Probably you will need to check your checkstyle.xml config file. I needed to move those two tags: <module name=”SuppressionCommentFilter”/> <!–Enable usage SUPPRESS CHECKSTYLE comment–> <module name=”SuppressWithNearbyCommentFilter”> <property name=”commentFormat” value=”CHECKSTYLE IGNORE”/> <property name=”checkFormat” value=”.*”/> <property name=”influenceFormat” value=”0″/> </module> … Read more

How to suppress all checks for a file in Checkstyle?

Don’t know whether you’re using command line or in an IDE, but you’ll basically need a suppresions file. If you’re manually editing the Checkstyle config file, add a new module to it: <module name=”SuppressionFilter”> <property name=”file” value=”mysuppressions.xml” /> </module> Your mysuppression.xml can be something like: <?xml version=”1.0″?> <!DOCTYPE suppressions PUBLIC “-//Puppy Crawl//DTD Suppressions 1.1//EN” “http://www.puppycrawl.com/dtds/suppressions_1_1.dtd”> … Read more

Ignoring of Checkstyle warnings with annotation @SuppressWarnings

A. SuppressWarnings Filter With checkstyle 6.5.0 I can use @SuppressWarnings. Please consider following points: The SuppressWarnings filter has to be enabled in the Checkstyle settings (see “TreeWalker” in the example settings below). In the tag for the SuppressWarnings annotation you have to use the name of the checkstyle module in all lower case. Optionally a … Read more