I’m trying to get started with SonarCloud on a Python and web project.
I’m trying to diagnose an issue with pysonar miscounting the number of lines. This mis-count is a separate issue.
To do this I want to temporarily exclude the web directory. I tried this:
pysonar \
--sonar-token=XXX \
--sonar-project-key=XXX \
--sonar-organization=XXX --sonar.coverage.exclusions='web/**'
According to the docs, that option should work. But I see in the logs:
WARNING: Too many duplication groups on file web/src/components/XXX.ts. Keep only the first 100 groups.
WARNING: Too many duplication references on file web/src/components/YYY.ts for block at line 978. Keep only the first 100 references.
WARNING: Too many duplication groups on file web/src/components/ZZZ.ts. Keep only the first 100 groups.
So it looks like pysonar is not respecting that exclusion. I’ve also tried supplying --sonar-coverage-exclusions='web' which also does’t work.
When I supply --debug:
DEBUG: Properties: {"scannerProperties": [{"key": "sonar.scanner.app", "value": "python"},
{"key": "sonar.scanner.appVersion", "value": "1.0"},
{"key": "sonar.scanner.bootstrapStartTime", "value": XXX},
{"key": "sonar.verbose", "value": true},
{"key": "sonar.scanner.skipJreProvisioning", "value": false},
{"key": "sonar.scanner.connectTimeout", "value": 5},
{"key": "sonar.scanner.socketTimeout", "value": 60},
{"key": "sonar.scanner.responseTimeout", "value": 0},
{"key": "sonar.scanner.truststorePassword", "value": "changeit"},
{"key": "sonar.scanner.keystorePassword", "value": "changeit"},
{"key": "sonar.scanner.os", "value": "mac"},
{"key": "sonar.scanner.arch", "value": "aarch64"},
{"key": "sonar.projectBaseDir", "value": XXX"},
{"key": "sonar.organization", "value": "XXX"},
{"key": "sonar.token", "value": "XXX"},
{"key": "sonar.projectKey", "value": "XXX"},
{"key": "sonar.coverage.exclusions", "value": "web"},
{"key": "sonar.host.url", "value": "https://sonarcloud.io"},
{"key": "sonar.scanner.apiBaseUrl", "value": "https://api.sonarcloud.io"},
{"key": "sonar.scanner.sonarcloudUrl", "value": "https://sonarcloud.io"},
{"key": "sonar.scanner.proxyPort", "value": "443"},
{"key": "sonar.scanner.javaExePath", "value": "XXX/.sonar/cache/OpenJDK21U-jre_aarch64_mac_hotspot_21.0.9_10.tar.gz_unzip/jdk-21.0.9+10-jre/Contents/Home/bin/java"}]}
How can I exclude a directory from analysis?