How to suppress Scalastyle warning?
Asked Answered
J

3

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?

Jagannath answered 21/2, 2014 at 10:17 Comment(0)
W
62

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

Wicketkeeper answered 21/2, 2014 at 10:24 Comment(0)
F
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
}
Foreknow answered 16/7, 2015 at 19:29 Comment(0)
C
0

You may also add a

scalastyle_config.xml

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

Calibre answered 4/8, 2021 at 12:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.