Danger Dart Linter
A Danger Plugin to lint dart files using dart analyze or flutter analyze command line interface.
Installation
Add this line to your application's Gemfile:
$ gem 'danger-dart-linter'
Or install it yourself as:
$ gem install danger-dart-linter
Usage
Dart/Flutter Analyze doesn't give an option to generate report but you can achieve this easily using regular shell command (locally or on CI):
$ dart analyze > analyze_report.txt
or
$ flutter analyze > analyze_report.txt
It will add output from dart analyze or flutter analyze command to analyze_report.txt.
Now you need to set report_path and invoke lint in your Dangerfile.
dart_linter.report_path = "analyze_report.txt"
dart_linter.lint
This will add markdown table with summary into your PR.
Or make Danger comment directly on the line instead of printing a Markdown table (GitHub only)
dart_linter.lint(inline_mode: true)
Default value for inline_mode parameter is false.
Configuration options
It's possible to change some parameters to manage the report behavior.
# Lint only modified files (useful for legacy projects)
#
# If you're dealing with a legacy project, with tons
# of warnings, you may want to lint only new/modified files.
#
# Default: false
dart_linter.only_modified_files = true
# Custom table title
#
# Change title for the markdown table.
# Use `{{violations.legth}}` to dynamically insert the total issue count
#
# Default: "Dart Analyze found {{violations.length}} issues"
dart_linter.table_title = "Dart Analyze found {{violations.length}} issues"
# Table output format
#
# Select the table output format:
# - [S]everity: info, warning, error
# - [F]ile: file path
# - [P]ath: violation file path with line and column
# - [L]ine: line number
# - [C]olumn: column number
# - [R]ule: lint rule
# - [D]escription: lint description
#
# Default: "SFLR"
dart_linter.table_output_format = "SFLR"
# Path to the Dart analysis output file
# You should set output from `dart analyze` here
dart_linter.report_path = "analyze_report.txt"
# Run the linter parser
dart_linter.lint
Development
- Clone this repo
- Run
gem install bundlerto configure environment tools. - Run
bundle installto setup dependencies. - Run
bundle exec rake specto run the tests. - Use
bundle exec guardto automatically have tests run as you make changes. - Make your changes.
Contributing
Merge requests are welcome on GitLab at https://gitlab.com/fasunna/danger-dart-linter.
License
The gem is available as open source under the terms of the MIT License.
⚠️ Disclaimer: This project is a copy and continuation of danger-flutter_lint by mateuszszklarek. All original work belongs to the author.