Coding

Spotless – automated source code formatting

Spotless is a code formatting framework that helps developers maintain consistent source code across projects containing one or more programming languages. Rather than enforcing a single formatting style, it integrates existing formatting engines into build workflows. Kotlin projects can use ktlint or ktfmt, while Java projects can use google-java-format and other supported formatters. It also handles numerous additional languages and text-based formats.

Spotless integrates with Gradle and Maven, allowing developers to define formatting rules alongside the rest of their build configuration. Projects can check whether files comply with the configured format or automatically apply corrections. Formatting violations can cause automated builds to fail, preventing inconsistently formatted changes from entering a codebase. Its support for incremental processing, selective enforcement and Git-based workflows makes it particularly useful when introducing formatting rules to established projects containing substantial amounts of existing source code.

This is free and open source software.

Key Features

  • Supports Kotlin, Java, Groovy, Scala, JavaScript, TypeScript, Python, C, C++, CSS, HTML, Markdown, SQL, YAML and many other languages and formats.
  • Integrates with Gradle and Maven build systems, with additional SBT integration.
  • Uses ktlint and ktfmt as formatting engines for Kotlin source code.
  • Provides separate tasks for checking formatting compliance and applying corrections.
  • Supports configurable formatting steps that can be combined in a defined sequence.
  • Offers built-in formatting operations for indentation, trailing whitespace and final newlines.
  • Automatically inserts and updates copyright or licence headers in source files.
  • Supports regular-expression replacements and other text transformations.
  • Allows formatting to be temporarily disabled within selected source sections using special comments.
  • Provides Git ratcheting to enforce formatting only on files changed relative to a selected Git reference.
  • Supports configurable line endings, including integration with Git line-ending settings.
  • Checks that formatting transformations are idempotent to detect unstable formatting behaviour.
  • Includes safeguards for character encoding mismatches.
  • Supports incremental formatting checks and Gradle build caching.
  • Can integrate formatting checks with continuous integration pipelines.

Website: github.com/diffplug/spotless
Support:
Developer: DiffPlug
License: Apache License 2.0

Spotless is written in Java. Learn Java with our recommended free books and free tutorials.


Related Software

Kotlin Code Formatters
ktlintKotlin linter with built-in formatter
SpotlessKeeps codebases pristine with automated formatting checks
ktfmtPretty-prints (formats) Kotlin code
ktlint-gradleRuns ktlint from Gradle to enforce Kotlin style rules
Kotlinter GradlePlugin for linting and formatting
ktlint-gradle-pluginBrings Kotlin linting and formatting checks into Gradle projects
ktfmt-gradleAdds ktfmt formatting to Gradle builds with minimal fuss.
Kotlin FormatterFormats Kotlin source with a simple, consistent command-line tool

Read our verdict in the software roundup.


Best Free and Open Source Software LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.

We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more.

Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion.

Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted