From 722875365bee458028296ea058d27b0c244c4841 Mon Sep 17 00:00:00 2001 From: Mirko Alicastro Date: Sun, 17 May 2026 16:00:43 +0200 Subject: [PATCH 1/2] Avoids recomputing LineEnding.toUnix in Formatter step loop --- lib/src/main/java/com/diffplug/spotless/Formatter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/main/java/com/diffplug/spotless/Formatter.java b/lib/src/main/java/com/diffplug/spotless/Formatter.java index 26f4f61238..71eba72204 100644 --- a/lib/src/main/java/com/diffplug/spotless/Formatter.java +++ b/lib/src/main/java/com/diffplug/spotless/Formatter.java @@ -182,7 +182,7 @@ String computeWithLint(String unix, File file, ValuePerStep exception storeForStep = LintState.formatStepCausedNoChange(); } else { storeForStep = null; - unix = LineEnding.toUnix(formatted); + unix = clean; } } } catch (Throwable e) { From 763468cf202c791fa8b0eab291d6b31b821a77ce Mon Sep 17 00:00:00 2001 From: Mirko Alicastro Date: Sun, 17 May 2026 16:11:56 +0200 Subject: [PATCH 2/2] Updates changelog --- CHANGES.md | 2 ++ plugin-gradle/CHANGES.md | 2 ++ plugin-maven/CHANGES.md | 2 ++ 3 files changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index d2e987fdfd..29485e1583 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### Fixed - `LicenseHeaderStep` in `SET_FROM_GIT` year mode no longer invokes `git log` through `bash -c` / `cmd /c`, eliminating a shell-injection vector when processing repositories that contain files whose names include shell metacharacters. +### Changes +- `Formatter` no longer recomputes line-ending normalization (`LineEnding.toUnix`) a second time for every formatter step that changes content, removing redundant O(n) work from the core formatting loop. ([#2934](https://github.com/diffplug/spotless/pull/2934)) ## [4.6.0] - 2026-05-14 ### Added diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 7cd19d2b6c..6fad800186 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -5,6 +5,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### Fixed - `licenseHeader` with `setLicenseHeaderYearsFromGitHistory()` no longer runs `git log` through a shell, eliminating a shell-injection vector when formatting files whose names contain shell metacharacters. +### Changes +- Improved formatting performance by eliminating redundant per-step line-ending normalization in the core formatter loop. ([#2934](https://github.com/diffplug/spotless/pull/2934)) ## [8.5.0] - 2026-05-14 ### Added diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index cc66003859..1b2fd500d1 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -6,6 +6,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Fixed - `` with `SET_FROM_GIT` no longer runs `git log` through a shell, eliminating a shell-injection vector when formatting files whose names contain shell metacharacters. - Bump transitive `plexus-utils` `4.0.2` -> `4.0.3` to address [CVE-2025-67030](https://github.com/advisories/GHSA-6fmv-xxpf-w3cw). ([#2919](https://github.com/diffplug/spotless/issues/2919)) +### Changes +- Improved formatting performance by eliminating redundant per-step line-ending normalization in the core formatter loop. ([#2934](https://github.com/diffplug/spotless/pull/2934)) ## [3.5.0] - 2026-05-14 ### Added