Menu

#1161 Confusing Ternary should skip else if statements (or have a property to do so)

PMD-5.1.0
closed
None
PMD
4-Minor
Feature-Request
5.0.5
2015-01-03
2014-01-05
Ulli Hafner
No

While I like the check for a statement like

if (!condition) {
} 
else {
}

I would like to suppress checks for statements like

if (!condition) {
} 
else if (otherCondition) {
}
else {
}

If I invert the condition in the first if, then the whole statement will be more complex since you need a block inside the first block.

It would be nice if either such statements would not be processed anymore (or if there would be a property that could be activated).

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-01-27
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,11 +1,14 @@
     While I like the check for a statement like 
    +
     ~~~~~
     if (!condition) {
     } 
     else {
     }
     ~~~~~
    +
     I would like to suppress checks for statements like
    +
     ~~~~~
     if (!condition) {
     } 
    @@ -14,6 +17,7 @@
     else {
     }
     ~~~~~
    +
     If I invert the condition in the first if, then the whole statement will be more complex since you need a block inside the first block. 
    
     It would be nice if either such statements would not be processed anymore (or if there would be a property that could be activated).
    
    • status: open --> in-progress
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.1.0
     
  • Andreas Dangel

    Andreas Dangel - 2014-01-27

    I've added a property "ignoreElseIf". It will be available with PMD 5.1 in February.

     
  • Andreas Dangel

    Andreas Dangel - 2014-01-27
    • status: in-progress --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.