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

FP in S1854 for effective-final assignment of variables used in a lambda

    Details

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

      Description

      In SONARJAVA-3281, we already solved when S1854 was reporting FPs when a final variable was used in a lambda and the bytecode was incomplete.
      The rule is still reporting an issue in a similar situation when an effectively final variable is assigned and then used in a unknown lambda.

        void fpWithAssignment(boolean cond) {
          List<String> myList;
          if (cond) {
            myList = List.of("a", "b"); // FP here
          } else {
            myList = List.of("c", "d"); // FP here
          }
          new Unknown(str -> unknown(str, myList));
        }
      

      We should not report an issue here.

        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: