All contributions

diffplug/spotless

Spotless

A Gradle and Maven plugin that formats code in many languages, from Java and Kotlin to SQL and YAML, and enforces that formatting in the build.

Language
Java
GitHub stars
5,736
Merged changes
1

What we changed

spotlessCheck no longer fails with "There were 0 lint error(s)" when the spotless-clean directory only holds stale copies of files that already match what is on disk. The lint exception is thrown only when there are actual lints.

What this work shows

  • Gradle tasks and plugins
  • Code formatting in the build
  • JUnit tests for a Gradle plugin
What was broken

The check failed on zero errors

The issue described that after gradle clean openApiGenerate spotlessApply a directory stays behind in build/spotless-clean, and the next spotlessCheck or build throws There were 0 lint error(s). getUncleanFiles skipped files that matched the disk, but SpotlessCheck still went into the lint branch and threw with an empty list.

How we fixed it

An exception only for real lints

The lint branch now runs only when the list of lints is not empty. Otherwise the task finishes without an error, since the files in spotless-clean are stale copies of what is already on disk. A new test, checkPassesWhenCleanFileMatchesDisk, covers this case, and the change has an entry in CHANGES.md.

#3189

Merged change 1

  1. #3189 Fix `spotlessCheck` failing with 0 lint errors on stale clean files Merged 20 November 2026

What it taught us

From a message about zero errors we traced the branch the code fell into when there were neither unformatted files nor lints. We close such a state with a test that recreates it in the plugin's working directory.

More about this technology: Java

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.