nahsra / WebGoat_12_23

Other
0 stars 2 forks source link

(Sonar) Fixed finding: "String literals should not be duplicated" #37

Closed pixeebot[bot] closed 1 month ago

pixeebot[bot] commented 1 month ago

Remediation

This change fixes "String literals should not be duplicated" (id = java:S1192) identified by Sonar.

Details

This change defines a constant for duplicated literal expression values, simplifying the refactoring process and mitigating the risk of overlooking any values during updates.

Our changes look something like this:


+    private static final String EXCEPTION_AT = "Exception at";

-       LOG.error("Exception at", ex)
+       builder.add(EXCEPTION_AT)  

-       LOG.error("Exception at", ex)
+       builder.add(EXCEPTION_AT)  

-       LOG.error("Exception at", ex)
+       builder.add(EXCEPTION_AT)  
More reading * [https://rules.sonarsource.com/java/RSPEC-1192/](https://rules.sonarsource.com/java/RSPEC-1192/)

I have additional improvements ready for this repo! If you want to see them, leave the comment:

@pixeebot next

... and I will open a new PR right away!

đŸ§šđŸ€– Powered by Pixeebot

Feedback | Community | Docs | Codemod ID: sonar:java/define-constant-for-duplicate-literal-s1192

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud