Skip to content

Ignoring Violations

Jon Schneider edited this page Mar 8, 2017 · 4 revisions

Ignore

When you wish to force the linter to ignore a block of build script code that it believes is in violation, you can surround the code with a block like:

gradleLint.ignore {
  // my build script code that makes the linter suspicious...
}

In this way, you can leave a rule intact for much of a build, and declaratively ignore it where you find exceptional cases.

You can also be selective about which rules to ignore in the block by providing up to 5 arguments to ignore:

gradleLint.ignore('dependency-parentheses', 'dependency-tuple') {
  // here I want to use a non-idiomatic dependency syntax, but lint for everything else
}

Fixme

gradleLint.fixme is an alternative to gradleLint.ignore that expires at a defined date in the future. Once it expires, the fixme statement itself will be treated like a critical rule failure that will fail the build whenever any lint task is ran.

gradleLint.fixme('2020-1-1', 'dependency-parentheses') {
  // my build script code that makes the linter suspicious...
}

Just like ignore, fixme can either be used to ignore all lint failures or selectively by providing a list of rules to ignore after the date predicate.