How to specific Scala style rules for a specific file/directory?

1.3k views Asked by At

I have some cucumber stepDef steps which are more than more than 120 characters in length, I want to exclude all stepDef files from Scala style warning.

Is there a way to to exclude a specific files/directories, using xml tag only for FileLineLengthChecker condition?

2

There are 2 answers

2
Mario Galic On

Wrapping the entire file in the following comment filter in effect excludes the file from FileLineLengthChecker rule:

// scalastyle:off line.size.limit
val foobar = 134
// scalastyle:on line.size.limit

line.size.limit is the ID of FileLineLengthChecker rule.

Multiple rules can be switched off simultaneously like so

// scalastyle:off line.size.limit
// scalastyle:off line.contains.tab
// ...
0
Fei YuanXing On

scalastyle must Paired use

// scalastyle:off line.size.limit

_FUNC_(str, regexp) - Searches a string for a regular expression and returns an integer that indicates the beginning position of the matched substring. Positions are 1-based, not 0-based. If no match is found, returns 0.

// scalastyle:on line.size.limit