Skip to content

TCATools/common-dart-code-metrics-1.7.1

Repository files navigation

Build Status License Pub Version Dart SDK Verison Dart Platform

The Dart command line tool which helps to improve code quality

Reports:

Output formats:

  • Plain terminal
  • JSON
  • HTML
  • Codeclimate

Simple usage:

pub global activate 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), json, html, codeclimate]

    --cyclomatic-complexity=<20>                       Cyclomatic complexity threshold
                                                       (defaults to "20")

    --lines-of-code=<50>                               Lines of code threshold
                                                       (defaults to "50")

    --number-of-arguments=<4>                          Number of arguments threshold
                                                       (defaults to "4")

    --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}")

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

Use as library

See example/example.dart

Use as analyzer plugin

A plugin for the Dart analyzer library package providing rules support from dart_code_metrics.

Usage

  1. Add dependency to pubspec.yaml

    dev_dependencies:
      dart_code_metrics: ^1.5.1
  2. Add settings to analysis_options.yaml

    analyzer:
      plugins:
        - dart_code_metrics
    
    dart_code_metrics:
      metrics:
        cyclomatic-complexity: 20
        number-of-arguments: 4
      metrics-exclude:
        - test/**
      rules:
        - newline-before-return
        - no-boolean-literal-compare
        - no-empty-block
        - prefer-trailing-comma-for-collection

Rules

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published