Skip to content

fix: rename local variable to avoid shadowing sourcepath field - #12

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260331-032518-5833b4a7
Open

sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260331-032518-5833b4a7

Conversation

@sonarqube-agent

Copy link
Copy Markdown

This PR resolves a SonarQube MAJOR issue where a local variable named 'sourcepath' was shadowing the class field of the same name. The local variable at line 529 has been renamed to 'effectiveSourcepath' to eliminate the shadowing, improving code clarity and preventing potential confusion between the local variable and the class field.

View Project in SonarCloud


Fixed Issues

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

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

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 sourcepath at line 529 was shadowing the class field sourcepath declared at line 59. By renaming the local variable from sourcepath to effectiveSourcepath, the shadowing is eliminated, making the code clearer and avoiding potential confusion between the local variable and the class field.

--- a/core/src/main/java/com/webcohesion/enunciate/Enunciate.java
+++ b/core/src/main/java/com/webcohesion/enunciate/Enunciate.java
@@ -529,1 +529,1 @@ public class Enunciate implements Runnable {
-      List<File> sourcepath = this.sourcepath == null ? new ArrayList<>() : this.sourcepath;
+      List<File> effectiveSourcepath = this.sourcepath == null ? new ArrayList<>() : this.sourcepath;

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


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZZmtiWq2HDYqP_XyoAt for java:S1117 rule

Generated by SonarQube Agent (task: 31eb4d3c-5ff7-4b17-a918-ec223abd76d0)
@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