Code Monkey home page Code Monkey logo

flutterando_metrics's Introduction

Build Status Coverage Status Pub Version Dart SDK Version License Pub popularity GitHub popularity

Flutterando Metrics logo

Flutterando Metrics

Note: you can find the full documentation on the website

Configuration | Metrics | Anti-patterns

Flutterando Metrics is a toolkit that helps you identify and fix problems in your Dart and Flutter code. These problems can range from potential runtime bugs and violations of best practices to styling issues. Flutterando Metrics includes over 70 built-in rules to validate your code against various expectations, and you can customize these rules to fit your specific needs.

Links

Installation

$ dart pub add --dev flutterando_metrics

# or for a Flutter package
$ flutter pub add --dev flutterando_metrics

Basic configuration

Add configuration to analysis_options.yaml and reload IDE to allow the analyzer to discover the plugin config.

You can read more about the configuration on the website.

Basic config

analyzer:
  plugins:
    - flutterando_metrics

flutterando_metrics:
  metrics:
    cyclomatic-complexity: 20
    number-of-parameters: 4
    maximum-nesting-level: 5
  metrics-exclude:
    - test/**

Usage

CLI

The package can be used as CLI and supports multiple commands:

Command Example of use Short description
analyze dart run flutterando_metrics:metrics analyze lib Reports code metrics anti-patterns violations.
check-unnecessary-nullable dart run flutterando_metrics:metrics check-unnecessary-nullable lib Checks unnecessary nullable parameters in functions, methods, constructors.
check-unused-files dart run flutterando_metrics:metrics check-unused-files lib Checks unused *.dart files.
check-unused-l10n dart run flutterando_metrics:metrics check-unused-l10n lib Check unused localization in *.dart files.
check-unused-code dart run flutterando_metrics:metrics check-unused-code lib Checks unused code in *.dart files.

For additional help on any of the commands, enter dart run flutterando_metrics:metrics help <command>

Note: if you're setting up Flutterando Metrics for multi-package repository, check out this website section.

Analyze

Reports code metrics and anti-patterns violations. To execute the command, run

$ dart run flutterando_metrics:metrics analyze lib

# or for a Flutter package
$ flutter pub run flutterando_metrics:metrics analyze lib

It will produce a result in one of the format:

  • Console
  • GitHub
  • Codeclimate
  • HTML
  • JSON

Console report example:

Console report example

Check unnecessary nullable parameters

Checks unnecessary nullable parameters in functions, methods, constructors. To execute the command, run

$ dart run flutterando_metrics:metrics check-unnecessary-nullable lib

# or for a Flutter package
$ flutter pub run flutterando_metrics:metrics check-unnecessary-nullable lib

It will produce a result in one of the format:

  • Console
  • JSON

Console report example:

Console report example

Check unused files

Checks unused *.dart files. To execute the command, run

$ dart run flutterando_metrics:metrics check-unused-files lib

# or for a Flutter package
$ flutter pub run flutterando_metrics:metrics check-unused-files lib

It will produce a result in one of the format:

  • Console
  • JSON

Console report example:

Console report example

Check unused localization

Checks unused Dart class members, that encapsulates the app’s localized values.

An example of such class:

class ClassWithLocalization {
  String get title {
    return Intl.message(
      'Hello World',
      name: 'title',
      desc: 'Title for the Demo application',
      locale: localeName,
    );
  }
}

To execute the command, run

$ dart run flutterando_metrics:metrics check-unused-l10n lib

# or for a Flutter package
$ flutter pub run flutterando_metrics:metrics check-unused-l10n lib

It will produce a result in one of the format:

  • Console
  • JSON

Console report example:

Console report example

Check unused code

Checks unused code in *.dart files. To execute the command, run

$ dart run flutterando_metrics:metrics check-unused-code lib

# or for a Flutter package
$ flutter pub run flutterando_metrics:metrics check-unused-code lib

It will produce a result in one of the format:

  • Console
  • JSON

Console report example:

Console report example

Troubleshooting

Please read the following guide if the plugin is not working as you'd expect it to work.

Contributing

If you are interested in contributing, please check out the contribution guidelines. Feedback and contributions are welcome!

LICENSE

MIT

flutterando_metrics's People

Contributors

akaiser avatar alvarovasconcelos avatar andrewst avatar anrock avatar ascenio avatar aschyolokov avatar bigdaddys avatar creativecreatorormaybenot avatar csepanda avatar dependabot[bot] avatar desdaemon avatar dkrutskikh avatar furaiev avatar fzyzcjy avatar grafovdenis avatar incendial avatar lsaudon avatar mariamelnik avatar nxtswitch avatar ookami-kb avatar orevial avatar rmortes avatar roman-petrov avatar san-smith avatar sinegovsky-ivan avatar tkreuder avatar valentinvignal avatar vlkonoshenko avatar xsahil03x avatar zmeggyesi avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

flutterando_metrics's Issues

- [FIX] Review dependencies

Description

While trying to use firebase_ui_auth and flutterando_metrics at the same time, I got a dependency errro because firebase_ui_auth already depends on http: ^1.0.0

I've created a fork from this project and updated the dependency for http by removing it, and got no errors.

Could you please review the dependencies needed for the package?

docs need some polish love

Hello,

I finally got it working by re-reading DCM docs to figure how to configure some of the lint rules as it is not in the docs...and also not in docs is how DCM structured the options command line arguments. Generally, you want this at the command line:

`dart run flutterando_metrics:metrics analyze lib --reporter=html --output-directory=reports/metrics

`

I appreciate the hard work the Flutterando group has done to rescue this neat tool.

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.