Skip to content

Support Android Lint #1089

Open
Open

Description

@rougsig

I have a large project, I would like not to check it all. I only want to check the changed files. AndroidLint haven't that feature. I need to write wrapper to implement it. It can be cool, if i can use AndroidLint from spotless with git ratchet feature.

Does spotless support AndroidLint?

Activity

  1. nedtwigg commented on Jan 12, 2022

    @nedtwigg
    Member

    It doesn't, but we'd be happy to take a PR which adds it. In this and #143 you're proposing adding support for linting tools rather than formatters.

    A key thing to understand about Spotless' current model is that a FormatterStep is just a String -> String (more details here).

    Perhaps we could create a new infrastructure for linters like so:

    public class Lint {
      int lineStart, lineEnd;
      String lintId;
      String comment;
      @Nullable String replacement;
    }
    
    public interface LintStep {
      public List<Lint> lintsFor(String formattedUnix, File file);
    }

    We could then add a List<LintStep> lintSteps to Formatter

    private List<FormatterStep> steps;
    private FormatExceptionPolicy exceptionPolicy;

    A computed result would become String cleanTxt, List<Lint> lintsOnCleanTxt.

    Whenever adding a big feature like that, I think it's key to have at least two actual clients and ideally three. We now have:

    • detekt
    • androidlint
    • ktlint (sorta)

    So I think that's enough to test this out. If anyone is interested in writing something along these lines I'd be happy to help them.

  2. rougsig commented on Jan 12, 2022

    @rougsig
    Author

    Sounds great. So i think. detekt should be implemented with that model String -> Optional<ErrorMsgAndLocation>. It can be cool, if you can help me with LintStep infrastructure.

  3. nedtwigg commented on Jan 12, 2022

    @nedtwigg
    Member

    I'll push up a draft PR for the infrastructure of this.

  4. rougsig commented on Jan 13, 2022

    @rougsig
    Author

    In fact ktlint is linter too, not only formatter. May be more correct abstraction for spotless is str -> Pair<str, issue[]>, where left is autofixed issues, right is list of issues which used sould fixed manually.

    Or we shoud create two kind of aggregation? Formatter and Linter.
    where, Formatter is pure function str -> str, Linter is pure function str -> Pair<str, issue[]>.

  5. nedtwigg commented on Jan 14, 2022

    @nedtwigg
    Member

    A PR against #1097 would be very welcome, for any of the linters discussed :)

  6. marked Support Android Lint #2784 as a duplicate of this issue on Feb 2, 2026
  7. changed the title [-]AndroidLint support[/-] [+]Support Android Lint[/+] on Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions