Menu

#1484 [java] UnusedLocalVariable: false positive - parenthesis

PMD-5.3.8
closed
java (55)
PMD
3-Major
Bug
2016-06-25
2016-05-17
No

import java.util.ArrayList;
import java.util.List;

public class Test {

public static void main(String[] args) {
    List<String> list = new ArrayList<>();
    list.add("first");
    list.add("second");

    int notEmpty = 0;
    for (String string : list) {
            if (!string.isEmpty()) {
                notEmpty++;
            }
    }

    System.out.println(list.size() + " (" + (notEmpty) + " not empty)");
}

}

notEmpty is reported as UnusedLocalVariable. If I remove the parentheses arround notEmpty everything is OK.

Discussion

  • Andreas Dangel

    Andreas Dangel - 2016-05-21
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.3.8
     
  • Andreas Dangel

    Andreas Dangel - 2016-06-25
    • summary: UnusedLocalVariable - false positive - parenthesis --> [java] UnusedLocalVariable: false positive - parenthesis
    • Ruleset / Rule: --> java
     
  • Andreas Dangel

    Andreas Dangel - 2016-06-25
    • labels: --> java
     
  • Andreas Dangel

    Andreas Dangel - 2016-06-25
    • Ruleset / Rule: java -->
     

Log in to post a comment.