Java custom rules executes via SonarLint , ONLY after Jenkins build execution( via. SonarQube)

Please provide

  • Operating system: Windows Server 2022
  • SonarLint plugin version:
  • Intellij IDEA version : 2022.3.3
  • Programming language you’re coding in: Java
  • Is connected mode used: Yes
    • Connected to SonarCloud or SonarQube (and which version):
      SonarQube Community Edition Version 9.9.3 (build 79811)

And a thorough description of the problem / question:
Custom rule execution issue via. SonarLint.
Steps :

  1. A new quality profile is created in SonarQube and set as a DEFAULT profile.
  2. Few custom rules have been developed and activated in the default quality profile, along with “Sonar Way BUILT IN” rules
  3. In IntelliJ IDEA, Integrate SonarLint to SonarQube project and execute code analysis via SonarLint. Custom rules were NOT executed. The SonarLint tab displays the issues only from the “Sonar Way BUILT IN” rules. “Update local storage” has been clicked in the SonarLint settings and tried again - same output (“Found 0 issues and 0 hotspots”).
  4. With the same SonarQube configuration, Code analysis is performed via. Jenkins (Project “Build Now” operation). All custom rules are executed as expected in the SonarQube UI, along with “Sonar Way” ( all BUILT IN) rules.
  5. Now return to IntelliJ IDEA and execute code analysis via the SonarLint tab - All custom rules executed successfully, along with “Sonar Way” ( all BUILT IN) rules. Expected response received in SonarLint tab of IntelliJ IDEA.
    Why SonarLint did NOT execute all the custom rules checks in step 3, but executed the same custom rules in the step 5 ( using the same SonarQube configuration)?
    Custom plugin was packaged using the sonarLintSupported = TRUE option in pom.xml
                    <!-- the entry-point class that extends org.sonar.api.SonarPlugin -->
                    <pluginDescription>sonarqube custom rules</pluginDescription>
                    <!-- properly declare dependency on SonarJava for SonarLint -->

Please advise if I am missing anything to execute the custom rules via SonarLint as we only like to use SonarLint for code analysis ( not via Jenkins’s Build → SonarQube for all projects).


This is a great question. The key part is this:

That means that you set it as the profile to be used in the next analysis for each project not directly pinned to a specific profile.

As a rule, Quality Profiles don’t change that often, and it’s generally true that the profile used for the last analysis will be the profile that will be used for the next analysis.

I’ve never had to think this through before, but I suppose Connected Mode is picking up the last-used profile and applying that, rather than trying to calculate what the next-used profile will be.

It’s possible that you’d have had a different outcome if you’d explicitly pinned your project to the new profile, but I doubt it.


Thank you for the reply. I have set the new “quality profile” as a default profile and set that in the project as a default quality profile. Custom rules have been activated in that quality profile. Connected mode did not pick up the custom rules until I executed the analysis via Jenkins for the same quality profile ( and same project). I thought the connected mode should execute the custom rules as like SonarQube ( via. Jenkins).

1 Like


It was just a guess that assigning the project to the profile might work. And I’m not shocked that it didn’t.

Look at it from the other direction: if your new default profile raises more issues than the old one, it would look weird for SonarLint to have “extra” issues that don’t show up in SonarQube (until after the new analysis).