Checkstyle¶
Groovy | Home | Release Notes | Plugin
By default, plugin activates if groovy sources available (src/main/groovy).
Warning
Since codenarc 3.1 there is a separate jar for groovy4 (codenarc-groovy4) and
plugin use it by default. If you need to use lower codenarc version set
quality.codenarcGroovy4 = false in order to switch to usual codenarc jar (groovy 3 based).
Note that it does not relate to your project's groovy version - codenarc will use its own
groovy version.
Output¶
24 (0 / 10 / 14) CodeNarc violations were found in 2 files
[Formatting | ClassJavadoc] sample.(GSample.groovy:3) [priority 2]
>> class GSample {
Class sample.GSample missing Javadoc
Makes sure each class and interface definition is preceded by javadoc. Enum definitions are not checked, due to strange behavior in the Groovy AST.
http://codenarc.sourceforge.net/codenarc-rules-formatting.html#ClassJavadoc
...
Counts in braces show priorities (p1/p2/p3).
Config¶
Tool config options with defaults:
quality {
codenarcVersion = '3.7.0'
codenarc = true // false to disable automatic plugin activation
// use groovy4-based codenarc version; set to false to use groovy3-based version
codenarcGroovy4 = true
suppressCodenarcRules = []
}
Suppress¶
@SuppressWarnings("ClassJavadoc")
Since codenarc 2.2 CodeNarc. prefix could be used to differentiate with pure java suppressions:
@SuppressWarnings("CodeNarc.ClassJavadoc")
To suppress all violations use:
@SuppressWarnings('CodeNarc')
Also, comments may be used for disabling blocks of file.
Global suppressions¶
Plugin could automatically disable rules in the xml file:
quality {
suppressCodenarcRules = ['ANNOYING_RULE', 'ANNOYING_RULE2']
}
When suppression declared, plugin would modify default or custom xml file and exclude specified rules.
Note
Codenarc require you only to declare "modules" (blocks of rules) and manually exclude some rules within module, if required. But, to do it, plugin have to read all rules declaration xmls from codenarc jar and this might slightly slow down initialization.