Recently we installed SonarQube 8.7 with monorepo support. I’d like to connect SonarLint to our SonarQube Projects but the Projects are a monorepo. Is it possible to connect multiple Projects in SonarLint for when I work on our monorepo and SonarLint recognize my working on particular files in each Project? I have not been able to find mention of a particular setting or format to do this.
@solar_slam which IDE are you using?
SonarLint doesn’t do anything special for monorepos, so it will depend on the IDE you are using and what you are trying to open in that IDE.
For example, SonarLint for Visual Studio (“SLVS”) binds at the solution-level i.e. each solution can be bound to one Sonar project. So SLVS won’t complain if you have multiple solutions in one repo that map to different Sonar projects.
In IntelliJ, if you open a specific project/module that is bound to a Sonar project then it should work as expected. However, if you open the repo root then the individual project/modules won’t be bound correctly.
Using VS Code. Looking at the configuration for the add-on, the JSON reads as if it can only accept a single Project. Would I need to include a
sonar-project.properties file to each sub-project (or “solution” as you say) in the monorepo for SonarLint to automatically pick up on? I suppose that also means I can’t open from the root of the monorepo?
Hello thanks for the additional details!
It all depends how your monorepo is laid out and how you want to open it in VSCode.
Say for instance that your monorepo has a layout like this:
root |- project1 |- project2 ... |- projectN
Then if I understand correctly how monorepos work in SonarQube, you would have one
sonar-project.properties per project, at least to define its key.
Then in VSCode, you can:
- create a multi root workspace
- add each project as a workspace folder in VSCode
- setup your server URL and credentials in your user settings
- configure project bindings in each project’s
.vscode/settings.json, to bind each folder to a server project
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.