Skip to content

obsolete - Add support for linters #1097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d5b0421
Define a `Lint`.
nedtwigg Jan 12, 2022
db676fc
Add a `lint` method to `FormatterStep` and let it wripple through.
nedtwigg Jan 12, 2022
5dc6271
Make Lint roundtrippable through a String.
nedtwigg Jan 13, 2022
cc71751
Formatter.lint
nedtwigg Jan 13, 2022
aac3972
Lint ripples through DirtyState and Formatter.
nedtwigg Jan 13, 2022
a25eded
SpotlessTaskImpl now generates both a formatted result and a lint res…
nedtwigg Jan 13, 2022
89339cd
SpotlessTaskImpl now generates a lint result for `check` and for `app…
nedtwigg Jan 14, 2022
cac4f70
Gradle spotlessCheck will now throw an error if all of the files are …
nedtwigg Jan 14, 2022
d4ec76b
Maven spotless:check will now throw an error if all of the files are …
nedtwigg Jan 14, 2022
7a1e72a
Default `FormatterFunc.lint` now traps errors from the formatter itse…
nedtwigg Jan 14, 2022
109c7fb
Remove `FormatExceptionPolicy`.
nedtwigg Jan 14, 2022
0049661
Remove `FormatExceptionPolicy` from the maven plugin.
nedtwigg Jan 14, 2022
dd5165f
Replace `FormatExceptionPolicy` with `LintPolicy` inside the Gradle p…
nedtwigg Jan 14, 2022
85fbe71
Lint.toFile might need to create parent directories.
nedtwigg Jan 14, 2022
e8e5df5
Lints are now quietly suppressed during `apply`, you have to do `chec…
nedtwigg Jan 14, 2022
6ec06cc
Fix spotbugs warnings.
nedtwigg Jan 14, 2022
9557c66
Fix the bug I made from fixing spotbugs :)
nedtwigg Jan 14, 2022
2844068
Make sure that FormatterFunc.Closeable's helpers support linting.
nedtwigg Jan 14, 2022
9134d8c
Fix FormatterFunc.Closeable earlier
nedtwigg Jan 14, 2022
5a9799d
Refactor PipeStepPair so that it can detect lost tags within our new …
nedtwigg Jan 14, 2022
07b39cb
Rename PipeStepPair to FenceStep.
nedtwigg Jan 14, 2022
78ddcd6
Removed `rootDir` property `Formatter` and its builder because it was…
nedtwigg Jan 14, 2022
f947c7b
`DiffMessageFormatter.Builder::formatter` needs a new `Path rootDir` …
nedtwigg Jan 14, 2022
a3eef1f
Adapt StepHarness for the new "exceptions never get thrown" environment.
nedtwigg Jan 15, 2022
3f72b7e
When a step throws an exception, we now accurately consider the entir…
nedtwigg Jan 14, 2022
1ed3149
Fix tests.
nedtwigg Jan 15, 2022
6e38887
Fix spotbugs.
nedtwigg Jan 15, 2022
eb0feed
Fix wrong SuppressFBWarnings import.
nedtwigg Jan 15, 2022
248ec28
Fix tests on windows.
nedtwigg Jan 15, 2022
3aa780e
Fix prettier error test.
nedtwigg Jan 15, 2022
e110426
Make our testing parallel.
nedtwigg Jan 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
When a step throws an exception, we now accurately consider the entir…
…e file as linted, rather than just the first line.
  • Loading branch information
nedtwigg committed Jan 15, 2022
commit 3f72b7ef6e7452ec8887741729b7b44dda75a2f4
2 changes: 1 addition & 1 deletion lib/src/main/java/com/diffplug/spotless/Formatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public List<Lint> lint(String content, File file) {
totalLints.addAll(lints);
}
} catch (Throwable e) {
totalLints.add(Lint.createFromThrowable(step, e));
totalLints.add(Lint.createFromThrowable(step, content, e));
}
}
if (totalLints.isEmpty()) {
Expand Down
5 changes: 3 additions & 2 deletions lib/src/main/java/com/diffplug/spotless/Lint.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static void toFile(List<Lint> lints, File file) throws IOException {
}

/** Attempts to parse a line number from the given exception. */
static Lint createFromThrowable(FormatterStep step, Throwable e) {
static Lint createFromThrowable(FormatterStep step, String content, Throwable e) {
Throwable current = e;
while (current != null) {
String message = current.getMessage();
Expand All @@ -183,7 +183,8 @@ static Lint createFromThrowable(FormatterStep step, Throwable e) {
}
current = current.getCause();
}
return Lint.create(step.getName(), ThrowingEx.stacktrace(e), 1);
int numNewlines = (int) content.codePoints().filter(c -> c == '\n').count();
return Lint.create(step.getName(), ThrowingEx.stacktrace(e), 1, 1 + numNewlines);
}

private static int lineNumberFor(String message) {
Expand Down