Skip to content

Commit 860a7a8

Browse files
(Sonar) Fix "Unused local variables should be removed" (#342)
## Remediation This change fixes the following Sonar rule: "Unused local variables should be removed" (id = [java:S1481](https://rules.sonarsource.com/java/RSPEC-1481)) ## 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: ```diff catch (final UnsolvedSymbolException e) { - String errorMessage = "An unexpected exception happened"; LOG.error("Problem resolving type of : {}", expr, e); return false; } ``` <details> <summary>More reading</summary> * [https://rules.sonarsource.com/java/RSPEC-1481/](https://rules.sonarsource.com/java/RSPEC-1481/) </details> 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](https://docs.pixee.ai/) (codemod ID: [sonar:java/remove-unused-local-variable-s1481](https://docs.pixee.ai/codemods/java/sonar_java_remove-unused-local-variable-s1481)) ![](https://d1zaessa2hpsmj.cloudfront.net/pixel/v1/track?writeKey=2PI43jNm7atYvAuK7rJUz3Kcd6A&event=DRIP_PR%7Cpixee%2Fcodemodder-java%7C4ecfd2604c21a9055780d9c91ec0d5d7ef819086) <!--{"type":"DRIP","codemod":"sonar:java/remove-unused-local-variable-s1481"}--> Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
1 parent d827745 commit 860a7a8

File tree

1 file changed

+0
-1
lines changed
  • plugins/codemodder-plugin-maven/src/main/java/io/codemodder/plugins/maven/operator

1 file changed

+0
-1
lines changed

plugins/codemodder-plugin-maven/src/main/java/io/codemodder/plugins/maven/operator/FormatCommand.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ private void parseXmlAndCharset(POMDocument pomFile) throws XMLStreamException,
267267
boolean mustTrack = false;
268268
boolean hasPreamble = false;
269269
int elementStart = 0;
270-
int elementEnd = 0;
271270
List<XMLEvent> prevEvents = new ArrayList<>();
272271

273272
while (eventReader.hasNext()) {

0 commit comments

Comments
 (0)