AndroidLint support
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?
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
https://github.com/diffplug/spotless/blob/c66f83e434ff91ee6b0fcc3a475c6aa0e10cdc95/lib/src/main/java/com/diffplug/spotless/Formatter.java#L45-L46
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.
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.
I'll push up a draft PR for the infrastructure of this.
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[]>.
A PR against #1097 would be very welcome, for any of the linters discussed :)