[java] RSPEC-2189 should consider do-while loop

Hi, I think we should consider make RSPEC-2189 detect do-while loop. Currently, SonarQube can only recognize for and while loop. Please review the sample below (a false negative):

public class Impl {
  public void foo() {
    int j = 0;
    do {
      j++;
    } while(true);  // should report a warning here
  }
}

However, the following example can be detected:

public class Impl {
  public void foo() {
    int j = 0;
    while(true) {
      j++;    // a warning reported here
    }
  }
}

Besides, my version:

  • sonarqube-9.2.2.50622
  • sonar-scanner-cli-4.6.2.2472-linux

Hello @Belle

Thanks for taking the time to report this false negative, it makes sense to report the first case aswell. Ticket created: SONARJAVA-4108.

Best,
Quentin

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.