简体   繁体   中英

Codenarc priority meanings

I'm a novice CodeNarc user. After a fair amount of googling, I still haven't found any clear indication of what the 3 CodeNarc finding priority levels mean. Right now I take priority 1 to probably mean critical, must fix. But how are other priorities defined?

For further clarification, I am mainly using it for the security ruleset.

The CodeNarc rule priorities aren't explicitly defined anywhere.

When you use the Groovy script provided by CodeNarc to generate a new rule, the default priority is 2 . Examining the existing rules distributed with CodeNarc 0.22, there are 0 priority 1 rules, 245 priority 2 rules, and 96 priority 3 rules.

The primary use of these priority levels is so you can define a threshold to determine a pass/fail for your code. If you take a look at the parameters for CodeNarc Ant Task , there are three relevant ones you can set (one for each priority, the same as the one pasted below).

maxPriority1Violations The maximum number of priority 1 violations allowed before failing the build (throwing a BuildException).

Other CodeNarc runners have a similar concept, for example the Grails CodeNarc plugin , see Configuring Maximum Number of Violations.

So it's really up to you to decide the meaning of each priority. You can not allow any priority 1 violations if they're "critical, must fix" problems. You can allow up to 50 priority 2 violations if they're "okay, but don't want too many" or you can decide to let them all slide.

Note that you can override the priority for individual rules if you don't like the default priority.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM