Repository navigation
SONARJAVA-7301 Rename local variable to avoid shadowing class field in MethodTreeImpl - #6487
Conversation
Fixed issues: - AaGp8UCtNZKwc-1vcC4E for java:S1117 rule Generated by SonarQube Agent (task: 394197e2-f2b6-42d9-ad1e-1eaa1a4d0e74)
Code Review ✅ Approved🟢 Low risk · Renaming the local variable and its references only clarifies intent; it leaves executable behavior and interfaces unchanged. Renames the local variable Verification Rules 1/1 met PRs 1 inspectedFunctional validation No results Rules 1 passed 2 not applicable
Broader impact PRs 1 inspectedCross-PR 1 PR inspected 0 open impacts
Auto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




Fixed a variable shadowing issue where a local variable named "symbol" in the overriddenSymbols() method was hiding a class field with the same name. The local variable has been renamed to "methodSymbol" to clarify intent and eliminate the shadowing, improving code maintainability and reducing potential confusion.
View Project in SonarCloud
Fixed Issues
java:S1117 - Rename "symbol" which hides the field declared at line 75. • MAJOR • View issue
Location:
java:java-frontend/src/main/java/org/sonar/java/model/declaration/MethodTreeImpl.java:300Why is this an issue?
Shadowing occurs when a local variable has the same name as a variable or a field in an outer scope.
What changed
Renames the local variable "symbol", which hid the class field of the same name, to "methodSymbol" and updates its immediate use in the overriddenSymbols() call. This removes the shadowing.