Skip to content

Commit 59cdaa1

Browse files
committed
Better error message, and loop that into the README.
1 parent 44b1ee4 commit 59cdaa1

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

plugin-gradle/README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,26 +146,22 @@ Starting in version `7.0.0`, Spotless now supports linting in addition to format
146146

147147
```console
148148
user@machine repo % ./gradlew build
149-
:spotlessJavaCheck FAILED
150-
The following files had format violations:
151-
src\main\java\com\diffplug\gradle\spotless\FormatExtension.java
152-
-\t\t····if·(targets.length·==·0)·{
153-
+\t\tif·(targets.length·==·0)·{
149+
:spotlessKotlinCheck FAILED
150+
There were 2 lint error(s), they must be fixed or suppressed.
151+
src/main/kotlin/com/diffplug/Foo.kt:L7 ktlint(standard:no-wildcard-imports) Wildcard import
152+
src/main/kotlin/com/diffplug/Bar.kt:L9 ktlint(standard:no-wildcard-imports) Wildcard import
154153
Resolve these lints or suppress with `suppressLintsFor`
155154
```
156155

157156
To suppress lints, you can do this:
158157

159158
```gradle
160159
spotless {
161-
suppressLintsFor { // applies to all formats
162-
file = 'src/blah/blah'
163-
}
164160
kotlin {
165-
ktfmt()
166-
suppressLintsFor { // applies to only the kotlin formats
161+
ktlint()
162+
suppressLintsFor {
167163
step = 'ktlint'
168-
shortCode = 'rename'
164+
shortCode = 'standard:no-wildcard-imports'
169165
}
170166
}
171167
}

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessTaskService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public void visitFile(FileVisitDetails fileVisitDetails) {
199199
}
200200
}
201201
}
202-
builder.setLength(builder.length() - 1); // remove trailing newline
202+
builder.append("Resolve these lints or suppress with `suppressLintsFor`");
203203
return builder.toString();
204204
}
205205
}

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/ErrorShouldRethrowTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ void anyExceptionShouldFail() throws Exception {
7070
"* What went wrong:",
7171
"Execution failed for task ':spotlessMiscCheck'.",
7272
"> There were 1 lint error(s), they must be fixed or suppressed.",
73-
" README.md:LINE_UNDEFINED noSwearingStep(swearing) No swearing!");
73+
" README.md:LINE_UNDEFINED noSwearingStep(swearing) No swearing!",
74+
" Resolve these lints or suppress with `suppressLintsFor`");
7475
}
7576

7677
@Test
@@ -119,7 +120,8 @@ void failsIfNeitherStepNorFileExempted() throws Exception {
119120
"* What went wrong:",
120121
"Execution failed for task ':spotlessMiscCheck'.",
121122
"> There were 1 lint error(s), they must be fixed or suppressed.",
122-
" README.md:LINE_UNDEFINED noSwearingStep(swearing) No swearing!");
123+
" README.md:LINE_UNDEFINED noSwearingStep(swearing) No swearing!",
124+
" Resolve these lints or suppress with `suppressLintsFor`");
123125
}
124126

125127
private void expectSuccess() throws Exception {

0 commit comments

Comments
 (0)