SonarLint 9.2 does not highlight issue in Eclipse

Please provide

  • Operating system: Windows 10 Version 22H2 (OS Build 19045.3930)
  • SonarLint plugin version: 9.2.0.81471
  • Eclipse version: 2023-12 (4.30.0) - Build ID: 20231201-2043 (Eclipse IDE for Enterprise Java and Web Developers)
  • Programming language you’re coding in: Java
  • Is connected mode used: Connected to SonarQube Enterprise Edition - Version 9.9.2 (build 77730)

And a thorough description of the problem / question:
Previously I was using SonarLint 7.1.0.39158 in Eclipse 2022-06R and it was able to highlight the issue with blue squiggly line. See image below:
image

However, when using Eclipse 2023-12R with the latest SonarLint the blue squiggly line doesn’t highlight anymore. If the verbose log is required, please do contact me privately to share it.

Hey there.

That’s a funky rule key – wm6-guidelines:UnusedField. Do you know where this rule is coming from? Is it a custom rule being provided by a custom plugin?

Hi Colin, thanks for your response.

Yes, it is actually a custom rule created in SonarQube.

Created in SonarQube (using a rule template) or created for SonarQube (and installed using a custom plugin)?

One thing that might help is getting the verbose sonarlint logs when viewing a file you expect to raise this issue.

It was created for SonarQube (and installed using a custom plugin)

In the verbose logs I don’t see any errors…

JavaTestClasspath initialization (done) | time=6ms
Caching is enabled: false
Caching is enabled: false
Caching is enabled: false
Caching is enabled: false
Server-side caching is not enabled. The Java analyzer will not try to leverage data from a previous analysis.
Java "Main" source files AST scan
1 source file to be analyzed
Analysis time of [uri=file:/D:/dev/testProject/src/main/java/test/package/Test.java] (55ms)
1/1 source file has been analyzed
Java "Main" source files AST scan (done) | time=55ms
No "Test" source files to scan.
No "Generated" source files to scan.
'CobolSquidSensor' skipped because there is no related files in the current project
'Python Sensor' skipped because there is no related files in the current project
'RPG sensor' skipped because there is no related files in the current project
'Kotlin Sensor' skipped because there is no related files in the current project
'T-SQL Sensor' skipped because there is no related files in the current project
'PliSquidSensor' skipped because there is no related files in the current project
'Apex Sensor' skipped because there is no related files in the current project
'JavaScript/TypeScript analysis' skipped because there is no related files in the current project
'JavaScript inside YAML analysis' skipped because there is no related files in the current project
'JavaScript inside HTML analysis' skipped because there is no related files in the current project
Execute Sensor: CSS Rules
No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
'Ruby Sensor' skipped because there is no related files in the current project
'PL/SQL Sensor' skipped because there is no related files in the current project
'Scala Sensor' skipped because there is no related files in the current project
Execute Sensor: HTML
'XML Sensor' skipped because there is no related files in the current project
'PHP sensor' skipped because there is no related files in the current project
'Analyzer for "php.ini" files' skipped because there is no related files in the current project
Execute Sensor: TextAndSecretsSensor
1 source file to be analyzed
1/1 source file has been analyzed
'AbapSquidSensor' skipped because there is no related files in the current project
Found 0 issue(s)
Done in 227 ms

I saw that the requirement for SonarLint is JDK17. However, my project is required to be compiled to Java 11 and had my eclipse configured as follow:


I also saw this in the verbose log:

JavaClasspath initialization (done) | time=5ms
JavaTestClasspath initialization
Property 'sonar.java.jdkHome' resolved with:
[]
Property 'sonar.java.test.libraries' resolved with:
[D:\dev\testProject\target\classes,
C:\Program Files\Java\jdk-11.0.19\lib\jrt-fs.jar,

Could this affect the sonarlint compatibility?

I’ve also tested using the standard SonarQube rule such as java:S1444 rule. Which is working with my previous Eclipse 2022-06R + SonarLint 7.1.0.39158 (See image below)

As shown in image below, it doesn’t work with the latest Eclipse and SonarLint 9.2

Even the standard rule aren’t working, so the issue could be something else. Any idea on this?

Hi @Samuel_W,

thank you for reaching out to us. At first glance, it seems that SonarLint is picking up the file as a source and not a test file (based on the logs I can see from your screenshots). On the other hand, you mention the sonar.java.test.libraries from the logs.
I think I need the full verbose logs from you, in the best case when running the old and new installation, you can provide them to me via pm if you like.

Have you configured the Test file glob patterns in Preferences → SonarLint? And/or is the Java build path configured to contain test sources in Project properties → Java Build Path → Source?
Either configuration will ensure that on test code there will be only the test rules applied as most of the unit test code for example is not compliant with the normal Sonar rules.

Best,
Tobias

Hi @tobias.hahnen,

Thanks for your response.
Apologies, the example I provide above might be confusing and bad, it is not about verifying the test classes but issues when verifying the actual Java classes.

I’ve created a very simple Spring boot app containing the “SomeSampleClass” as seen in the image below:

Please also find herewith the required log files.
working_sonarlint_7.1.log (31.4 KB)
not_working_sonarlint_9.2.log (90.0 KB)

Hi @Samuel_W,

thank you very much for the logs. I tried to reproduce it, but it didn’t succeed: I was testing with the project not in connected mode and in connected mode to SQ 9.9 LTS (the one you are using).

I see your test project is bound to your SQ server, when not connected, do the issues show or are they not shown as well? I’m asking that because I want to clarify if the issue is because of configuration on SonarLint or on SonarQube side.

From the logs, I can see that you have a custom plug-in installed with additional rules and use your own quality profile for Java. With my freshly installed SQ 9.9 LTS instance, I have ca. 580 active Java rules available (visible from the verbose logs) when analyzing based on the default quality profile, I can see that you only have 311 active Java rules.
Can it be that your quality profile is configured to not have the rules that should be triggered on SomeClassSample enabled (I see java:S1104, java:S1118, java:S1444 and java:S2129)?

Based on your response I’ll try to get in touch with the language analyzer experts to check if it is an issue on the analyzer side (or changes made between the versions).

Best,
Tobias

Hi @tobias.hahnen,

Many thanks for your investigation, let’s focus on the java:S1444 rule to simplify the investigation.

I can see that you have a custom plug-in installed with additional rules and use your own quality profile for Java.

Yes, this is correct that we have additional rules and use our own quality profile.

I can see that you only have 311 active Java rules.

Yes, this is correct. Not all the default SQ rules are active in the custom quality profile. Only some of it + our custom rules. However, the java:S1444 rule is currently active in my custom quality profile.

I see your test project is bound to your SQ server, when not connected, do the issues show or are they not shown as well?

When not connected to SQ server, the issue does show up in the latest SonarLint 9.2. Attached image below:

Hi @Samuel_W,

thank you for your quick response. Just to be sure: The quality profile that is downloaded (and blurred by you in the logs), when you go to SonarQube instance → Quality ProfilesJava, and there open your custom quality profile → click on the XXX active rules: Can you find it there as well?

I’m asking as I’m forwarding this thread to the specialists for Java / SonarQube to help you with it. From what I can see there is no issue with the SonarLint side of the connected mode and my knowledge sadly ends here :frowning_face:

Please be patient as it can take a bit for them to get familiar with this case.
If you encounter anything in the meantime, just reply to this thread as usual and someone will have a look!

Best,
Tobias

Hi @tobias.hahnen ,

when you go to SonarQube instance → Quality ProfilesJava , and there open your custom quality profile → click on the XXX active rules : Can you find it there as well?

Yup, I can see the rules active there in the list.

From what I can see there is no issue with the SonarLint side of the connected mode

Yeah, I thought the same as well. It could either be misconfiguration or something from SonarQube server. My knowledge on how our SQ server is being setup is limited as well, do let me know if anything your team would like to have from our SQ server.

Many thanks for the help!

Hi there,

Any updates on this topic?
Thanks

Hi @Samuel_W,

it was discussed internally and is currently forwarded to the specialists to have a look into it and to answer.
Thank you for your patience!

Best,
Tobias

Hi @Samuel_W

Thank you very much for this report and apologies for the inconveniences you are experiencing.

Could you analyze this test project with any Sonar scanner and report back whether the issue is reported/visible in SonarQube UI? If so, what is the status of this issue?

Also, to narrow down the source of the issue you are having, it would be great if you could let SonarLint connect the test project in your IDE to brand new test project in SQ that uses just default quality profile and see if SonarLint still doesn’t highlight this issue.