androidandroid-studiolintandroid-lint

Android Studio lint_baseline.xml does not exclude many issues that it should


I have this in my build.gradle:

android {
  lintOptions {
    abortOnError false
    absolutePaths false
    lintConfig file('lint.xml')
    baseline file('lint-baseline.xml')
  }
}

And I have run Analyze > Inspect Code previously to establish this baseline. I've also confirmed that this file does in fact exist, and is populated with issues to ignore.

However I still have many warnings showing up when I run Analyze > Inspect Code. It seems that the issues that are not excluded based on the baseline are those not listed by lint --list/the ones listed here.

They include 'Unused declaration', 'Field can be local', etc.

Is there any way to filter these out as well? Why does the code inspection check for warnings/errors that lint does not list as issues?


Solution

  • From Android Studio inspections:

    Lint can be configured with a "baseline"; a set of current issues found in a codebase, which future runs of lint will silently ignore. Only new issues not found in the baseline are reported.

    Note that while opening files in the IDE, baseline issues are not filtered out; the purpose of baselines is to allow you to get started using lint and break the build on all newly introduced errors, without having to go back and fix the entire codebase up front. However, when you open up existing files you still want to be aware of and fix issues as you come across them.

    This issue type is used to emit two types of informational messages in reports: first, whether any issues were filtered out so you don't have a false sense of security if you forgot that you've checked in a baseline file, and second, whether any issues in the baseline file appear to have been fixed such that you can stop filtering them out and get warned if the issues are re-introduced.

    I was just wondering the same thing. Maybe that will help explain things.

    The baseline feature is intended to hide linting errors in the console and make it so that new warnings/errors will break the build. Unfortunately this doesn't suppress Android Studio inspections.

    enter image description here