Skip to content

fix: define BEGIN_ATTRIBUTE constant to eliminate string duplication#150

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260530-050213-3d04da04
Open

fix: define BEGIN_ATTRIBUTE constant to eliminate string duplication#150
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260530-050213-3d04da04

Conversation

@sonarqube-agent
Copy link
Copy Markdown

This PR was automatically created by the Remediation Agent's Scheduled backlog remediation feature.

Resolves a critical SonarQube issue by extracting the duplicated string literal "begin" into a constant. This improves code maintainability and reduces the risk of inconsistencies if the value needs to be updated in the future.

View Project in SonarCloud


Fixed Issues

java:S1192 - Define a constant instead of duplicating this literal "begin" 3 times. • CRITICALView issue

Location: sonar-ruby-plugin/src/main/java/org/sonarsource/ruby/converter/RubyVisitor.java:163

Why is this an issue?

Duplicated string literals make the process of refactoring complex and error-prone, as any change would need to be propagated on all occurrences.

What changed

Defines the constant BEGIN_ATTRIBUTE with value "begin" to replace the duplicated string literal "begin" that appears 3 times in the file. This constant declaration enables the other hunks to reference a single constant instead of repeating the literal string.

--- a/sonar-ruby-plugin/src/main/java/org/sonarsource/ruby/converter/RubyVisitor.java
+++ b/sonar-ruby-plugin/src/main/java/org/sonarsource/ruby/converter/RubyVisitor.java
@@ -96,0 +97,1 @@ public class RubyVisitor {
+  private static final String BEGIN_ATTRIBUTE = "begin";

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


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZl5MuC8GyUqE6OUiTjn for java:S1192 rule

Generated by SonarQube Agent (task: d317bef7-fe78-4133-8c6b-7171939e11aa)
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