Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-591

FP on Anonymous class should be lambda : Apply only on SAM interfaces

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 3.12
    • Component/s: Rules
    • Labels:
      None

      Description

      source : http://stackoverflow.com/questions/24365440/sonar-anonymous-inner-classes-containing-only-one-method-should-become-lambdas

      The types on which this rule applies should be restricted to Single Abstract Method interfaces :

      public abstract class Main {
      
          public abstract void myMethod();
      
          public static void main(String[] args) {
              Main main = new Main() {
      
                  @Override
                  public void myMethod() {
                      // TODO Auto-generated method stub
      
                  }
              };
              main.myMethod();
          }
      }
      

      So this code would not raise an issue as Main is not a SAM interface.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                nicolas.peru Nicolas Peru
                Reporter:
                benzonico OLD - Nicolas Peru
              • Votes:
                6 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: