Menu

#550 False +: MissingBreakInSwitch

PMD-5.2.1
closed
None
PMD
1-Blocker
Bug
2014-11-03
2006-07-30
rei3ner
No

in

    switch (sign) {
    case  1:
        return "+";
    case  0:
        return "0";
    case -1:
        return "-";
    default:
        throw new IllegalArgumentException();
    }

obviously one does not need a break.

Suggestion:
require either break or return.

Discussion

  • rei3ner

    rei3ner - 2006-07-30

    Logged In: YES
    user_id=1316370

    also a throws substitutes for a break.

    another problem:
    each fall-through should be reported seperately
    such that it can be avoided using NOPMD individually.

     
  • rei3ner

    rei3ner - 2006-07-30

    Logged In: YES
    user_id=1316370

    still another substitution for a break: a continue-statement
    refering to an enclosing loop.

     
  • Tom Copeland

    Tom Copeland - 2006-08-09

    Logged In: YES
    user_id=5159

    Hm, this is an interesting one... it only applies if all
    cases have return stmts. Kind of a data flow analysis
    problem...

    Tom

     
  • Nick Radov

    Nick Radov - 2007-08-23

    Logged In: YES
    user_id=348202
    Originator: NO

    Was anyone able to make progress on this bug? I am getting a number of false positives from it.

     
  • Mark Anderson

    Mark Anderson - 2014-09-09

    I'm seeing false positives with this issue in 5.1.3. Any updates on whether it can be fixed?

     
  • Andreas Dangel

    Andreas Dangel - 2014-09-28
    • Module: --> PMD
    • Milestone: --> PMD-next
    • Priority: 5 --> 1-Blocker
    • Type: --> Bug
    • Affects version: -->
     
  • Andreas Dangel

    Andreas Dangel - 2014-10-18
    • assigned_to: Andreas Dangel
     
  • Andreas Dangel

    Andreas Dangel - 2014-11-03
    • status: open --> closed
     

Log in to post a comment.