Programming language you’re coding in: JAVA, PLI, COBOL
Is connected mode used:
SonarQube Cloud, SonarQube Server, or SonarQube Community Build? (if one of the latter two, which version?):SonarQube Server
And a thorough description of the problem / question:
We have a vscode extension to automate maven quarkus and java batch projects for users (we use redhats java extensions and Microsofts java debugger, and we also use other languages). We implemented the maven commands via contextmenü, added a view for testing rest calls for the services, etc.
Now we would like to automate the project binding with
And parsing the project name for the binding from the git file of the current project opened file (so the user dont has to set a project binding by hand ). We use a multiroot Workspace with severall folders…
→ this is allready working, but i noticed that setting “sonarlint.connectedMode.project” in the workspace setting does not seem to be reflected in sonars view “Connected Mode” only when writing a folders setting file.
Questions:
1.)So can you confirm that the correct way to automate the project binding ist to write the setting file to the workspace folder?
2.)Is there a way to initiate a binding after changing of the project without the need of restart or wait an hour?
3.) We want to use other languages as well, cobol seems allready working (after connecting), we noticed on the server side under “Rules” that there are also rules for PL/I , but you do not provide support for this language…
4.) is there a possibillity to provide multiple bindings to sonar server
Just to better understand your use-case, is there a reason the Shared Binding Configuration feature does not work for you? The feature provides a possibility to store a SonarQube binding configuration file in a git repository, and then all collaborators can make use of it. If the config file is present in the workspace folder, SonarQube for IDE will prompt you to set up the binding.
We also provide a command, `SonarLint. AutoBindWorkspaceFolders, ’ which allows you to quickly bind currently open workspace folders.
Thanks in advance for clarifying and all the best,
Sophio
we have not considered storing it in git. Our use case is to automatically collect the information and bind the current open file to the current project, where the user should not have to do anything, and if there are more projects in the workspace, they should be bound automatic (by writing a setting via our own extension)
when setting the trace we noticed that the detection seems to fail, the git repo is the PROJECTROOT and is 2 folders “deeper”, or 1 folder deeper if it were a JAVADEV…,
[Trace - 7:39:56 AM] Received notification 'window/logMessage'.
Params: {
"type": 4,
"message": "[Info - 07:39:56.954] [sonarlint : SonarLint Analysis Executor] Git Repository not found for c:\\MYFOLDERS\\WORKSPACE ROOT\\FOLDER XYZ. The path c:\\\WORKSPACE ROOT\\FOLDER XYZ is not in a Git repository"
}
In the example above, I have created a connection to my-sonarqube-server, and then bound three different workspace folders to three different projects on my server.
Documentation for this is here. So, firstly, users will need to have a connection to the server set up. After that, the project binding setup can be automated as you describe.
Yes, the project binding settings are stored in a workspace folder settings file, so you can have one binding per workspace folder. From the example above, folder1/.vscode/settings.json will have the following content
I don’t understand the question do you mean initiating a synchronization with the server?
Yes, currently, SonarQube for IDE: VS Code does not support PL/I analysis. You can see the list of supported languages here. I will flag this internally for future consideration.
Not sure I understand the question; As mentioned above, it is only possible to have one binding per workspace folder. So in your example you can have FOLDER XYZ bound to PROJECT XYZ on the server, and FOLDER JAVADEV to PROJECT JAVADEV.
Upon connection creation we store User Token into VSCode’s SecretStorage. Relevant code is here. Just sharing in case it might help you with further automation
If a user opens workspacefolder X and project 1 we want to write this information to the settings file of workspacefolder X. If the user opens workspacefolder Y and project 2, we have to write the settings file to workspacefolder Y. If i understand the project binding correctly there is then a restart required (or wait an hour). → the idea is that the user does not need to do this manually (via the view).
Our workspace is normally fully automated, where the user jirastories are present as folders und in this folders you have the projectsfolder… (and we are doing cobol and pl/I also in vscode)…
One missing part maybe is the fact that sonar does not find the git folder because of the multiroot workspace and settings mentioned above, i will have to check that…(and therefore the serverside checking is not active, just the local linting)
If i understand the project binding correctly there is then a restart required (or wait an hour). → the idea is that the user does not need to do this manually (via the view).
I confirm that the user does NOT need to do anything manually and does not wait for 1 hour. The synchronization will happen immediately once binding is created + at window startup (reload) + every 1 hour. In addition, the server sends the IDE events to keep it up-to-date (such as Quality Profile update, issue status change, etc.). So this is all transparent for the users and no manual triggers are needed.
LMK if any further details will be needed.
Best,
Sophio