I have implemented a bunch of custom rules for SonarQube, deployed them to a SonarQube server, and activated them. I then connected my SonarLint in IntelliJ with that SonarQube server, and my custom rules were applied beautifully.
I then implemented more custom rules and deployed them as well. When I trigger the sonar checks with a mvn sonar:sonar command, the new rules are applied as expected. But when I analyze my code within SonarLint, they are not applied. The “Logs” tab of the SonarLint has an entry called “activeRules” which lists all rules which are applied. This list contains all the old custom rules, but not the new ones.
Obviously, the rules are cached somewhere. In former times, the SonarLint UI had a button called “update” (or something like that, I do not remember exactly). But this button is gone. How can I update that cache?
I created a new version of the custom rules as a jar file and deployed it to the SonarQube server. Then I configured SonarLint and switched on both check boxes “Analyses Logs” and “Verbose output” and restarted IntelliJ. After the start, I verified that the new version of the jar file with our custom rules was used in the cache you mentioned.
Then I wanted to apply a new rule. And here the logs showed something very amazing:
[2024-08-19T09:10:48.878] [SonarLint Server RPC request executor] DEBUG sonarlint - Rule Test-Automation:TA0031 is enabled on the server, but not available in SonarLint
“Test-Automation:TA0031” is the identifier of my new rule.
All my rules are part of the same jar file. And in that, I had configured in the pom:
<sonarLintSupported>true</sonarLintSupported>
So, I don’t understand why some (the old) rules are applied, and the new ones are not available to SonarLint
It was quite hidden, but eventually I found out what caused the issue: With verbose log switched on, I discovered a message that my custom rules require API version 10.4, whereas SonarLint can only work up to a certain 10.1 version.
So I changed my configuration in the pom to:
<pluginApiMinVersion>10.1</pluginApiMinVersion>
and all rules are applied now in SonarLint.
To be honest: 10.1 seems to me to be quite old. It would be great if SonarLint could deal with higher numbers.