Custom rule is enabled on the server, but not available in SonarLint

Please provide

  • Operating system: PyCharm 2023.1.5 on Windows 11
  • SonarLint plugin version: 10.3.0.77475
  • Programming language you’re coding in: Python
  • Is connected mode used:Yes
    • Connected to SonarCloud or SonarQube (and which version): SonarQube Enterprise Edition version 10.3

And a thorough description of the problem / question:
I created a custom rule using the sample Python plugin from here: sonar-custom-rules-examples/python-custom-rules at master · SonarSource/sonar-custom-rules-examples · GitHub

This works fine when I look at the analysis on the SonarQube server side. The rule is raised when I expect it. However, when I connect the PyCharm SonarLint plugin to the SonarQube server and try to run the rules, the logs show the following: Rule python-monorepo-import-rule is enabled on the server, but not available in SonarLint. I was of the impression that the custom plugins should in fact be available to SonarLint, so any help would be greatly appreciated.

Hey there!

Have you marked the plugin as compatible with SonarLint in the manifest? From the docs:

Note: Custom rules written in Java will run in SonarLint if SonarLint compatibility is properly notated in the custom plugin manifest, see this example for the syntax.

I repurposed the manifest from the sample Python plugin so this attribute is already marked as true.

Hm. :thinking:

Can you check the GET api/plugins/installed API (http://localhost:9000/api/plugins/installed) to see if the plugin is marked as sonarlint compatible there?

{
   "plugins":[
      {
         "key":"abap",
         "name":"ABAP Code Quality and Security",
         "description":"Code Analyzer for ABAP",
         "version":"3.14 (build 5470)",
         "license":"SonarSource",
         "organizationName":"SonarSource",
         "organizationUrl":"http://www.sonarsource.com",
         "editionBundled":true,
         "homepageUrl":"http://redirect.sonarsource.com/plugins/abap.html",
         "issueTrackerUrl":"http://jira.sonarsource.com/browse/ABAP",
         "implementationBuild":"ed8f535cc76a0a2be68bcfd2de29eff22412e83f",
         "filename":"sonar-abap-plugin-3.14.0.5470.jar",
         "hash":"578fac2aced2a282667d0ecb17a8b571",
         "sonarLintSupported":true, <-------
         "documentationPath":"static/documentation.md",
         "updatedAt":1714729027787,
         "type":"BUNDLED",
         "requiredForLanguages":[
            "abap"
         ]
      },

The plugin has the following entry:

{
         "key":"custompythonrule",
         "name":"Custom Python Rule",
         "description":"Import check custom rule",
         "version":"0.1.6",
         "license":"",
         "editionBundled":false,
         "filename":"sonar-python-rules-0.1.6.jar",
         "hash":"1fbada16149531c509a6b9b5d4984a51",
         "sonarLintSupported":true,
         "updatedAt":1718040865434,
         "type":"EXTERNAL",
      },

Thanks. I’m not sure how to square these two things (sonarLintSupported is true but a Rule python-monorepo-import-rule is enabled on the server, but not available in SonarLint. error).

So I’m going to flag this for some expert eyes.

1 Like

Hello,

I wasn’t able to reproduce the issue. Sonarlint works fine with the custom plugin that was developed following the example in the sample repo. I tested for both SonarQube versions: 9.9, which is the current LTA, and 10.3. Regarding SonarLint versions, it was tested for the latest versions on PyCharm and VSCode.
I would try to double check if the custom plugin follows all the guidelines.
Also, make sure that the rule is enabled in the active Quality Profile on the server.

Terribly sorry for the very late response.

Best,