LintOptions

@Incubating
public interface LintOptions


DSL object for configuring lint options.

This block is replaced by the new Lint block. Unlike most other renamed blocks the new type is unrelated, to allow for some extra changes, such as removing the 'is' prefix from boolean properties.

Example:

android {
lintOptions {
// set to true to turn off analysis progress reporting by lint
quiet true
// if true, stop the gradle build if errors are found
abortOnError false
// set to true to have all release builds run lint on issues with severity=fatal
// and abort the build (controlled by abortOnError above) if fatal issues are found
checkReleaseBuilds true
// if true, only report errors
ignoreWarnings true
// if true, emit full/absolute paths to files with errors (true by default)
absolutePaths true
// if true, check all issues, including those that are off by default
checkAllWarnings true
// if true, treat all warnings as errors
warningsAsErrors true
// turn off checking the given issue id's
disable 'TypographyFractions','TypographyQuotes'
// turn on the given issue id's
enable 'RtlHardcoded','RtlCompat', 'RtlEnabled'
// check *only* the given issue id's
check 'NewApi', 'InlinedApi'
// if true, don't include source code lines in the error output
noLines true
// if true, show all locations for an error, do not truncate lists, etc.
showAll true
// whether lint should include full issue explanations in the text error output
explainIssues false
// Fallback lint configuration (default severities, etc.)
lintConfig file("default-lint.xml")
// if true, generate a text report of issues (false by default)
textReport true
// location to write the output; can be a file or 'stdout' or 'stderr'
//textOutput 'stdout'
textOutput file("$buildDir/reports/lint-results.txt")
// if true, generate an XML report for use by for example Jenkins
xmlReport true
// file to write report to (if not specified, defaults to lint-results.xml)
xmlOutput file("$buildDir/reports/lint-report.xml")
// if true, generate an HTML report (with issue explanations, sourcecode, etc)
htmlReport true
// optional path to HTML report (default will be lint-results.html in the builddir)
htmlOutput file("$buildDir/reports/lint-report.html")
// if true, generate a SARIF report (OASIS Static Analysis Results Interchange Format)
sarifReport true
// optional path to SARIF report (default will be lint-results.sarif in the builddir)
sarifOutput file("$buildDir/reports/lint-report.html")
// Set the severity of the given issues to fatal (which means they will be
// checked during release builds (even if the lint target is not included)
fatal 'NewApi', 'InlineApi'
// Set the severity of the given issues to error
error 'Wakelock', 'TextViewEdits'
// Set the severity of the given issues to warning
warning 'ResourceAsColor'
// Set the severity of the given issues to ignore (same as disabling the check)
ignore 'TypographyQuotes'
// Set the severity of the given issues to informational
informational 'StopShip'
// Use (or create) a baseline file for issues that should not be reported
baseline file("lint-baseline.xml")
// Normally most lint checks are not run on test sources (except the checks
// dedicated to looking for mistakes in unit or instrumentation tests, unless
// ignoreTestSources is true). You can turn on normal lint checking in all
// sources with the following flag, false by default:
checkTestSources true
// Like checkTestSources, but always skips analyzing tests -- meaning that it
// also ignores checks that have explicitly asked to look at test sources, such
// as the unused resource check.
ignoreTestSources true
// Normally lint will skip generated sources, but you can turn it on with this flag
checkGeneratedSources true
// Whether lint should check all dependencies too as part of its analysis.
// Default is false.
checkDependencies true
}
}

Summary

Public methods

abstract void

This method is deprecated. Replaced by lint.baseline

abstract void

This method is deprecated. Replaced by lint.baseline

abstract void

This method is deprecated. Use checkOnly instead; check will turn off all other checks so the method has been renamed to be more explicit about this

abstract void

This method is deprecated. Use checkOnly instead; check will turn off all other checks so the method has been renamed to be more explicit about this

abstract void

This method is deprecated. Replaced by lint.checkOnly += id

abstract void

This method is deprecated. Replaced by lint.checkOnly += ids

abstract void

This method is deprecated. Replaced by lint.disable += ids

abstract void

This method is deprecated. Replaced by lint.disable += ids

abstract void

This method is deprecated. Replaced by lint.enable += id

abstract void

This method is deprecated. Replaced by lint.enable += ids

abstract void

This method is deprecated. Replaced by lint.error += id

abstract void

This method is deprecated. Replaced by lint.error += ids

abstract void

This method is deprecated. Replaced by lint.fatal += id

abstract void

This method is deprecated. Replaced by lint.fatal += ids

abstract File

The baseline file to use, if any.

abstract @NonNull Set<@NonNull String>

The exact set of issues to check set by checkOnly. s If empty, lint will detect the issues that are enabled by default plus any issues enabled via enable and without issues disabled via disable.

abstract @NonNull Set<@NonNull String>

The set of issue IDs to suppress.

abstract @NonNull Set<@NonNull String>

The set of issue IDs to enable.

abstract File

The optional path to where an HTML report should be written.

abstract boolean

Whether we should write an HTML report.

abstract File

The default config file to use as a fallback.

abstract File

The optional path to where a SARIF report (OASIS Static Analysis Results Interchange Format) should be written.

abstract boolean

Whether we should write a SARIF (OASIS Static Analysis Results Interchange Format) report.

abstract File

The optional path to where a text report should be written.

abstract boolean

Whether we should write a text report.

abstract File

The optional path to where an XML report should be written.

abstract boolean

Whether we should write an XML report.

abstract void

This method is deprecated. Replaced by lint.ignore += id

abstract void

This method is deprecated. Replaced by lint.ignore += ids

abstract void

This method is deprecated. Replaced by lint.informational += id

abstract void

This method is deprecated. Replaced by lint.informational += ids

abstract boolean

Whether lint should set the exit code of the process if errors are found

abstract boolean

Whether lint should display full paths in the error output.

abstract boolean

Whether lint should check all warnings, including those off by default

abstract boolean

Whether lint should check all dependencies too as part of its analysis.

abstract boolean

Returns whether lint should run checks on generated sources.

abstract boolean

Whether lint should check for fatal errors during release builds.

abstract boolean

Whether lint should run all checks on test sources, instead of just the lint checks that have been specifically written to include tests (e.g. checks looking for specific test errors, or checks that need to consider testing code such as the unused resource detector)

abstract boolean

Whether lint should include explanations for issue errors.

abstract boolean

Whether lint should ignore all test sources.

abstract boolean

Returns whether lint will only check for errors (ignoring warnings)

abstract boolean

Whether lint should include the source lines in the output where errors occurred (true by default)

abstract boolean

Whether lint should be quiet (for example, not write informational messages such as paths to report files written)

abstract boolean

Whether lint should include all output (e.g. include all alternate locations, not truncating long messages, etc.)

abstract boolean

Whether lint should treat all warnings as errors

abstract void
@Incubating
setAbortOnError(boolean isAbortOnError)

Whether lint should set the exit code of the process if errors are found

abstract void
@Incubating
setAbsolutePaths(boolean isAbsolutePaths)

Whether lint should display full paths in the error output.

abstract void

The baseline file to use, if any.

abstract void
@Incubating
setCheckAllWarnings(boolean isCheckAllWarnings)

Whether lint should check all warnings, including those off by default

abstract void
@Incubating
setCheckDependencies(boolean isCheckDependencies)

Whether lint should check all dependencies too as part of its analysis.

abstract void
@Incubating
setCheckGeneratedSources(boolean isCheckGeneratedSources)

Returns whether lint should run checks on generated sources.

abstract void
@Incubating
setCheckReleaseBuilds(boolean isCheckReleaseBuilds)

Whether lint should check for fatal errors during release builds.

abstract void
@Incubating
setCheckTestSources(boolean isCheckTestSources)

Whether lint should run all checks on test sources, instead of just the lint checks that have been specifically written to include tests (e.g. checks looking for specific test errors, or checks that need to consider testing code such as the unused resource detector)

abstract void
@Incubating
setExplainIssues(boolean isExplainIssues)

Whether lint should include explanations for issue errors.

abstract void

The optional path to where an HTML report should be written.

abstract void
@Incubating
setHtmlReport(boolean htmlReport)

Whether we should write an HTML report.

abstract void
@Incubating
setIgnoreTestSources(boolean isIgnoreTestSources)

Whether lint should ignore all test sources.

abstract void
@Incubating
setIgnoreWarnings(boolean isIgnoreWarnings)

Returns whether lint will only check for errors (ignoring warnings)

abstract void

The default config file to use as a fallback.

abstract void
@Incubating
setNoLines(boolean isNoLines)

Whether lint should include the source lines in the output where errors occurred (true by default)

abstract void
@Incubating
setQuiet(boolean isQuiet)

Whether lint should be quiet (for example, not write informational messages such as paths to report files written)

abstract void

The optional path to where a SARIF report (OASIS Static Analysis Results Interchange Format) should be written.

abstract void
@Incubating
setSarifReport(boolean sarifReport)

Whether we should write a SARIF (OASIS Static Analysis Results Interchange Format) report.

abstract void
@Incubating
setShowAll(boolean isShowAll)

Whether lint should include all output (e.g. include all alternate locations, not truncating long messages, etc.)

abstract void

The optional path to where a text report should be written.

abstract void
@Incubating
setTextReport(boolean textReport)

Whether we should write a text report.

abstract void
@Incubating
setWarningsAsErrors(boolean isWarningsAsErrors)

Whether lint should treat all warnings as errors

abstract void

The optional path to where an XML report should be written.

abstract void
@Incubating
setXmlReport(boolean xmlReport)

Whether we should write an XML report.

abstract void

This method is deprecated. Replaced by lint.textOutput

abstract void

This method is deprecated. Replaced by lint.textOutput

abstract void

This method is deprecated. Replaced by lint.warning += id

abstract void

This method is deprecated. Replaced by lint.warning += ids

Public methods

baseline

@Incubating
abstract void baseline(@NonNull File baselineFile)

Sets the baseline file to use, if any. The baseline file is an XML report previously created by lint, and any warnings and errors listed in that report will be ignored from analysis.

If you have a project with a large number of existing warnings, this lets you set a baseline and only see newly introduced warnings until you get a chance to go back and address the "technical debt" of the earlier warnings.

baseline

@Incubating
abstract void baseline(@NonNull String baseline)

Sets the baseline file to use, if any. The baseline file is an XML report previously created by lint, and any warnings and errors listed in that report will be ignored from analysis.

If you have a project with a large number of existing warnings, this lets you set a baseline and only see newly introduced warnings until you get a chance to go back and address the "technical debt" of the earlier warnings.

check

@Incubating
abstract void check(@NonNull String id)

Adds the id to the set of unique issues to check.

check

@Incubating
abstract void check(@NonNull String ids)

Adds the ids to the set of unique issues to check.

checkOnly

@Incubating
abstract void checkOnly(@NonNull String id)

Adds the id to the set of issues to check. Note that when using this, all other checks are turned off.

checkOnly

@Incubating
abstract void checkOnly(@NonNull String ids)

Adds the id to the set of issues to check. Note that when using this, all other checks are turned off.

disable

@Incubating
abstract void disable(@NonNull String id)

Adds the id to the set of issues to suppress.

disable

@Incubating
abstract void disable(@NonNull String ids)

Adds the ids to the set of issues to suppress.

enable

@Incubating
abstract void enable(@NonNull String id)

Adds the id to the set of issues to enable.

enable

@Incubating
abstract void enable(@NonNull String ids)

Adds the ids to the set of issues to enable.

error

@Incubating
abstract void error(@NonNull String id)

Adds a severity override for the given issue.

error

@Incubating
abstract void error(@NonNull String ids)

Adds a severity override for the given issues.

fatal

@Incubating
abstract void fatal(@NonNull String id)

Adds a severity override for the given issue.

fatal

@Incubating
abstract void fatal(@NonNull String ids)

Adds a severity override for the given issues.

getBaselineFile

@Incubating
abstract File getBaselineFile()

The baseline file to use, if any. The baseline file is an XML report previously created by lint, and any warnings and errors listed in that report will be ignored from analysis.

If you have a project with a large number of existing warnings, this lets you set a baseline and only see newly introduced warnings until you get a chance to go back and address the "technical debt" of the earlier warnings.

getCheckOnly

@Incubating
abstract @NonNull Set<@NonNull StringgetCheckOnly()

The exact set of issues to check set by checkOnly. s If empty, lint will detect the issues that are enabled by default plus any issues enabled via enable and without issues disabled via disable.

getDisable

@Incubating
abstract @NonNull Set<@NonNull StringgetDisable()

The set of issue IDs to suppress.

Issues passed to disable to this list, call Callers are allowed to modify this collection.

getEnable

@Incubating
abstract @NonNull Set<@NonNull StringgetEnable()

The set of issue IDs to enable. Callers are allowed to modify this collection.

getHtmlOutput

@Incubating
abstract File getHtmlOutput()

The optional path to where an HTML report should be written. Setting this property will also turn on htmlReport.

getHtmlReport

@Incubating
abstract boolean getHtmlReport()

Whether we should write an HTML report. Default is true. The location can be controlled by htmlOutput.

getLintConfig

@Incubating
abstract File getLintConfig()

The default config file to use as a fallback. This corresponds to a lint.xml file with severities etc to use when a project does not have more specific information.

getSarifOutput

@Incubating
abstract File getSarifOutput()

The optional path to where a SARIF report (OASIS Static Analysis Results Interchange Format) should be written. Setting this property will also turn on sarifReport.

getSarifReport

@Incubating
abstract boolean getSarifReport()

Whether we should write a SARIF (OASIS Static Analysis Results Interchange Format) report. Default is false. The location can be controlled by sarifOutput.

getTextOutput

@Incubating
abstract File getTextOutput()

The optional path to where a text report should be written. The special value "stdout" can be used to point to standard output. Setting this property will also turn on textReport.

getTextReport

@Incubating
abstract boolean getTextReport()

Whether we should write a text report. Default is false. The location can be controlled by textOutput.

getXmlOutput

@Incubating
abstract File getXmlOutput()

The optional path to where an XML report should be written. Setting this property will also turn on xmlReport.

getXmlReport

@Incubating
abstract boolean getXmlReport()

Whether we should write an XML report. Default is true. The location can be controlled by xmlOutput.

ignore

@Incubating
abstract void ignore(@NonNull String id)

Adds a severity override for the given issue.

ignore

@Incubating
abstract void ignore(@NonNull String ids)

Adds a severity override for the given issues.

informational

@Incubating
abstract void informational(@NonNull String id)

Adds a severity override for the given issue.

informational

@Incubating
abstract void informational(@NonNull String ids)

Adds a severity override for the given issues.

isAbortOnError

@Incubating
abstract boolean isAbortOnError()

Whether lint should set the exit code of the process if errors are found

isAbsolutePaths

@Incubating
abstract boolean isAbsolutePaths()

Whether lint should display full paths in the error output. By default the paths are relative to the path lint was invoked from.

isCheckAllWarnings

@Incubating
abstract boolean isCheckAllWarnings()

Whether lint should check all warnings, including those off by default

isCheckDependencies

@Incubating
abstract boolean isCheckDependencies()

Whether lint should check all dependencies too as part of its analysis. Default is false.

isCheckGeneratedSources

@Incubating
abstract boolean isCheckGeneratedSources()

Returns whether lint should run checks on generated sources.

isCheckReleaseBuilds

@Incubating
abstract boolean isCheckReleaseBuilds()

Whether lint should check for fatal errors during release builds. Default is true. If issues with severity "fatal" are found, the release build is aborted.

isCheckTestSources

@Incubating
abstract boolean isCheckTestSources()

Whether lint should run all checks on test sources, instead of just the lint checks that have been specifically written to include tests (e.g. checks looking for specific test errors, or checks that need to consider testing code such as the unused resource detector)

isExplainIssues

@Incubating
abstract boolean isExplainIssues()

Whether lint should include explanations for issue errors. (Note that HTML and XML reports intentionally do this unconditionally, ignoring this setting.)

isIgnoreTestSources

@Incubating
abstract boolean isIgnoreTestSources()

Whether lint should ignore all test sources. This is like isCheckTestSources, but always skips analyzing tests -- meaning that it also ignores checks that have explicitly asked to look at test sources, such as the unused resource check.

isIgnoreWarnings

@Incubating
abstract boolean isIgnoreWarnings()

Returns whether lint will only check for errors (ignoring warnings)

isNoLines

@Incubating
abstract boolean isNoLines()

Whether lint should include the source lines in the output where errors occurred (true by default)

isQuiet

@Incubating
abstract boolean isQuiet()

Whether lint should be quiet (for example, not write informational messages such as paths to report files written)

isShowAll

@Incubating
abstract boolean isShowAll()

Whether lint should include all output (e.g. include all alternate locations, not truncating long messages, etc.)

isWarningsAsErrors

@Incubating
abstract boolean isWarningsAsErrors()

Whether lint should treat all warnings as errors

setAbortOnError

@Incubating
abstract void setAbortOnError(boolean isAbortOnError)

Whether lint should set the exit code of the process if errors are found

setAbsolutePaths

@Incubating
abstract void setAbsolutePaths(boolean isAbsolutePaths)

Whether lint should display full paths in the error output. By default the paths are relative to the path lint was invoked from.

setBaselineFile

@Incubating
abstract void setBaselineFile(File baselineFile)

The baseline file to use, if any. The baseline file is an XML report previously created by lint, and any warnings and errors listed in that report will be ignored from analysis.

If you have a project with a large number of existing warnings, this lets you set a baseline and only see newly introduced warnings until you get a chance to go back and address the "technical debt" of the earlier warnings.

setCheckAllWarnings

@Incubating
abstract void setCheckAllWarnings(boolean isCheckAllWarnings)

Whether lint should check all warnings, including those off by default

setCheckDependencies

@Incubating
abstract void setCheckDependencies(boolean isCheckDependencies)

Whether lint should check all dependencies too as part of its analysis. Default is false.

setCheckGeneratedSources

@Incubating
abstract void setCheckGeneratedSources(boolean isCheckGeneratedSources)

Returns whether lint should run checks on generated sources.

setCheckReleaseBuilds

@Incubating
abstract void setCheckReleaseBuilds(boolean isCheckReleaseBuilds)

Whether lint should check for fatal errors during release builds. Default is true. If issues with severity "fatal" are found, the release build is aborted.

setCheckTestSources

@Incubating
abstract void setCheckTestSources(boolean isCheckTestSources)

Whether lint should run all checks on test sources, instead of just the lint checks that have been specifically written to include tests (e.g. checks looking for specific test errors, or checks that need to consider testing code such as the unused resource detector)

setExplainIssues

@Incubating
abstract void setExplainIssues(boolean isExplainIssues)

Whether lint should include explanations for issue errors. (Note that HTML and XML reports intentionally do this unconditionally, ignoring this setting.)

setHtmlOutput

@Incubating
abstract void setHtmlOutput(File htmlOutput)

The optional path to where an HTML report should be written. Setting this property will also turn on htmlReport.

setHtmlReport

@Incubating
abstract void setHtmlReport(boolean htmlReport)

Whether we should write an HTML report. Default is true. The location can be controlled by htmlOutput.

setIgnoreTestSources

@Incubating
abstract void setIgnoreTestSources(boolean isIgnoreTestSources)

Whether lint should ignore all test sources. This is like isCheckTestSources, but always skips analyzing tests -- meaning that it also ignores checks that have explicitly asked to look at test sources, such as the unused resource check.

setIgnoreWarnings

@Incubating
abstract void setIgnoreWarnings(boolean isIgnoreWarnings)

Returns whether lint will only check for errors (ignoring warnings)

setLintConfig

@Incubating
abstract void setLintConfig(File lintConfig)

The default config file to use as a fallback. This corresponds to a lint.xml file with severities etc to use when a project does not have more specific information.

setNoLines

@Incubating
abstract void setNoLines(boolean isNoLines)

Whether lint should include the source lines in the output where errors occurred (true by default)

setQuiet

@Incubating
abstract void setQuiet(boolean isQuiet)

Whether lint should be quiet (for example, not write informational messages such as paths to report files written)

setSarifOutput

@Incubating
abstract void setSarifOutput(File sarifOutput)

The optional path to where a SARIF report (OASIS Static Analysis Results Interchange Format) should be written. Setting this property will also turn on sarifReport.

setSarifReport

@Incubating
abstract void setSarifReport(boolean sarifReport)

Whether we should write a SARIF (OASIS Static Analysis Results Interchange Format) report. Default is false. The location can be controlled by sarifOutput.

setShowAll

@Incubating
abstract void setShowAll(boolean isShowAll)

Whether lint should include all output (e.g. include all alternate locations, not truncating long messages, etc.)

setTextOutput

@Incubating
abstract void setTextOutput(File textOutput)

The optional path to where a text report should be written. The special value "stdout" can be used to point to standard output. Setting this property will also turn on textReport.

setTextReport

@Incubating
abstract void setTextReport(boolean textReport)

Whether we should write a text report. Default is false. The location can be controlled by textOutput.

setWarningsAsErrors

@Incubating
abstract void setWarningsAsErrors(boolean isWarningsAsErrors)

Whether lint should treat all warnings as errors

setXmlOutput

@Incubating
abstract void setXmlOutput(File xmlOutput)

The optional path to where an XML report should be written. Setting this property will also turn on xmlReport.

setXmlReport

@Incubating
abstract void setXmlReport(boolean xmlReport)

Whether we should write an XML report. Default is true. The location can be controlled by xmlOutput.

textOutput

@Incubating
abstract void textOutput(@NonNull File textOutput)

Sets the optional path to where a text report should be written

textOutput

@Incubating
abstract void textOutput(@NonNull String textOutput)

Sets the optional path to where a text report should be written

warning

@Incubating
abstract void warning(@NonNull String id)

Adds a severity override for the given issue.

warning

@Incubating
abstract void warning(@NonNull String ids)

Adds a severity override for the given issues.