dart_code_metrics 2.4.0 copy "dart_code_metrics: ^2.4.0" to clipboard
dart_code_metrics: ^2.4.0 copied to clipboard

discontinued
outdated

Software analytics tool that helps developers analyse and improve software quality.

Build Status Coverage Status License Pub Version Dart SDK Verison Dart Platform

Dart code metrics #

Dart code metrics is a static analysis tool that helps improve code quality. It analyzes code metrics and provides additional rules for dart analyzer. Can be used as a command line tool, analyzer plugin or library.

Reports:

Output formats:

  • Plain terminal
  • GitHub
  • Codeclimate
  • HTML
  • JSON

Usage #

Analyzer plugin #

A plugin for the Dart analyzer library package providing additional rules from Dart code metrics.

  1. Add dependency to pubspec.yaml

    dev_dependencies:
      dart_code_metrics: ^2.4.0
    
  2. Add configuration to analysis_options.yaml

    analyzer:
      plugins:
        - dart_code_metrics
    
    dart_code_metrics:
      anti-patterns:
        - long-method
        - long-parameter-list
      metrics:
        cyclomatic-complexity: 20
        lines-of-executable-code: 50
        number-of-arguments: 4
        maximum-nesting: 5
      metrics-exclude:
        - test/**
      rules:
        - newline-before-return
        - no-boolean-literal-compare
        - no-empty-block
        - prefer-trailing-comma
        - prefer-conditional-expressions
        - no-equal-then-else
    

Command line tool #

Simple usage

pub global activate dart_code_metrics
metrics lib

Flutter usage

flutter pub global activate dart_code_metrics
flutter pub global run dart_code_metrics:metrics lib

Full usage

Usage: metrics [options...] <directories>
-h, --help                                             Print this usage information.


-r, --reporter=<console>                               The format of the output of the analysis
                                                       [console (default), github, json, html, codeclimate]
    --verbose                                          Additional flag for Console reporter
    --gitlab                                           Additional flag for Code Climate reporter to report in GitLab Code Quality format


    --cyclomatic-complexity=<20>                       Cyclomatic complexity threshold
    --lines-of-executable-code=<50>                    Lines of executable code threshold
    --number-of-arguments=<4>                          Number of arguments threshold
    --number-of-methods=<10>                           Number of methods threshold
    --maximum-nesting=<5>                              Maximum nesting threshold


    --root-folder=<./>                                 Root folder
                                                       (defaults to current directory)
    --ignore-files=<{/**.g.dart,/**.template.dart}>    Filepaths in Glob syntax to be ignored
                                                       (defaults to "{/**.g.dart,/**.template.dart}")


    --set-exit-on-violation-level=<warning>            Set exit code 2 if code violations same or higher level than selected are detected
                                                       [noted, warning, alarm]

If you want command line tool to check rules, you should add configuration to your analysis_options.yaml as listed in Analyzer plugin usage example.

Library #

See example/example.dart

Anti-Patterns #

Rules #

Common #

Intl specific #

Angular specific #

Contributing #

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

936
likes
0
pub points
99%
popularity

Publisher

verified publisherdcm.dev

Software analytics tool that helps developers analyse and improve software quality.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

analyzer, analyzer_plugin, ansicolor, args, code_checker, crypto, glob, html, meta, path, quiver, source_span, yaml

More

Packages that depend on dart_code_metrics