2014-02-21 149 views
17

我得到了下面的代码:如何抑制Scalastyle警告?

string match { 
     case Regex(_, "1", "0", _, _) => 
     case Regex(_, "1", "1", null, _) => 
    } 

Scalastyle抱怨不能避免在这里空的使用。 任何方式我可以压制这条线的警告?

回答

15

对于单行线,你只是追加// scalastyle:ignore <rule-id>到最后,就像这样:

string match { 
    case Regex(_, "1", "0", _, _) => 
    case Regex(_, "1", "1", null, _) => // scalastyle:ignore null 
} 

如果很明显你想Scalastyle忽略,你可以通过省略规则的编号禁用当前行所有检查什么(正如你可以为开/关评论一样):

string match { 
    case Regex(_, "1", "0", _, _) => 
    case Regex(_, "1", "1", null, _) => // scalastyle:ignore 
}