Skip to content

fix(FormatExtension/Gradle): Fix step setup with toggleFence and targetExcludeContentPattern#2487

Merged
nedtwigg merged 3 commits intodiffplug:mainfrom
snazy:format-extension-target-content-exclude-pattern
May 21, 2025
Merged

fix(FormatExtension/Gradle): Fix step setup with toggleFence and targetExcludeContentPattern#2487
nedtwigg merged 3 commits intodiffplug:mainfrom
snazy:format-extension-target-content-exclude-pattern

Conversation

@snazy
Copy link
Contributor

@snazy snazy commented May 21, 2025

With a non-null toggleFence, com.diffplug.gradle.spotless.FormatExtension#setupTask creates a new List via List.of(). Also having a non-null targetExcludeContentPattern leads to an UnsupportedOperationException thrown by List.replaceAll, because List.of yields an immutable list.

The issue is reproducible via:

spotless {
  java {
    licenseHeader('// my-copyright')
    toggleOffOn() // adds the 'toggleFence'
    targetExcludeIfContentContains('excludeMe') // adds the 'targetExcludeContentPattern'
  }

Change includes (integeration) tests.

snazy added 2 commits May 21, 2025 12:27
…argetExcludeContentPattern`

With a non-null `toggleFence`, `com.diffplug.gradle.spotless.FormatExtension#setupTask` creates a new `List` via `List.of()`. Also having a non-null `targetExcludeContentPattern` leads to an `UnsupportedOperationException` thrown by `List.replaceAll`, because `List.of` yields an immutable list.

Change includes (integeration) tests.
@snazy
Copy link
Contributor Author

snazy commented May 21, 2025

Hm, is the spotlessCheck CI failure accurate? Mean, I can apply the formatting change 🤷
Ouch - I see the issue

@nedtwigg nedtwigg merged commit 281e12f into diffplug:main May 21, 2025
16 checks passed
@snazy snazy deleted the format-extension-target-content-exclude-pattern branch May 21, 2025 16:11
@snazy
Copy link
Contributor Author

snazy commented May 21, 2025

Thanks for the quick review + merge!
Really appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants