#1075 False Positive: LocalVariableCouldBeFinal

Eclipse-Plugin
closed
None
Eclipse
3-Major
Bug
2014-03-27
2013-03-11
john
No

the following code block triggers a false positive in Eclipse (not from maven) for LocalVariableCouldBeFinal. My guess is that it's not properly detecting a Java 5+ environment. I didn't see anywhere in the plugin to configure java5+ support like there is in the maven plugin.

 for (final Object user : Objects)

Discussion

  • Bo98

    Bo98 - 2013-05-02

    Same here on Java 6

    public void test(){
            final File[] files = dir.listFiles();
            if (files == null) {
                return;
            }
            for (final File f : files) {
                f.delete();
            }
    }
    

    This returns LocalVariableCouldBeFinal on the

    for (final File f : files)
    

    and a UR anomaly for variable f.

     
  • Andreas Dangel

    Andreas Dangel - 2013-05-02

    I think this is because the eclipse plugin doesn't use the latest pmd version.
    I hope to release a new pmd-eclipse-plugin soon (means in the next 2 weeks).

     
    • Bo98

      Bo98 - 2013-05-02

      Alright, good to hear.

       
  • Andreas Dangel

    Andreas Dangel - 2013-05-10
    • status: open --> closed
    • assigned_to: Andreas Dangel
     
  • Andreas Dangel

    Andreas Dangel - 2013-05-10

    This is fixed now with the version:

    PMD for Eclipse 4.0.0.v20130510-1000
    It is available via the update site: http://pmd.sourceforge.net/eclipse/

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks