Menu

#848 False positive: UnnecessaryLocalBeforeReturn

New Tickets
duplicate
nobody
None
PMD
1-Blocker
Bug
2017-02-16
2009-03-08
No

Hello,

A local assignment before return should not be an error if that assignment is annotated.

Example:
public int getVisibleIndex(){
....@SuppressWarnings("unchecked")
....int index = ((Container<component>)this.getContainer()).indexOf(this.getVisibleComponent());
....return index;
}</component>

In this case the annotation on the assignment is required to avoid annotating the whole method for this particular statement. The local assignment before return is therefore required, and should not cause PMD to report an error.

Discussion

  • Andreas Dangel

    Andreas Dangel - 2017-02-16
    • status: open --> duplicate
    • Module: --> PMD
    • Milestone: --> New Tickets
    • Priority: 5 --> 1-Blocker
    • Type: --> Bug
    • Affects version: -->
    • Ruleset / Rule: -->
     

Log in to post a comment.

MongoDB Logo MongoDB