False positive for S2325 : "private" methods that don't access instance data should be "static"

271 views
Skip to first unread message

Dominique Jean-Prost

unread,
Mar 30, 2016, 12:05:08 PM3/30/16
to SonarQube
Hello,

I guess I have a found a false positive for S2325 with the following code.

public class Sonar {

    private int foo;

    private void toto(final int b) {
        new File(".").listFiles(new FileFilter() {

            public boolean accept(final File pathname) {
                System.out.println(Sonar.this.foo);
                return false;
            }

        });
    }

}

I get this warning : "private" methods that don't access instance data should be "static" : Make "toto" a "static" method.

But I can't make the toto method static there. 

Thanks.
dom




Michael Gumowski

unread,
Mar 31, 2016, 3:56:58 AM3/31/16
to Dominique Jean-Prost, SonarQube
Hey Dom,

Thanks a lot for your feedback as well as for the pretty useful reproducer!
Indeed, this a FP and the case is not well handled in the rule! JIRA ticket created: https://jira.sonarsource.com/browse/SONARJAVA-1620

Cheers,

Michael GUMOWSKI | SonarSource
Software Developer @ Language Team
http://sonarsource.com

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/7fd05b73-ec2d-40dc-a70b-970a01f4cb47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages