SublimeText SonarCloud LSP usage

I am using GitHub - sublimelsp/LSP-SonarLint: Linting from SonarSource in SublimeText.
I am wondering how I can have it us my extended ruleset instead of the global SonarCloud Way.

This is my config file:

{
    "command": [
        "java",
        "-jar",
        "${packages}/${name}/sonarlint-language-server-4.6.0.2652.jar",
        "${port}",
        "${packages_uri}/${name}/sonar-javascript-plugin-6.4.1.12828.jar",
        "${packages_uri}/${name}/sonar-java-plugin-6.7.0.23054.jar",
        "${packages_uri}/${name}/sonar-php-plugin-3.9.0.6331.jar",
        "${packages_uri}/${name}/sonar-python-plugin-3.1.0.7619.jar",
        "${packages_uri}/${name}/sonar-html-plugin-3.2.0.2082.jar"
    ],
    "languages": [
        {
            "languageId": "javascript",
            "document_selector": "source.js"
        },
        {
            "languageId": "php",
            "document_selector": "embedding.php"
        },
        {
            "languageId": "html",
            "document_selector": "source.html | text.html.basic | text.html.ngx"
        },
        {
            "languageId": "css",
            "document_selector": "source.css"
        },
    ],
    "tcp_port": -1,
    "settings": {
        "sonarlint.connectedMode.connections.sonarcloud": [
        	{
        		"organizationKey":"MY_ORG_KEY",
                        "token":"MY_ORG_TOKEN"
        	}
        ],
        "sonarlint.disableTelemetry": true,
        "sonarlint.output.showAnalyzerLogs": false,
        // Enable verbose log level (for both SonarLint and analyzer) in the
        // SonarLint output.
        "sonarlint.output.showVerboseLogs": false,
    }
}

(of course MY_ORG_KEY and MY_ORG_TOKEN are placeholders in this above code)

How could I tell it to use my actual amended rules?
In the integration for VSCode I read that it is automatically using it, if in connected mode… but it also says I have to connected it to a project which I obviously don’t want, since I want to use SonarCloud on all my code edited in SublimeText, not just in one project.
(see sonarlint-vscode/package.json at master · SonarSource/sonarlint-vscode · GitHub for ref)

Anyone here using SublimeText has had any luck?
BTW, it is a shame that SonarCloud just skipped one of the most used Editor (SublimeText) compared to the ones integrated :frowning: (see Stack Overflow Developer Survey 2018, Stack Overflow Developer Survey 2021 for ref).
Sublimetext was above almost all integrated editors for long time and still is above things like PHPStorm.

1 Like

Hi,

As the README page notes, this is not an official, SonarSource implementation of SonarLint. So I don’t know if what I’m about to say will hold true for it.

But in official SonarLint versions, in connected mode SonarLint applies the Quality Profile defined on the server. So theoretically, you would define your profile on SonarCloud and either set it as your organizational default, or pin it to your project. Then in connected mode it would be applied automatically.

Aaaand… with further questions, you should ask the project’s maintainers.

 
HTH,
Ann

1 Like

This does as well not work with VisualStudio Code

  1. I have a (private) project in SonarCloud with custom quality profile
  2. I have the project in VS Code
  3. I added the connection to the SonarCloud, as such:
{
    "sonarlint.connectedMode.project": {
        "connectionId": "my_connection_id",
        "projectKey": "my_project_key"
    }
}

Does not work. Pulls in parent SonarWay rules.

the VS Code project is laid out in
Git Repo
> .vscode folder > settings.jsin
> Folder with code

It clearly pulls in parent rules since I altered the “function names must follow a naming convention” rule to allow _ and it does flag it as wrong. :frowning:

error:

Error running command SonarLint.AddProjectBinding: Unable to parse decrypted password. This is likely caused by the extension that contributes SonarLint.AddProjectBinding.

so, it is not just broken in Sublime text.

I deleted all connections and re-connected. That worked

Now find that I cannot bind more than one project in the same connection :rofl:
If I click the + in the specific connection, and choose another project, it simply replaces the current project binding.

Arrow indicates where I click and on that, it offers me to choose from projects… doing that, replaces instead of adding a new bind.

So I have to create a new connection for each project?
That is crazy. I will end up with something like 30 connections, but I have merely 2 orgs and each org has several connections.

Do I miss something?

This is next level weird.

I found this How to configure connected mode in VSCode - #7 by locdangle2552 - which totally breaks the setup

It truly seems we can NOT have open several folders (each folder a project in an org) at the same time in VSCode without actually breaking the SonarCloud integration, unless we bind ALL those folders to the same project, which is totally undesirable

This means, we have to open each folder (which corresponds to a project in Sonarcloud) on its own.

how cumbersome.

Found the awesomely hidden solution!

  1. Open any folder in VSCode
  2. Go to Files > Save Workspace as > Give it a name and save
  3. NOW you can add folders to workspace using Files > Add folder to workspace
  4. NOW you can connect to SonarCloud and NOW you can then connect each of these folders in the workspace to a specific SC Project without disturbing the others

Gosh. This is … Why is this not documented?
I could’t find this information anywhere! It is so simple yet so complicated :stuck_out_tongue:

I am trying it with Sublime Text… Currently it doesn’t crash but it doesn’t add any errors/warnings either :))

But I had to do local patching. I downloaded latest sonar-javascript-plugin-10.5.1.22382.jar. So there’s something I am missing.

My config file has this chunk additionally to the one posted by smileBeda:

"sonarlint.connectedMode.project": {
      "connectionId": "my-id", // should be same connectionId you defined above
      "projectKey": "project-id" // Replace with project key you grabbed from SonarQube server
    }

@Railing8902 … do yourself the favour and use VS Code Studio

I was a Sublime user for approximately 7 years and I am very stubborn when it comes to switching tools. Even more so when the other solution is made by corporations I do not identify with. However, I switched to VS about 2 months ago and I have no reason to look back. Literally, I wonder now why I was such a masochist over the past years using ST.

And the best is, you’ll save yourself some money too.

Just a suggestion, from someone who literally did not want to ditch ST both out of love to it and conservativeness when it comes to established tools in my workflow. Since I use VS, I am actually working with a tool and not trying to fix issues in a tool.

1 Like