Azure DevOps Monorepo shared library Lines of Code

We have a monorepo, using Azure DevOps for ALM and CI/CD. We are building microservices, expecting to have over 100 individual APIs/Projects when complete.

I’ve been setting up a Project for each of these in SonarCloud, and enabling the Monorepo setting for each Project.

Each project refers to some Shared Libraries, also in the monorepo. Because these shared libraries are referenced (and analyzed) in each Project, they are counted towards our total Lines of Code each time. This means our total Lines of Code is huge compared to what is actually in our repo.

Is there a way to get the Lines of Code count to not count these shared libraries many times?

Hi @glenmacdonald and welcome to the community !

A suggestion that i have in mind will be to make sure that your Shared libraries are analyzed only once into a single SonarCloud project (or have it’s dedicated SC project) and exclude it from other analyses/projects.

WDYT ?

Mickaël

Hi @mickaelcaro,

Having a separate project just for shared libraries was my thought also, although I would prefer if it were included in the same Projects as the components to give a true representation of whether all code used project has passed/failed.

I haven’t gotten to using PR quality gates yet, but if i have a dedicated SC project just for Shared Libraries, will the quality gate for a PR include both the SC project and the Components’ project?

Cheers,
Glen.

Hi @glenmacdonald

If you setup all your projects as monorepo and as long as a PR trigger multiple analyses, then yes, all QG related to the number of analyses (builds) triggered by that PR will be reported to it.

Mickaël