Multicomponent repository

Version:

  • Community Edition Version 10.2
    I have a repository with several components mainly python and two of them in ts/js.
    I have unit-testing for each component that uses a docker-compose to perform testing and then leaves coverage files.
    My first choice have been to use a multimodule project but I am encountering some issues. My coverage reports are under a ‘coverage_xml_report’ dir
├── component1
│   ├── coverage_xml_report
├── component2
│   ├── coverage_xml_report

the coverage reports have inside

        <sources>
                <source>/app</source>
        </sources>

and my sonar-project.properties

sonar.projectKey=core
sonar.projectName=Core
sonar.projectBasedir=/app

sonar.modules=component1,component2
sonar.scm.disabled=false
sonar.verbose=true
sonar.exclusions="**/tests/**,**/_test_results/**,**/*/migrations/*,*/manage.py,**/*.pyc,**/coverage_xml_report/**"
sonar.python.version=3.8,3.9,3.10

component1.sonar.sources=/app/component1
component1.sonar.projectName=component1
component1.sonar.language=py
component1.sonar.python.coverage.reportPaths=/app/component1/coverage_xml_report/coverage.xml

component2.sonar.sources=/app/component2
component2.sonar.projectName=component2
component2.sonar.python.coverage.reportPaths=/app/component2/coverage_xml_report/coverage.xml

To make sonarscanner to find the files I have to edit manually each coverate report to change sources from /app to ./
But some of the components don’t work like this because have different sources.
Is multimodule the way to go? Could I configure my properties file to find the coverage files without having to edit the sources ? I tried to use relative_files in coveragerc with no success.

Hi,

I doubt you really need the multi-module configuration. Can you just try setting

sonar.sources=app
sonar.python.coverage.reportPaths=component1/coverage_xml_report/coverage.xml,component2/coverage_xml_report/coverage.xml

Regarding some of your other properties

Why? This is how new code is detected. Without this you miss a lot of benefits

This does nothing. You can drop it.

Even if you stay with a multi-module analysis, I don’t think you need this.

 
HTH,
Ann

Thanks for your comments. I only showed two components but indeed I have 16, 2 of them are TS not python so multimodule helps me on maintaining excludes cleaner.

What about the ‘sed’ thing for the path in coverage.xml files ? I have seen lots of posts recommending this but it’s rare to edit files before scanning just because the coverage files were generated outside the scanner context and paths do not match

Hi,

Well, the paths in the reports need to match the paths analysis is seeing, so if the reports’s paths aren’t “correct” you’ll need to edit them somehow. I’m not a big sed-er, so it wouldn’t necessarily be my first choice, but…

I suppose the consolidated exclusions you showed in your OP was just a mockup, then for the purposes of example & not what you really use?

 
Ann