简体   繁体   English

CodeNarc在DuplicateStringLiteral规则上对ignoreStrings中包含的字符串失败

[英]CodeNarc failing on DuplicateStringLiteral rule for strings included in ignoreStrings

I'm using the CodeNarc plug for Gradle with CodeNarc 1.1. 我正在将CodeNarc插件用于CodeNarc 1.1的Gradle。 I am using the DuplicateStringLiteral rule and passing in ignoreStrings: ['1', '2'] in the config file but the rule is not respecting the values I'm passing in. It's a groovy config file, section looks like: 我正在使用DuplicateStringLiteral规则,并在配置文件中传递ignoreStrings:['1','2'],但该规则不尊重我要传递的值。这是一个常规配置文件,部分如下所示:

DuplicateStringLiteral (
        ignoreStrings: ['1', '2']
)

I am also using DuplicateNumberLiteral and defined the ignoreNumbers property the same way and that seems to be working fine, so I don't think I have the syntax wrong. 我也使用DuplicateNumberLiteral并以相同的方式定义了ignoreNumbers属性,这似乎运行良好,所以我认为语法没有错误。 The report seems to pick up the ignored values as well as it shows this line in the definition for the rule: 该报告似乎选择了忽略的值,并且在规则的定义中显示了以下行:

The ignoreStrings property ([1, 2]) can optionally specify a comma-separated list of Strings to ignore. ignoreStrings属性([1,2])可以选择指定要忽略的逗号分隔的字符串列表。

Anyone see what I'm doing wrong here? 有人看到我在做什么错吗?

The documentation shows the default value of ignoreStrings to be an empty String... not an empty List. 该文档显示的ignoreStrings的默认值是一个空字符串...而不是一个空列表。 This makes me think that when it says The optional comma-separated list of Strings that should be ignored (ie, not cause a violation). 这使我想到,当它说出可选的以逗号分隔的字符串列表时,应将其忽略(即,不引起违规)。 , it means to put the list (note lack of capitalization) of comma-separated strings in a single String value for the property. ,这意味着将以逗号分隔的字符串列表(请注意,缺少大写字母)放在属性的单个String值中。

TL;DR Try: TL; DR尝试:

DuplicateStringLiteral (
        ignoreStrings: '1,2'
)

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

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