SonarLint doesn't show custom rules from local SonarQube server

I’ve added some XML custom rules for my project. Then I added these rules to my local SonarQube server. When I analyze my project all of the custom rules appear. When I opened my project in Eclipse and connected to my local sonarqube via sonarlint, everything works fine. The problem with intellij. It doesn’t show any of rules except the rules that have been there before.

in my pom.xml I flagged this one

<sonarLintSupported>true</sonarLintSupported>

Also I’m informed that sonarlint doesn’t support 3rd party plugins, but I don’t use any of them. Maybe there is some exceptions for intellij? cause for eclipse those rules appear.

My sonarqube version is 7.7.0.23042 and sonarlint Version for Intellij : 3.4.0.2532 Sonarlint for eclipse 4.1

Hi,

SonarLint for Eclipse and IntelliJ are very similar, so it should work. Have you updated the SonarLint local storage in IntelliJ?

Hi,
Thank you for your reply. Yes, I updated binding, but it didn’t help.

Can you open the SonarLint logs tab, enable verbose output, and run again the binding update. It should display the list of plugins that have been downloaded from the server. Please share the entire log if you don’t know where to look at.

I see my XML plugin

Load plugins
Load plugins (done) | time=10ms
Plugins:

  • SonarScala 1.5.0.315 (sonarscala)
  • SonarPython 1.13.0.2922 (python)
  • SonarJava 5.11.0.17289 (java)
  • SonarHTML 3.1.0.1615 (web)
    SonarXML 2.1.0-SNAPSHOT (xml)
  • SonarKotlin 1.5.0.315 (kotlin)
  • SonarPHP 3.0.0.4537 (php)
  • SonarTS 1.9.0.3766 (typescript)
  • SonarJS 5.1.1.7506 (javascript)
  • SonarRuby 1.5.0.315 (ruby)full_log.txt (29.5 KB)

UPD: uploaded full log

I see you have modified the SonarXML plugin to implement your additional rules. That’s hard to see why it doesn’t work in IntelliJ when it works in Eclipse.
Are you able to share the changes you made on the plugin somewhere so that we could see if something is wrong?

@Julien_HENRY, this is my project

@Julien_HENRY Forget to mention, current branch is: 1.0

Thanks @DianaAimbetova

In fact this is not a forked version of SonarXML, but a brand new analyzer. So that’s expected to not have SonarLint running it (look for the FAQ in this forum for details).

Now I’m really surprised when you say it works in SonarLint for Eclipse. This is unexpected.

I tried to fork it from here https://github.com/DianaAimbetova/sonar-xml , but then I wasn’t able to push anything there, so that’s why I created new repo. What should I do to be able to add rules into intellij’s sonarlint?

We don’t have an official API for adding custom rules to SonarXML. I don’t think this is on our short term roadmap. So you can continue with your fork, but we won’t provide any active support. Or maybe if your rules are valuable to the community, you can create a new thread to suggest them, and we could consider implementing them in the official SonarXML plugin.

So the only way to add custom rules into sonar-XML analyzer which properly works with intellij is creating xpath rule like it was written here?

I think yes, but I have not tested recently.

ok, thanks

Personal rules are not synchronized

I just did a test with a SonarXML custom rule using XPath template:

I works fine in SonarLint for Eclipse:

Currently it doesn’t work in SonarLint for IntelliJ, since the support of XML has not yet been released (so in fact no XML rules at all will show up in IntelliJ). You can watch https://jira.sonarsource.com/browse/SLI-320 to be notified of the release.

1 Like

@Julien_HENRY thanks a lot

I post the same answer here yesterday :expressionless: