codemetrics 1.0.0-alpha

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • new49

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 https://github.com/daniel-v/codemetrics.git
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

directories.

You can also install it as a global package:

pub global activate --source git https://github.com/daniel-v/codemetrics.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 README.md

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:


dependencies:
  codemetrics: "^1.0.0-alpha"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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';
  
Version Uploaded Documentation Archive
1.0.0-alpha Jun 2, 2018 Go to the documentation of codemetrics 1.0.0-alpha Download codemetrics 1.0.0-alpha archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
98 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
98 / 100
Overall score:
Weighted score of the above. [more]
49
Learn more about scoring.

Platforms

Detected platforms: Flutter, other

Primary library: package:codemetrics/codemetrics.dart with components: io, isolate.

Suggestions

  • Package is pre-release.

    Pre-release versions should be used with caution, their API may change in breaking ways.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 8 hints.

    Strong-mode analysis of lib/analyzer/src/cyclomatic_impl.dart gave the following hint:

    line: 117 col: 3
    This function declares a return type of 'Map<String, dynamic>', but doesn't end with a return statement.

    Strong-mode analysis of lib/cyclomatic/cyclomatic.dart gave the following hint:

    line: 5 col: 1
    'analyzer.src.generated.scanner' is deprecated and shouldn't be used.

    Similar analysis of the following files failed:

    • lib/reporter/reporter.dart (hint)
    • lib/reporter/src/html_reporter.dart (hint)
    • lib/reporter/src/json_reporter.dart (hint)
  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use codemetrics.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2-0-0-dev <2.0.0
analyzer ^0.31.1 0.31.1 0.32.1
args ^1.4.0 1.4.3
built_collection ^3.0.0 3.1.1
glob ^1.1.0 1.1.5
html ^0.13.3 0.13.3+1
path ^1.5.0 1.6.1
resource ^2.1.0 2.1.4
Transitive dependencies
async 2.0.7
charcode 1.1.1
cli_util 0.1.3
collection 1.14.10
convert 2.0.1
crypto 2.0.5
csslib 0.14.4
front_end 0.1.0-alpha.9 0.1.1
isolate 1.1.0 2.0.1
kernel 0.3.0-alpha.9 0.3.1
logging 0.11.3+1
matcher 0.12.3
meta 1.1.5
package_config 1.0.3
plugin 0.2.0+2
quiver 0.29.0+1
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+8
yaml 2.1.14
Dev dependencies
mockito any
test any