Skip to content

Commit 5d2213e

Browse files
committed
update the README.
1 parent 74b9cf2 commit 5d2213e

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

plugin-maven/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,64 @@ By default, `spotless:check` is bound to the `verify` phase. You might want to
19441944
- set `-Dspotless.check.skip=true` at the command line
19451945
- set `spotless.check.skip` to `true` in the `<properties>` section of the `pom.xml`
19461946

1947+
### Suppressing lint errors
1948+
1949+
Sometimes Spotless will encounter lint errors that can't be auto-fixed. For example, if you run `mvn spotless:check`, you might see:
1950+
1951+
```
1952+
[ERROR] Unable to format file src/main/java/com/example/App.java
1953+
[ERROR] Step 'removeWildcardImports' found problem in 'App.java':
1954+
[ERROR] Do not use wildcard imports
1955+
```
1956+
1957+
To suppress these lints, you can use the `<lintSuppressions>` configuration:
1958+
1959+
```xml
1960+
<plugin>
1961+
<groupId>com.diffplug.spotless</groupId>
1962+
<artifactId>spotless-maven-plugin</artifactId>
1963+
<version>${spotless.version}</version>
1964+
<configuration>
1965+
<java>
1966+
<removeWildcardImports/>
1967+
</java>
1968+
<lintSuppressions>
1969+
<lintSuppression>
1970+
<path>src/main/java/com/example/App.java</path>
1971+
<step>removeWildcardImports</step>
1972+
<shortCode>*</shortCode>
1973+
</lintSuppression>
1974+
</lintSuppressions>
1975+
</configuration>
1976+
</plugin>
1977+
```
1978+
1979+
Each `<lintSuppression>` can match by:
1980+
- `<path>` - file path (supports wildcards like `*`)
1981+
- `<step>` - step name (supports wildcards like `*`)
1982+
- `<shortCode>` - specific error code (supports wildcards like `*`)
1983+
1984+
You can suppress multiple patterns:
1985+
1986+
```xml
1987+
<lintSuppressions>
1988+
<!-- Suppress all wildcard import errors in legacy code -->
1989+
<lintSuppression>
1990+
<path>src/main/java/com/example/legacy/*</path>
1991+
<step>removeWildcardImports</step>
1992+
<shortCode>*</shortCode>
1993+
</lintSuppression>
1994+
<!-- Suppress all errors from a specific step -->
1995+
<lintSuppression>
1996+
<path>*</path>
1997+
<step>removeWildcardImports</step>
1998+
<shortCode>*</shortCode>
1999+
</lintSuppression>
2000+
</lintSuppressions>
2001+
```
2002+
2003+
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.
2004+
19472005
<a name="preview"></a>
19482006

19492007
## How do I preview what `mvn spotless:apply` will do?

0 commit comments

Comments
 (0)