Coder Social home page Coder Social logo

mateuszszklarek / danger-flutter_lint Goto Github PK

View Code? Open in Web Editor NEW
36.0 3.0 4.0 29 KB

A Danger Plugin to lint dart files using flutter analyze command line interface.

License: MIT License

Ruby 100.00%
flutter flutterlint flutter-analyze dart danger danger-plugin

danger-flutter_lint's Introduction

danger-flutter_lint

Gem Build Status codecov

A Danger Plugin to lint dart files using flutter analyze command line interface.

Installation

Add this line to your application's Gemfile:

$ gem 'danger-flutter_lint'

Or install it yourself as:

$ gem install danger-flutter_lint

Usage

Flutter Analyze doesn't give an option to generate report but you can achieve this easily using regular shell command (locally or on CI):

$ flutter analyze > flutter_analyze_report.txt

It will add output from flutter analyze command to flutter_analyze_report.txt.

Now you need to set report_path and invoke lint in your Dangerfile.

flutter_lint.report_path = "flutter_analyze_report.txt"
flutter_lint.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)

flutter_lint.lint(inline_mode: true)

Default value for inline_mode parameter is false.

Lint only added/modified files

If you're dealing with a legacy project, with tons of warnings, you may want to lint only new/modified files. You can easily achieve that, setting the only_modified_files parameter to true.

flutter_lint.only_modified_files = true
flutter_lint.report_path = "flutter_analyze_report.txt"
flutter_lint.lint

Development

  1. Clone this repo
  2. Run bundle install to setup dependencies.
  3. Run bundle exec rake spec to run the tests.
  4. Use bundle exec guard to automatically have tests run as you make changes.
  5. Make your changes.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mateuszszklarek/danger-flutter_lint.

License

The gem is available as open source under the terms of the MIT License.

danger-flutter_lint's People

Contributors

mateuszszklarek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

danger-flutter_lint's Issues

Allow to run only on modified lines

First, thanks for this, I would be cool to have an option to run it only over modified files

Current

There's an option to run only on modified files only_modified_files,

Expected

Be able to run only over modified files, too.

`flutter analyze --write` breakes the parsing

flutter analyze takes --write=path/report-name.txt option argument. Reports generated in this way are slightly different than the flutter analyze, making flutter_lint unable to parse the results:

$ flutter analyze --no-fatal-infos --no-fatal-warnings > flutter_analyze_report.txt
1 issue found. (ran in 12.0s)
$ cat flutter_analyze_report.txt
Analyzing rtyst_flutter...                                      
   info • Sort constructor declarations before other members • lib/main.dart:23:3 • sort_constructors_first
$ flutter analyze --no-fatal-infos --no-fatal-warnings --write=flutter_analyze_report.txt
Analyzing rtyst_flutter...                                      
   info • Sort constructor declarations before other members • lib/main.dart:23:3 • sort_constructors_first
1 issue found. (ran in 13.2s)
$ cat flutter_analyze_report.txt
[info] Sort constructor declarations before other members (/builds/rtyst/rtyst_flutter/lib/main.dart:23:3)

Because --write is the supported way for flutter to generate reports, flutter_lint should work with it.

Report formatting issues with dartfmt

Would it be possible to also report formatting issues by calling dartfmt/flutter format? I currently have an action that calls the following:

find . -name *.dart -not -path "./lib/generated/*" -exec flutter format --set-exit-if-changed --dry-run {} +

and fails if it finds any formatting issues, but it would be amazing if they could be reported like the flutter analyze output. It doesn't need to report specific issues, even just "Formatting issues found" as a warning on the filename would be great.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.