Menu

#1198 ConfusingTernary does not ignore else if blocks even when property is set

PMD-5.1.2
closed
None
PMD
3-Major
Bug
5.1.1
2014-07-20
2014-05-09
No

PMD is set to ignore elseif blocks, but still flags these as a warning. This elseif block is nested inside another if / else, but this does not seem to affect the results of the check

Configuration setting:
<property name="ignoreElseIf" value="true"/>

Code:

if (noSave) {
    //continue on
} else {
    if (goBack == "Step") {
        //do logic
    } else if (currentStateID != -1 && selectedNextState != -2) {
        //do different logic
    } else {
        //more logic
    }
}

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-07-19
    • summary: PMD does not ignore else if blocks even when property is set --> ConfusingTernary does not ignore else if blocks even when property is set
     
  • Andreas Dangel

    Andreas Dangel - 2014-07-19
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -4,9 +4,11 @@
     <property name="ignoreElseIf" value="true" />
    
     Code:
    +
    +~~~~~
     if (noSave) {
    -//continue on
    -else {
    +    //continue on
    +} else {
         if (goBack == "Step") {
             //do logic
         } else if (currentStateID != -1 && selectedNextState != -2) {
    @@ -15,3 +17,4 @@
             //more logic
         }
     }
    +~~~~~
    
     
  • Andreas Dangel

    Andreas Dangel - 2014-07-19
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-Next
     
  • Andreas Dangel

    Andreas Dangel - 2014-07-19

    Will be fixed with the next release.

     

Log in to post a comment.