Qabbout / sonar-flutter

SonarQube plugin for Flutter / Dart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CI Coverage

SonarQube plugin for Flutter / Dart

A plugin to enable analysis of Dart and Flutter projects into SonarQube.

main.png

Features

Feature Supported
Size YES
Issues YES (dartanalyzer rules)
Tests YES
Coverage YES
Complexity YES
Syntax YES

The plugin is compatible with sonarQube 6.7+.

Download

Checkout the Releases page.

Changelog is available here.

Prerequisites

Flutter SDK

Install Flutter as explained on the official documentation page.

Installation instructions

Dart

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 recommended to install Dart SDK separately as explained here : Install the Dart SDK for more reliability in a CI/CD environment.

sonar-scanner (requires Java)

Install sonar-scanner as explained in the official documentation.

Installation instructions

Installation (on the server)

  • Download the plugin binary into the $SONARQUBE_HOME/extensions/plugins directory.
  • Restart the server.

Project configuration

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

# Allows reuse of an existing analyzer report
# sonar.dart.analysis.reportPath=

# Analyzer mode
# Can be:
# - flutter (flutter analyze) - default
# - dart (dart analyze)
# - legacy (dartanalyzer)
# sonar.flutter.analyzer.mode= 

For a complete list of available options, please refer to the SonarQube documentation.

Run analysis

Use the following commands from the root folder to start an analysis:

# Download dependencies 
flutter pub get 
# Run tests with User feedback (in case some test are failing)
flutter test
# Run tests without user feedback regeneration tests.output and coverage/lcov.info
flutter test --machine --coverage > tests.output 

# Run the analysis and publish to the SonarQube server
sonar-scanner

Use existing analysis options

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

Contributing

Any help is welcome, and PRs will be greatly appreciated!

License

SonarQube Plugin for Flutter / Dart is released under the GNU LGPL v3 license. See the LICENSE file for more information.

About

SonarQube plugin for Flutter / Dart

License:Other


Languages

Language:Java 96.3%Language:ANTLR 2.3%Language:Groovy 0.9%Language:Dart 0.4%Language:Shell 0.1%