S2189 potential infinite loop not detected

(Alexandre B ) #1

Hi we currently used SonarQube 7.5 and we face a potential infinite loop not detected by sonar

In the snippet below, if the send null to the increase function in the “condition” param the script will be in infinite loop,

but the rule S2189 - [Do not use an empty infinite loop], didn’t see any problem here

can sonar be able to detect this ?

Thanks a lot Alex.

exemple snippet :

    public class InfiniteLoop {

public static void main(String[] args) {
	int start = 1;
	int limit = 100;
	String condition = null;
	increase(limit, condition, start);

static int increase(int limit, String condition, int start) {
	while (start < limit) {
		System.out.println("im in the loop");
		if (null != condition) {
			//do something wonderful with your condition
			start ++;
			System.out.println("here we are in infinite loop");
	return start;