Difference between Sonarlint in Vs Code and Intellij

Please provide

  • Operating system: Ubuntu 22.04
  • SonarLint plugin version:
    - Vs code: v4.12.0
    - Intellij: 10.12.0.79769
  • Programming language you’re coding in: Java
  • Is connected mode used:
    • Connected to SonarQube (and which version): SonarQube Developer Edition v10.7

And a thorough description of the problem / question:

I use both IDEs, Intellij and VS Code, I connect them to the same project in the same SonarQube, however in Intellij I noticed that it gives me a problem that does not appear in VS Code, the problem “java:S6204”.

Intellij:

Vs code:

I checked the rules to see if they were disabled, however in both IDEs the rules are the same and are enabled. I am using Java 17 for both IDEs.
Could this be a problem in Vs Code?

Hey there @DanielFerreira,

Thanks for reporting this. I was able to reproduce the issue and I freaked out for a minute :smiley: Until I remembered I’d recently reset my whole VS Code setup along with all the extensions.

In fact, for Java analysis to work properly in SonarQube for VS Code (yes, we have a new name :star_struck:), you need to have the Language Support for Java(TM) by Red Hat installed. This is highlighted in our docs.

Installing the extension fixed the issue for me, and I hope it does the same for you, too. :hugs:

All the best,
Sophio

1 Like

Hi @sophio.japharidze :grin:

Unfortunately, even with the installation of Language Support for Java™ from Red Hat and starting in standard mode, VS Code did not validate this part of the code.

I made an example for you to see, on the left VS Code and on the right Intellij

Some things are validated by Sonarlint on VS Code, such as the “class name” and “system.out”, but not the “collect”. Could it be some configuration of this extension that you sent me?

I tested on two different versions of Language Support for Java™ by Red Hat: v1.36.0 and v1.37.2024112108 (pre-release)

1 Like

You are right!

Can you try adding the following settings to your VS Code user settings and let me know if that helps?

    "sonarlint.analyzerProperties": {
        "sonar.java.source": "17",
    }

Feel free to replace the “17” with whichever Java version you are using.

Best,
Sophio

@sophio.japharidze You are the best hehe :grin:

After applying the change “sonar.java.source” at the file settings.json, it is working correctly.

image

Thank you very much for your attention.

Awesome! I’ve filed the bug, and the fix will be part of the upcoming release. :dart: In the meantime, you can stick with this workaround.

Thanks again for the report and sorry for the inconvenience.

P.S. If you enjoy our products, a review is always appreciated. :face_holding_back_tears:

Best,
Sophio :wave:

1 Like