Repository navigation
Conversation
…diffplug#2859) Lints that FenceStep.preserveWithin (toggleOffOn) forwards from its inner steps were reported under the fence step name "toggle", so messages named the wrong step and lint suppressions by the real step name (e.g. forbidWildcardImports) did not match. FenceStep now records the inner step name on each forwarded lint (Lint#withStepName, innermost step wins). LintState reports lints under that name, and LintSuppression matches either the inner step name or the fence step name, so existing "toggle" suppressions keep working. Tests for lib, testlib, plugin-maven and plugin-gradle are included; they have not been run yet (Maven Central rate limiting in the build environment). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MTr23yLJcRtZewXQd4rbQS
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MTr23yLJcRtZewXQd4rbQS
Pankraz76
marked this pull request as ready for review
November 23, 2026 16:01
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2859. Follow-up to #2962.
Problem
#2962 made
toggleOffOnforward lints from its inner steps, but they are attributed to the fence steptoggleinstead of the step that produced them:Because of that, a suppression for the real step does not match while
toggleOffOnis enabled:<lintSuppression><step>forbidWildcardImports</step></lintSuppression>suppressLintsFor { step = 'forbidWildcardImports' }Only
toggleor*work.After this change:
Change
Lintgets an optional step name:getStepName()andwithStepName(String).withStepNamereturns a copy and keeps an existing name, so for nested fences the innermost step wins. The field is not part ofequals/hashCode/toString, andserialVersionUIDis unchanged, so lint files Gradle has already written still deserialize.FenceStep.preserveWithinsets the inner step's name on each lint it forwards. The fence's ownfenceRemovedlint is still reported as the fence step.LintState.getLintsByStepandasStringreport each lint under that step name when it is set, and otherwise under the formatter step. All Maven (check/apply/report) and Gradle messages go through these two methods.LintSuppressionmatches a step against the inner step name or the formatter step name, so existingtogglesuppressions keep working.Why this approach
I started with the simplest version: the change stays inside
FenceStepand the two places that resolve a lint's step name, it adds only one optional field toLint, and nothing changes for builds without a fence.Alternatives I considered:
Lintalone and haveLintStatelook insideFenceStep's inner steps. That avoids touchingLint, but it ties core lint handling toFenceStepinternals: more code and more coupling for the same result.shortCode. That would break suppressions byshortCode.If you'd prefer a different approach, tell me in review and I'll change it.
Tests
LintTest(step name copy, innermost wins, not part of identity, serialization round trip),LintStateTest(grouping and output by step name),LintSuppressionTest(suppression by inner and by fence step name)FenceStepTest. The expectation changes fromtoggle(...)toforbidWildcardImports(...), plus nested fences and suppression end to endToggleOffOnTest. Covers the reported step name, the same output without the toggle, suppression byforbidWildcardImportsand bytoggle, and the issue's own config (toggleOffOn+removeUnusedImports+forbidWildcardImportswithspotless:apply)ToggleOffOnTest, with the config cache on and off. Covers the reported step name and both suppressionsVerified locally:
mainas expected (Step 'toggle' …); the backward-compatibility tests (suppression bytoggle, output without toggle) pass onmain.:lib:test105/105, testlibFenceStepTest7/7, plugin-mavenToggleOffOnTest7/7 +LintSuppressionTest5/5, plugin-gradleToggleOffOnTest10/10 (with and without configuration cache).spotlessCheckand:lib:spotbugsMainpass.Changelog entries are in
CHANGES.md,plugin-maven/CHANGES.mdandplugin-gradle/CHANGES.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01MTr23yLJcRtZewXQd4rbQS