简体   繁体   English

Codenarc优先级含义

[英]Codenarc priority meanings

I'm a novice CodeNarc user. 我是CodeNarc的新手用户。 After a fair amount of googling, I still haven't found any clear indication of what the 3 CodeNarc finding priority levels mean. 经过大量的谷歌搜索,我仍然没有找到任何清晰的迹象表明3 CodeNarc查找优先级的含义。 Right now I take priority 1 to probably mean critical, must fix. 现在,我将优先级1视为关键,必须修复。 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. 没有明确定义CodeNarc规则优先级。

When you use the Groovy script provided by CodeNarc to generate a new rule, the default priority is 2 . 当您使用CodeNarc提供的Groovy脚本生成新规则时, 默认优先级为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. 检查使用CodeNarc 0.22分发的现有规则,有0个优先级1规则,245个优先级2规则和96个优先级3规则。

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). 如果您查看CodeNarc Ant Task的参数,则可以设置三个相关参数(每个优先级一个,与下面粘贴的一个相同)。

maxPriority1Violations The maximum number of priority 1 violations allowed before failing the build (throwing a BuildException). maxPriority1Violations在构建失败( maxPriority1Violations BuildException)之前允许的违反优先级1的最大数量。

Other CodeNarc runners have a similar concept, for example the Grails CodeNarc plugin , see Configuring Maximum Number of Violations. 其他CodeNarc运行程序也有类似的概念,例如Grails CodeNarc插件 ,请参阅配置最大违反次数。

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. 如果优先级1违规是“严重的,必须解决”的问题,则不能允许它们。 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. 如果它们“还可以,但不要太多”,则最多可以允许50个优先级2违例,或者您可以决定让它们全部滑动。

Note that you can override the priority for individual rules if you don't like the default priority. 请注意,如果您不喜欢默认优先级,则可以覆盖各个规则的优先级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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