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

S3516: inconsistent behavior for checked and unchecked exceptions

    Details

    • Type: False Negative
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Symbolic Execution
    • Labels:
      None

      Description

      S3516 will not report an issue when one method return the same value and can also raise a checked exception, while it does report an issue when the exception is unchecked.

      class FP {
        public boolean foo(int a) throws IOException { // No issue, FN? True negative?
          switch (a) {
            case 1:
              throw new IOException();
            case 2:
              return true;
            default:
              return true;
          }
        }
      }
      
      class FP2 {
        public boolean foo(int a) throws IllegalStateException { // One issue: FP? True Positive?
          switch (a) {
            case 1:
              throw new IllegalStateException();
            case 2:
              return true;
            default:
              return true;
          }
        }
      }
      

      We might want to clarify if this situation reflect a FP or a FN.

        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: