GR

CodeNarc

CodeNarc static analysis for Groovy code quality

Details

Language / Topic
groovyGroovy
Category
Linter / Formatter

Rules

balanced
- Apply CodeNarc via the Gradle `codenarc` plugin — configure `configFile = file('config/codenarc/ruleset.groovy')` in `build.gradle`.
- Enable the `basic`, `imports`, `naming`, and `unused` rule sets at minimum to catch the most common Groovy-specific code quality issues.
- Run `./gradlew codenarcMain codenarcTest` in CI to lint both production and test code separately.
- Configure `maxPriority1Violations = 0` to fail the build on any priority-1 (error) violation while allowing priority-3 (info) violations during migration.
- Use `@SuppressWarnings('VariableName')` to suppress specific CodeNarc rules on generated or framework-required code that cannot be renamed.
- Enable the `concurrency` and `security` rule sets in addition to style rules for Groovy code running in multi-threaded or web contexts.
- Use the HTML report (`codenarcMain.reports.html.required = true`) in CI artifacts to review violations across the team.