I have a codebase the holds both python and java code under different directories.
We initially configurated sonar scan for java and it was working well. Later we added the configuration for python source code. Now we are able to get all source code metrics. However, on the Sonarcloud inside this project, in the code tab/section, when I get a warning while navigating through the directories.
On each directory, for every immediate childe file or directory under it, Sonarcloud throws a warning sign which says "Component Key β<repo-name<:<directory/file name> not foundβ
Edit: It looks these warnings are about the three parameter
- Security
- Reliability
- Maintainability
All of them are blank in the project dashboard.
Edit 2: Putting out the detailed structure of project and webpage screenshots
sonar.projectName=xxx-xxxx-xxx-cloud-services
sonar.projectKey=xxx-xxxx-xxx-cloud-services
sonar.projectVersion=1.0
sonar.sources=digital-api/add-module/src/main/java,digital-api/multiply-module/src/main/java,legacy-api/lambdas/add_module,legacy-api/lambdas/multiply_module
sonar.java.binaries=digital-api/add-module/target/classes,digital-api/multiply-module/target/classes
sonar.coverage.exclusion=**/ENV/**/*
sonar.java.libraries=${env.MAVEN_CACHE_FOLDER}/**/*.jar
sonar.java.test.libraries=${env.MAVEN_CACHE_FOLDER}/**/*.jar
sonar.coverage.jacoco.xmlReportPaths=digital-api/add-module/target/site/jacoco/jacoco.xml,digital-api/multiply-module/target/site/jacoco/jacoco.xml
sonar.junit.reportPaths=digital-api/add-module/target/surefire-reports,digital-api/multiply-module/target/surefire-reports
sonar.python.coverage.reportPaths=legacy-api/lambdas/coverage.xml
Project structure
βββ digital-api
β βββ add-module
β β βββ target
β β βββ site
β β βββ jacoco
β β βββ jacoco.xml
β βββ multiply-module
β β βββ target
β β βββ site
β β βββ jacoco
β β βββ jacoco.xml
β βββ pom.xml
βββ legacy-api
β βββ lambdas
β β βββ add_module
β β βββ adder.py
β β βββ multiply_module
β β βββ multiplier.py
β β βββ coverage.xml
β βββ requirements.txt
βββ tests
β βββ __pycache__
β βββ test_adder.py
β βββ test_multiplier.py
βββ sonar-project.properties
Edit 3:
How we are running the sonar scan?
- task: SonarCloudPrepare@1
displayName: "Prepare SonarCloud"
inputs:
SonarCloud: 'XXX-XXXXXX-SONARCLOUD'
organization: 'xxx-xxxxxxx'
scannerMode: 'CLI'
configMode: 'file'
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
sonar.pullrequest.vsts.instanceUrl=$(System.CollectionUri)
sonar.pullrequest.vsts.project=$(System.TeamProject)
sonar.pullrequest.vsts.repository=$(Build.Repository.Name)
sonar.projectName=$(Build.Repository.Name)
sonar.projectKey=$(Build.Repository.Name)
- task: SonarCloudAnalyze@1
displayName: 'Run Sonar Analysis'