codemetrics 1.0.0-alpha+1

  • Readme
  • Changelog
  • Installing
  • 0

Codemetrics #

Codemetrics for Dart is a simple command line utility that provides some insight into the "quality" of code.

It uses static analysis of the code to determine:

and provides different reporting serialization formats:

  • json
  • html

How to use #

For now, there is no pub package for this project, so you have to clone it

git clone
cd codemetrics
pub get
cd bin; dart codemetrics.dart --analysis-root=/path/to/your/package

Internally, Codemetrics for Dart uses glob package to find dart files within the --analysis-root folder with the **.dart glob. It will exclude all dart files in:

  • packages
  • .pub


You can also install it as a global package:

pub global activate --source git

Executable name is dart-codemetrics

Reporting options #

For html output use the --report-format=html and for JSON use --report-format=json. A full command could look like this:

dart bin/codemetrics.dart --analysis-root=/path/to/your/package --report-format=html > /tmp/test.html

Looking for contributors #

There are number of areas you can contribute to this project:

  • code reviews: I always welcome criticism to my code, esp. when it comes to the analysis package
  • documentation: the code is mostly undocumented
  • tests: there are little if any tests written for this package
  • funtionality: if you feel contributing with some functionality, let me know!

Changelog for CodeMetrics dart package #

For a high level overview of what CodeMetrics is, please read

v1.0.0-alpha+1 #

  • Fixed a typo in the name of executable. It spells codemetrics now. Command line usage: pub global run codemetrics or dart-codemetrics if Pub's bin folder is added to PATH
  • Update dependencies to be compatible with 2.0.0-dev.67.0

v1.0.0-alpha - Prepping for pub release #

v0.0.2 - Dart 2 updates #

v0.0.1 - Initial release #

Please keep in mind, this is the first preview release of the software, things might break or might not function as intended

  • support for calculating cyclomatic complexity of individual files or entire packages
  • support for configuration options for what is included in the complexity calculations
    • predefined configurations with similar settings to already known tools such as CodePro
  • export detailed and aggregated statistics to JSON
    • provides per-method/per-function detailed analysis
    • provides an aggregated statistics for all the methods/functions

Use this package as an executable

1. Install it

You can install the package from the command line:

$ pub global activate codemetrics

2. Use it

The package has the following executables:

$ dart-codemetrics

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  codemetrics: ^1.0.0-alpha+1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:codemetrics/codemetrics.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2-0-0-dev <2.0.0