# 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.