public static void main(String args[]) throws IOException, InterruptedException, AWTException, IllegalMonitorStateException
{
Scanner sc = new Scanner(System.in);
TicTacToe ge = null;
//ge.clearScreen();
System.out.println("Do You Want To Continue Then Press Y If No The Press Any Key");
char yes = sc.next().charAt(0);
if(yes == 'Y' || yes == 'y')
{
//TimeUnit.SECONDS.wait(10);
//ge.clearScreen();
//Thread.sleep(4000);
ge.game();
}
}
Scanner sc = new Scanner(System.in); should trigger a violation of S1943.
Thanks for your message. Could you please clarify which Java version you’re using?
Starting from Java 18 this rule doesn’t really make sense as the default charset was changed. You can check it here
Java Analyzer should be able to support versions 5 to 18.
That’s strange that it’s happening on Java 11. The rule should report an issue if you’re using Java 11.
Could you please set the version in SonarLint directly through sonar.java.source property? Set it to 18 (there should be no issue) and then set it to any other value like 11 or 17. The issue should appear then. After this, please, get back to me with the results.
Most likely is that your java version is not set correctly.
Thanks, @aman, Yes, looks like this is the right place.
Have you re-run the analysis after changing the version? You can also try re-starting the IDE.
A few more questions:
Do you see this issue when analyzing the whole project?
Can you reproduce it in SonarQube or SonarCloud?
Have you build the project?
I tried it with SonarQube, and it did not detect too. However, I found out why it is not being detected. S1943 is deactivated in the default quality profile. If I create another quality profile with S1943 activated, the violation is detected.