【发布时间】:2014-02-21 10:17:06
【问题描述】:
我得到以下代码:
string match {
case Regex(_, "1", "0", _, _) =>
case Regex(_, "1", "1", null, _) =>
}
Scalastyle 抱怨这里无法避免使用 null。 有什么办法可以仅针对这一行禁止警告?
【问题讨论】:
标签: scalastyle
我得到以下代码:
string match {
case Regex(_, "1", "0", _, _) =>
case Regex(_, "1", "1", null, _) =>
}
Scalastyle 抱怨这里无法避免使用 null。 有什么办法可以仅针对这一行禁止警告?
【问题讨论】:
标签: scalastyle
Scalastyle 理解抑制 cmets:
// scalastyle:off <rule id>
...
// scalastyle:on <rule id>
已列出规则 ID here
在你的情况下,id 只是空:
// scalastyle:off null
...
// scalastyle:on null
mailing list 也回答了这个问题
【讨论】:
对于单行,您只需将// scalastyle:ignore <rule-id> 附加到末尾,如下所示:
string match {
case Regex(_, "1", "0", _, _) =>
case Regex(_, "1", "1", null, _) => // scalastyle:ignore null
}
如果您希望 Scalastyle 忽略的内容很明显,您可以通过省略 rule-id 来禁用对当前行的所有检查(对于开/关 cmets 也可以):
string match {
case Regex(_, "1", "0", _, _) =>
case Regex(_, "1", "1", null, _) => // scalastyle:ignore
}
【讨论】:
【讨论】: