Repository navigation
[java] Fix #3124: Deprecate statementOrderMatters property of VariableCanBeInlined - #7065
Merged
UncleOwen merged 4 commits intoSep 13, 2026
Conversation
…ableCanBeInlined The property silently migrated into the replacement rule when UnnecessaryLocalBeforeReturn was deprecated (pmd#5847): setting it to false relaxes the rule under the assumption that the statements between the declaration and the return/throw have no side effects, which is unsafe and could introduce an application bug when following the suggestion. Mark the property as deprecated using DEPRECATED_RULE_PROPERTY_MARKER: configuring it now issues a warning when the ruleset is loaded, and the rule documentation displays a deprecated label. Behavior is unchanged while deprecated (the conservative default, statementOrderMatters=true, stays the default); the property will be removed later. Signed-off-by: 付典 <[email protected]>
Contributor
|
Compared to main: (comment created at 2026-09-13 18:35:18+00:00 for 5eb3435) |
Only make actually removing the property harder.
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.
AI disclosure: this change was prepared with AI coding agents, reviewed and revised line by line by me.
Describe the PR
statementOrderMatters=falserelaxesVariableCanBeInlinedto report any variable used solely in a return/throw statement, assuming the statements between the declaration and the return have no side effects. The assumption is unsafe: following the suggestion can introduce an application bug. This is what #3124 asks to remove.The property came from the deprecated
UnnecessaryLocalBeforeReturnrule: it was carried over whenVariableCanBeInlinedwas created in #5847 and was not discussed in that review.This PR marks it deprecated via
DEPRECATED_RULE_PROPERTY_MARKER(same mechanism asMethodNamingConventions):Behavior is unchanged: the default stays
statementOrderMatters=true. The property can be removed later.Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)Regression
No rule behavior change: the property default and the rule logic are untouched, only the property description changed — expect zero new violations in the regression tester. The four
statementOrderMatters=falsetest cases in the rule's test XML still pass and now log the deprecation warning on stderr, which is the intended new behavior.