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

S128: FP when case contains a finally block.

    Details

    • Type: False-Positive
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: CFG, Rules
    • Labels:
      None

      Description

      S128 raises FP when a case contains a finally. In such situation, the case still contains an unconditional jump, but is not detected as such.

      Reproducer

        public void foo(int in) {
          switch (in) {
            case 1: // FP
              try {
                return 1;
              } finally {
              }
            case 12: // FP
              try {
                return new A(true);
              } catch (Exception e) {
                throw new RuntimeException("Wrapping", e);
              } finally {
                System.out.println("Finally");
              }
            default:
              return 99;
          }
        }
      

      In both case 1 and case 12, the case ends with an unconditional jump.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated: