Menu

#1315 New Rule: Avoid reusing of a local variable between switch cases

New Tickets
open
nobody
None
PMD
3-Major
Feature-Request
2015-02-20
2015-02-20
No

Irrespective of this bug it's worth considering the reuse of a local variable in another case block questionable and add a corresponding PMD rule.

See [#1305]

Example code:

int switchvar = 0;
switch (switchvar) {
    case 1:
        boolean localvar = false;
        break;
    case 2:
        localvar = true;
        break;
    case 3:
        if (localvar) {
            //
        }
}

Related

Issues: #1305

Discussion


Log in to post a comment.