Skip to content

fix: rename local variable to prevent shadowing of class field#10

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260331-032517-42e3d7a8
Open

fix: rename local variable to prevent shadowing of class field#10
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260331-032517-42e3d7a8

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Resolved a SonarQube MAJOR issue where a local variable named 'sourceFiles' was shadowing a class field of the same name. Renamed the local variable to 'sourceFileURLs' to eliminate the shadowing and provide a more descriptive name that better reflects its Set type, improving code clarity and preventing potential bugs from accidental field reference confusion.

View Project in SonarCloud


Fixed Issues

java:S1117 - Rename "sourceFiles" which hides the field declared at line 54. • MAJORView issue

Location: core/src/main/java/com/webcohesion/enunciate/Enunciate.java:588

Why 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

This is the primary fix for the variable shadowing issue. The local variable sourceFiles at line 588 was shadowing the class field sourceFiles declared at line 54. By renaming the local variable from sourceFiles to sourceFileURLs, the shadowing is eliminated, giving the local variable a unique and more descriptive name that also better reflects its type (Set<URL>).

--- a/core/src/main/java/com/webcohesion/enunciate/Enunciate.java
+++ b/core/src/main/java/com/webcohesion/enunciate/Enunciate.java
@@ -588,1 +588,1 @@ public class Enunciate implements Runnable {
-      Set<URL> sourceFiles = getSourceFileURLs();
+      Set<URL> sourceFileURLs = getSourceFileURLs();

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZZmtiWq2HDYqP_XyoAu for java:S1117 rule

Generated by SonarQube Agent (task: 0e7917ba-1428-45e9-91f6-7edf0e726bad)
@sonarqubecloud
Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant