# Required metadata
sonar.projectKey=<Project-Name-Key>
sonar.organization=<Organization ID>
# Project details
sonar.projectName=<Project Name>
sonar.projectVersion=1.1.14+37
sonar.sourceEncoding=UTF-8
# Properties specific to the Flutter project
sonar.sources=lib
sonar.tests=test
sonar.exclusions=**/*.g.dart,**/*.freezed.dart,lib/app/core/shimmer_widget/**,lib/app/core/shimmer_widget/widgets/**,lib/app/modules/**/views/**
sonar.test.inclusions=**/*_test.dart
# Additional settings
sonar.flutter.enabled=true
sonar.language=dart
# Coverage settings (if you have coverage reports)
sonar.dart.lcov.reportPaths=coverage/lcov.info
Languages of the Repository
Dart
SonarCloud Project URL (if public)
N/A (Private project)
Issue Encountered
Despite having unit tests 70% nevertheless, the code coverage is being reported as 0% in SonarCloud. The tests are running successfully, and test results are being generated, but the coverage data is not reflected on the SonarCloud dashboard.
This is an open community with people volunteering their free time to provide assistance. We’re eager to contribute to the community, but you are not guaranteed a fast response.
(posting that without having tested on my side but to try to unlock you)
Given that the sonarsource/sonarcloud-scan:2.0.0 relies on Docker Bitbucket, I believe you are facing the same problem as the one discussed here.
I suggest you try to configure your scan and import of coverage without using SonarSource/sonar cloud-scan:2.0.0 but instead call the sonar-scanner directly (get some inspiration from the post made by @Margarita_Nedzelska).
I’m running into an issue with my Bitbucket pipeline when trying to set up SonarCloud scanning. Specifically, I’m attempting to manually download and extract the Sonar Scanner CLI, but the pipeline throws an error:
+ unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
bash: unzip: command not found
To resolve this, I added the following command to install unzip before running the scanner:
apt-get update && apt-get install -y unzip
However, even with this addition, the pipeline still fails at the unzip command, indicating that it wasn’t installed correctly or perhaps there’s a misconfiguration somewhere in the environment.
I suspect that the base Docker image I’m using (sonarsource/sonarcloud-scan:2.0.0) might not have the unzip package available or there might be some issue with installing it in the pipeline environment.
Is there anything I’m missing in terms of setup or configuration that could help resolve this? I would greatly appreciate any guidance or suggestions on how to get the unzip command working or if there’s a better approach for handling the Sonar Scanner installation in a Bitbucket pipeline.
If you’re using this image you don’t have to install sonar-scanner since it’s already there. You can just use. The reason why you might want to download the the scanner is when you’re using a different image that doesn’t have it.
I don’t know from where this property is coming but I don’t think it’s needed for our analysis.
I don’t see any issue with your configuration, so I will need to check the logs. Let me know if you can’t share the logs here, and I’ll open a private conversation.
I have followed your instructions, but unfortunately, the issue persists. Could you kindly initiate a private conversation so I can share the logs with you?
This is an open community with people volunteering their free time to provide assistance. We’re eager to contribute to the community, but you are not guaranteed a fast response.
After looking at the logs (part of the logs that were shared), It seems to me that the analysis itself failed even before reaching the Dart analyzer.
From what I can see, the analysis failed due to the presence of C or C++ files. In order to analyze them, please, follow the documentation: Overview
If you only want to analyze Dart without C/C++/Objective-C files, you can follow the instructions in the error message:
`If you don’t want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-
Try setting these properties and check what is the result.
Quality Gate failed: Could not get scanner report: [Errno 2] No such file or directory: /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/sonarsource/sonarcloud-scan.log
Steps Taken:
Generate the coverage/lcov.info using flutter test --coverage
Verified that the Sonar Scanner command is correctly formatted.
Checked that the SonarCloud project configuration (organization, project key, and source paths) is accurate.
It looks like the pipeline fails on this step: Bitbucket and not at the analysis itself. Could you please double-check if you can see the analysis results in the SonarCloud UI?
Previously, the logs you shared showed the failure in the scan itself. The new error shows that the analysis was completed successfully, but the reporting quality gate in BitBucket through sonarcloud-quality-gate failed.
Could you please check the results in the SonarCloud UI and share logs with us in our private thread so we can investigate further?
Thanks for the update. The analysis results’ visibility in SonarCloud validates that the scan was successful. However, the problem is that a missing file prevented the quality gate from reporting.
Quality Gate failed: Could not get scanner report: [Errno 2] No such file or directory: '/opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/sonarsource/sonarcloud-scan/sonarcloud-scan.log'
It seems you are trying to use the sonarcloud-quality-gate pipe but this one can only be used after the sonarcloud-scan pipe.
Because of your previous problems we adviced not to use the sonarcloud-scan pipe. So, as a consequence, you can’t use the sonarcloud-quality-gate pipe.
So, I would recommend to follow these instructions in case you would like to stop your pipeline when the quality gate fails.
Basically, just add a -Dsonar.qualitygate.wait=true when running the scanner.
Yes, I agree with your observation. The issue appears to be related to the SonarCloud scan step. While the scan is running, we encounter errors that result in the code coverage showing 0%. We are still facing the same problems as before.
For your reference, I’ve shared all the details regarding this issue. Please let me know if there’s anything further to address or if we can take additional steps to resolve this.