java:S1128 (Unnecessary imports should be removed) is not triggered on file that were not compiled

  • Operating system: Windows 11 / Linux

  • IDE: Using sonarlint-plugin-api and sonarlint-core in a custom project for Gerrit.

In my company, we have an app that retrieves all modified files in a Gerrit change and runs SonarLint on them to provide comments for each rule violation detected.

Recently, we decided to upgrade our versions of sonarlint-plugin-api and sonarlint-core from 7.0.0.37656 to 9.8.0.76914. Since this upgrade, some rule violations are no longer triggered, even though they appear on SonarQube.

When investigating this issue, I found this ticket: SONARJAVA-3777.

As I understand it, we now need to compile the code before analysis for certain checks to be triggered.

To test this, I checked the UselessImportCheckTest both before and after applying the changes mentioned in the ticket.

From my debugging, it appears that the jdt library relies on compiler problems to report the java:S1128 rule.

Without compilation:

With compilation:


Question:

In my case, I cannot compile the code beforehand. Is there any way to have the RuleKeys not triggered by compiler warnings, as they were before?

Thanks in advance! :blush:

Hi,

What flavor and version of SonarLint are you using?

 
Thx,
Ann