Skip to content

Conversation

@pixeebot
Copy link
Contributor

@pixeebot pixeebot bot commented Apr 9, 2024

Remediation

This change fixes the following Sonar rule: "Unused local variables should be removed" (id = java:S1481)

Details

This change removes unused variables. Unused variables make the code harder to read, which will lead to confusion and bugs. We only remove variables that have no state-changing effects.

Our changes look something like this:

     catch (final UnsolvedSymbolException e) {
-      String errorMessage = "An unexpected exception happened";
       LOG.error("Problem resolving type of : {}", expr, e);
       return false;
     }
More reading

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 (codemod ID: sonar:java/remove-unused-local-variable-s1481)

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 9, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Contributor

@nahsra nahsra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx!

@nahsra nahsra merged commit 860a7a8 into main Apr 9, 2024
@nahsra nahsra deleted the pixeebot/drip-2024-04-09-sonar-java/remove-unused-local-variable-s1481 branch April 9, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant