spotbugs / spotbugs

SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.

Home Page:https://spotbugs.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A false negative about the rule IL_INFINITE_LOOP

Jane-PL-256 opened this issue · comments

commented

This rule is used to detect infinite loop. SpotBugs can recognize the issue in the following code example:

public void test4(boolean b) {
  while (b = true) {  // can report a warning
    System.out.println("Wow");
  } 
}

But the following example cannot be detected, these two cases are equivalent.

public void test4(boolean b) {
  do {
    System.out.println("Wow");
  } while (b = true); // should report a warning here
}

Version: LATEST