Unable to synchronise Rules between SonarLint <> SonarCloud in VSCode

Hello Sonar-Team,

Apologies if this is a duplicate of an existing question.
I’ve read through them all, and I’ve been trying to get this to work for days now, I’m ready to give up.
I’d like to however give this one last chance.

If I understand the SonarLint <> SonarCloud connection properly, we should we able to setup one QualityProfile (containing multiple Rules) in SonarCloud.
When I then enable the SonarLint <> SonarCloud connection, the same rules as in the QualityProfile assigned to the current project should be enabled in SonarLint, correct?

I’ve followed the guide at Link, I’ve tried it multiple times, however I just can’t get the enabled / disabled SonarLint Rules to line up with the quality profile selected for the synchronised project.

I’ve tried to get all the relevant settings / rules into one screenshot:

Above you can see

  1. VSCode User Settings: ConnectedMode > SonarCloud (incl. organizationKey and Token)
  2. VSCode Workspace Folder Settings: ConnectedMode > Project (incl. correct ProjectKey)
  3. Activated QualityProfile “PHP Recollect Sonar” (Assigned to the project)
  4. As an example, Rule ‘“enable_dl” should be disabled’ showing activated in SonarCloud
  5. Same Rule “Off” in SonarLint Rules.

This is after restarting VSCode, Running “Update all Project bindings”, swapping out my SonarCloud Connection Token mutliple times, reinstalling VSCode, enabling SonarLint.trace.server: verbose and combing through the output there…
I don’t understand what I’m missing, please help! :slight_smile:

Thanks,
Dominik

Hello @DFeiler and welcome to the community!

I’m not sure I got what is the problem from your description. It looks like you configured everything well. I’ll take a risk to assume you maybe expect to see local rules settings to match your quality profile. If it is so - it’s not how it works. When connected to server SonarLint just ignores local settings and override them with Quality Profile configuration. So expected behavior in your situation - is that SonarLint will analyze local files and raise issues for rules activated on server. With important remark that not all rules can be checked on SonarLint. You can see on https://rules.sonarsource.com/ for specific rule if you have doubts.
So the question is if SonarLint actually analyze files and shows issues from your Quality Profile. I hope it is. And if it’s not - please come back and we will find out why.

Hey @Kirill_Knize,
Thanks, that was it.
I didn’t have the sonarlint <> sonarcloud configuration in the right place, so the sonarcloud rules were not being followed by sonarlint.
Then to troubleshoot this, I (incorrectly) used the display of the local sonarlint rules to try and verify whether it is syncing.

Thanks for your help!

Cheers,
Dominik

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.