A plugin to enable analysis of Dart and Flutter projects into SonarQube.
Feature | Supported |
---|---|
Size | YES |
Issues | YES (dartanalyzer rules) |
Tests | YES |
Coverage | YES |
Complexity | YES |
Syntax | YES |
The plugin is compatible with sonarQube 6.7+.
Checkout the Releases page.
Changelog is available here.
Install Flutter as explained on the official documentaiton page.
Dart is downloaded by the Flutter SDK in $FLUTTER_HOME/bin/cache/dart-sdk, however command lines are not on the path by default (dartanalyzer must be on the path).
It is recommanded to install Dart SDK separately as explained here : Install the Dart SDK for more reliability in a CI/CD environement.
Install sonar-scanner as explained in the official documentation.
- Download the plugin binary into the $SONARQUBE_HOME/extensions/plugins directory.
- Restart the server.
Create a sonar-project.properties file at the root with this content :
# Project identification
sonar.projectKey=flutter_rocks
sonar.projectName=Flutter Rocks
sonar.projectVersion=1.0
# Source code location.
# Path is relative to the sonar-project.properties file. Defaults to .
# Use commas to specify more than one folder.
sonar.sources=lib
sonar.tests=test
# Encoding of the source code. Default is default system encoding.
sonar.sourceEncoding=UTF-8
For a complete list of available options, please refer to the SonarQube documentation.
Use the following commands from the root folder to start an analysis:
# Download dependencies
flutter pub get
# Run tests
flutter test --machine > tests.output
# Compute coverage (--machine and --coverage cannot be run at once...)
flutter test --coverage
# Run the analysis and publish to the SonarQube server
sonar-scanner
The plugin uses its own analysis options file.
If analysis_options.yaml
file already exists under the project root, it will be saved during the analysis and then restored to its initial state.
To disable this behavior and use the existinganalysis_options.yaml
file instead, add the following line to sonar-project.properties
file :
# Use existing options to perform dartanalyzer analysis
sonar.dart.analysis.useExistingOptions=true
Any help is welcome, and PRs will be greatly appreciated!
SonarQube Plugin for Flutter / Dart is released under the GNU LGPL v3 license. See the LICENSE file for more information.