Skip to content

Commit 8f43b2f

Browse files
committed
First cut at gradle docs.
1 parent f4df956 commit 8f43b2f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

plugin-gradle/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Spotless supports all of Gradle's built-in performance features (incremental bui
5353

5454
- [**Quickstart**](#quickstart)
5555
- [Requirements](#requirements)
56+
- [Linting](#linting)
5657
- **Languages**
5758
- [Java](#java) ([google-java-format](#google-java-format), [eclipse jdt](#eclipse-jdt), [clang-format](#clang-format), [prettier](#prettier), [palantir-java-format](#palantir-java-format), [formatAnnotations](#formatAnnotations), [cleanthat](#cleanthat))
5859
- [Groovy](#groovy) ([eclipse groovy](#eclipse-groovy))
@@ -139,6 +140,39 @@ Spotless requires JRE 11+ and Gradle 6.1.1 or newer.
139140
- If you're stuck on JRE 8, use [`id 'com.diffplug.spotless' version '6.13.0'` or older](https://github.com/diffplug/spotless/blob/main/plugin-gradle/CHANGES.md#6130---2023-01-14).
140141
- If you're stuck on an older version of Gradle, [`id 'com.diffplug.gradle.spotless' version '4.5.1'` supports all the way back to Gradle 2.x](https://github.com/diffplug/spotless/blob/main/plugin-gradle/CHANGES.md#451---2020-07-04).
141142

143+
### Linting
144+
145+
Starting in version `7.0.0`, Spotless now supports linting in addition to formatting. To Spotless, all lints are errors which must be either fixed or suppressed. Lints show up like this:
146+
147+
```console
148+
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)·{
154+
Resolve these lints or suppress with `suppressLintsFor`
155+
```
156+
157+
To suppress lints, you can do this:
158+
159+
```gradle
160+
spotless {
161+
suppressLintsFor { // applies to all formats
162+
file = 'src/blah/blah'
163+
}
164+
kotlin {
165+
ktfmt()
166+
suppressLintsFor { // applies to only the kotlin formats
167+
step = 'ktlint'
168+
shortCode = 'rename'
169+
}
170+
}
171+
}
172+
```
173+
174+
Spotless is primarily a formatter, _not_ a linter. In our opinion, a linter is just a broken formatter. But formatters do break sometimes, and representing these failures as lints that can be suppressed is more useful than just giving up.
175+
142176
<a name="applying-to-java-source"></a>
143177

144178
## Java

0 commit comments

Comments
 (0)