Rule S2095 is not triggering in Sonarlint, but appears in SonarQube

Hi,

My issue is this rule S2095 is not triggering in Sonarlint, but appears in SonarQube.

  • Operating system: Windows
  • SonarLint plugin version: 7.4
  • Is connected mode used: No (also not possible to connect due to restrictions)

Here’s a minimal example that reproduced the issue in Sonarlint 7.4 for Eclipse :

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;

public class TestSonarS2095 {

	void test(String document) {
		try {
			PrintWriter prw = new PrintWriter(new File("temp.xml"));
			prw.println(document);
			prw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Thanks & regards,
Nicolas.

Hello Nicolas,

What version of SonarQube are you using ?

Since you are not using connected mode, analysis might have different outcomes. The Java analyzer could be different on SonarQube than the one embedded into SonarLint

1 Like

Hello Damien,

I’m using SonarQube Community Edition Version 9.3 (build 51899).

If both SonarQube and Sonarlint are based on the same core engine referred to as the “Java analyzer”, could this be due to some regression on the “Java analyzer” ?

Thanks & regards,
Nicolas.

Hello Nicolas,

I did some more testing and I am not able to have this issue raised on SonarQube, even on older versions (I tried up to 7.8). So it does not seem to be caused by a different analyzer version. Does the code snippet you shared correspond exactly to the one analyzed on SonarQube ?