40

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?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Kiril
  • 998
  • 1
  • 11
  • 20

3 Answers3

59

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

Cory Klein
  • 51,188
  • 43
  • 183
  • 243
mbarton
  • 616
  • 6
  • 3
39

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
}
Mike Allen
  • 8,139
  • 2
  • 24
  • 46
0

You may also add a

scalastyle_config.xml

to your project, and enable/disable any rule. See http://www.scalastyle.org/configuration.html

Guildenstern70
  • 1,715
  • 18
  • 18