I'm using Gradle 5.0 and Checkstyle 8.15. I have a Java project with the following Checkstyle config and suppressions files:
checkstyle.xml references suppressions.xml like so:
<module name="SuppressionFilter">
<property name="file" value="config/checkstyle/suppressions.xml"/>
</module>
If I run checkstyle against my source, it fails:
$ ./gradlew checkstyleMain -xwebpack
Configure project : Defaulting to dev Spring profile
Task :checkstyleMain FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':checkstyleMain'. Unable to create Root Module: config {/Users/robert/dev/...}, classpath {/Users/robert/dev/...}.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
- Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s 3 actionable tasks: 1 executed, 2 up-to-date
If I remove the reference to suppressions.xml, the build completes (checkstyle finds errors that would have been ignored if the suppressions were discovered).
My understanding from the doc is that the root for referenced files like config/checkstyle/suppressions.xml is the project root. That doesn't seem to be the case however.
Am I not setting up checkstyle properly?
Checkstyle allows the definition of a list of files and their line ranges that should be suppressed from reporting any violations (known as a suppressions filter ).
Checkstyle obtains a configuration from an XML document whose elements specify the configuration's hierarchy of modules and their properties. You provide a file that contains the configuration document when you invoke Checkstyle at the command line, and when you run a Checkstyle task in ant.
If you are placing suppressions.xml inside project-dir/config/checkstyle/ , please use the following way,
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml"/>
</module>
Latest version of checkstyle has config_loc variable set as project-dir/config/checkstyle/ automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With