False positive in squid:S1604 (Anonymous inner classes containing only one method should become lambdas)

88 views
Skip to first unread message

mabbas

unread,
Mar 6, 2018, 8:54:15 AM3/6/18
to SonarQube
Hello,

I think the Rule squid:S1604 should not raise an issue for the following example:

public class S1604Test {

   
public static void main(String[] args) {

       
new S1604() { // An Issue squid:S1604 is raised by Sonar here:
                     
// Make this anonymous inner class a lambda            
           
@Override
           
public void m1(String s) {
               
// do Nothing
           
}

       
};

   
}

   
public interface S1604 {

       
default void m1(String s) {}

       
default void m2(String s) {}

       
default void m3(String s) {}

   
}

}

As you can see, the interface contains only default methods so a lambda can't be used.

I am using the version 5.1.1 of SonarJava and the version 7.0 of SonarQube

Regards;

Michael Gumowski

unread,
Mar 6, 2018, 9:00:41 AM3/6/18
to mabbas, SonarQube
Hello,

Thanks a lot for your feedback.
This issue has already reported recently, and will be fixed by the following ticket: SONARJAVA-2654

Cheers,
Michael

--
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/e22d7464-bb2b-4aee-861a-229fb10ef6ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Michael Gumowski | SonarSource
Software Developer, Language Team
https://www.sonarsource.com

mabbas

unread,
Mar 6, 2018, 10:07:44 AM3/6/18
to SonarQube
Hello Michael and thank you for you answer and for the link.

Cheers,
Reply all
Reply to author
Forward
0 new messages