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

FP in S2184 when return is in another scope

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.9
    • Component/s: Rules
    • Labels:
      None

      Description

      In S2184, we check any return in the body of a function for misuse, while we should exclude ones in a nested lambda or class since they are in another scope.

      double compute() {
          long sum = List.of(1, 2, 3).stream().mapToLong(i -> {
              return i * i;
          }).sum();
          return sum;
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quentin.jaquier Quentin Jaquier
                Reporter:
                quentin.jaquier Quentin Jaquier
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: