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

Improve rule S1612 to replace instanceof lambda with method reference

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.13
    • Component/s: Rules
    • Labels:
      None

      Description

      Noncompliant Code Example

      list.stream()
        .filter(a -> a instanceof B)  // Noncompliant
        .collect(Collectors.toList())
      
      

      Compliant Solution

      list.stream()
        .filter(B.class::isInstance)  // Compliant
        .collect(Collectors.toList())
      
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              margarita.nedzelska Margarita Nedzelska
              Reporter:
              margarita.nedzelska Margarita Nedzelska
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: