Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress Scalastyle warning?

Tags:

scalastyle

I got following code:

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

Scalastyle is complaining about usage of null which cannot be avoided here. Any way I can suppress warning just for this line?

like image 320
Kiril Avatar asked Feb 21 '14 10:02

Kiril


2 Answers

Scalastyle understands suppression comments:

// scalastyle:off <rule id>
...
// scalastyle:on <rule id>

Rule ids are listed here

In your case, the id is simply null:

// scalastyle:off null
...
// scalastyle:on null

This was also answered on the mailing list

like image 60
mbarton Avatar answered Oct 15 '22 17:10

mbarton


For a single line, you just append // scalastyle:ignore <rule-id> to the end, like so:

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

If it's obvious what you want Scalastyle to ignore, you can disable all checks for the current line by omitting the rule-id (as you can for the on/off comments as well):

string match {
  case Regex(_, "1", "0", _, _)    =>
  case Regex(_, "1", "1", null, _) => // scalastyle:ignore
}
like image 39
Mike Allen Avatar answered Oct 15 '22 18:10

Mike Allen