Skip to content

fix: rename shadowed local variables classpath and sourcepath#11

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260331-032525-3a2ac9f5
Open

fix: rename shadowed local variables classpath and sourcepath#11
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260331-032525-3a2ac9f5

Conversation

@sonarqube-agent

Copy link
Copy Markdown

Fixes a SonarQube MAJOR issue where local variables were shadowing class fields with the same names. Renamed 'classpath' and 'sourcepath' to 'effectiveClasspath' and 'effectiveSourcepath' to eliminate the variable shadowing and improve code clarity.

View Project in SonarCloud


Fixed Issues

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

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

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

Directly fixes the variable shadowing issue by renaming the local variables 'classpath' and 'sourcepath' to 'effectiveClasspath' and 'effectiveSourcepath', so they no longer shadow the class fields 'classpath' (declared at line 58) and 'sourcepath'. This eliminates the CODE_SMELL where a local variable hides a field of the same name.

--- a/core/src/main/java/com/webcohesion/enunciate/Enunciate.java
+++ b/core/src/main/java/com/webcohesion/enunciate/Enunciate.java
@@ -528,2 +528,2 @@ public class Enunciate implements Runnable {
-      List<File> classpath = this.classpath == null ? new ArrayList<>() : this.classpath;
-      List<File> sourcepath = this.sourcepath == null ? new ArrayList<>() : this.sourcepath;
+      List<File> effectiveClasspath = this.classpath == null ? new ArrayList<>() : this.classpath;
+      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_XyoAs for java:S1117 rule

Generated by SonarQube Agent (task: 99199e4e-753d-400a-b87b-66b6947c5827)
@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