You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds null checks and integer comparisons across several check implementations to resolve issues with the isRValue null guard and TreeSorter comparisons.
📄 java-checks/src/main/java/org/sonar/java/checks/unused/UnusedLocalVariableCheck.java:111-122📄 java-checks/src/main/java/org/sonar/java/checks/unused/UnusedLocalVariableCheck.java:103-105
In the old code parent.parent() was only evaluated when parent.is(INCREMENT_KINDS) was true (short-circuit &&), so a non-increment parent always yielded true (identifier counted as a read). The rewrite hoists the null check out of the conjunction, so grandParent == null now returns false for any parent kind, and parent == null also returns false; because isUnused uses noneMatch(isRValue), false means "this usage is not a read", i.e. the fallback for an unknown/detached tree now pushes the check toward reporting an unused variable (and offering a quick fix that deletes the declaration) instead of staying silent. Keep the guard inside the increment branch and default the unknown cases to true.
✅ Quality: JavaQuickFix TreeSorter: only last of four comparisons migrated
📄 java-frontend/src/main/java/org/sonar/java/reporting/JavaQuickFix.java:103-109
The PR replaces the subtraction in the final return of TreeSorter.compare with Integer.compare, but the three preceding comparisons in the same method (startLine, startCharacter, endLine) still compute their ordering via subtraction, leaving the mechanical change half applied in a single method. Convert them all so the comparator is consistent (and uniformly overflow-safe).
Options
Auto-apply is off → Gitar will not commit updates to this branch. Display: compact → Showing less information.
Comment with these commands to change the behavior for this request:
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
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.
Summary by Gitar
UnusedLocalVariableCheckandMathOnFloatCheckInteger.compareto prevent overflow issuesThis will update automatically on new commits.