What is the recommended location for a custom rule set for PMD / checkstyle / findbugs?

When using Maven with various plugins for PMD, Checkstyle and / or Findbugs, what would be the recommended place to put your rules file?

+5
source share
1 answer

I usually put them in a separate parent pom, so I can reuse them later in other modules or projects. Similar to the suggestion on the checkstyle page ( https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html ), but I do not use it in the main project.

You place the files with the module called build-tools , in which you have src / main / resources / your / package with checkstyle and pmd config, and then configure this plugin with:

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.17</version> <dependencies> <dependency> <groupId>com.example.whizbang</groupId> <artifactId>build-tools</artifactId> <version>1.0</version> </dependency> </dependencies> </plugin> 

FindBugs is more complex, I usually leave it as it is, and sometimes use @SuppressFBWarnings from:

  <dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>annotations</artifactId> <version>3.0.1</version> </dependency> 
+2
source

Source: https://habr.com/ru/post/1238237/


All Articles