I have a simple python project organized as follows:
src app.py fizzbuzz.py test fizzbuzz_test.py
But it seems that
sonar.sources is not working properly because SonarQube is considering tests file part of the coverage.
I’ve tried several configurations:
but I got this error:
ERROR: Error during SonarScanner execution ERROR: File test/fizzbuzz_test.py can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
that pass indexing
INFO: Indexing files... INFO: Project configuration: INFO: Excluded sources: .vscode, conftest.py INFO: 10 files indexed... (last one was .pylintrc) INFO: 10 files indexed... (last one was .pylintrc) INFO: 32 files indexed INFO: 1 file ignored because of inclusion/exclusion patterns
but tests files are indexed as code that SonarQube want to cover.
I’m scanning it with:
- SonarQube: 18.104.22.168709
- SonarScanner 22.214.171.12447
With this config:
sonar.sources=src/app.py sonar.tests.inclusions=test/**/*_test.py # Goal: i want to delete this line # sonar.coverage.exclusions=test/**/*, docs/**/* sonar.exclusions=.vscode, conftest.py sonar.language=py sonar.python.version=3.9 sonar.sourceEncoding=UTF-8 # Unit tests sonar.python.xunit.reportPath=build/reports/tests/*.xml sonar.python.coverage.reportPaths=build/reports/coverage/*.xml
What I’m missing to proper configure src files ?