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

FP on S2589/S2583 when loop needs 3 visits to cover all branches

    Details

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

      Description

      Following is example of loop which needs more than 2 visits to avoid FP on S2589

      abstract class LoopNeeds3Visit {
      
         void m(boolean b1, boolean b2, boolean b3) {
          b1 = false;
          b2 = false;
          b3 = false;
          for (int i = 0; i < 10; i++) {
            if (cond()) {
              b1 = true;
            } else if (cond()) {
              b2 = true;
            } else if (cond()) {
              b3 = true;
            }
          }
          if (!b1 || !b2) {
            return;
          }
          if (b3) { // FP 
      
          }
        }
      
        abstract boolean cond();
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                tibor.blenessy Tibor Blenessy
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: