dart_coco 1.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 64

Dart-CoCo Coverage #

Dart-CoCo for Dart is a simple command line utility providing insights into:

  • quality of code by using static analysis of the code to calculate cyclomatic complexity value.
  • coverage information generated from lcov.info file.

How to use #

In pubspec.yaml add a development dependency:

dev-dependencies:
    dart_coco: ^1.0.6

From command line execute:

flutter pub run dart_coco --html

If you run flutter test --coverage before executing Dart-CoCo, tool will include coverage data gathered inside coverage/lcov.info

Directly from GitHub clone:

git clone https://github.com/alexZaicev/dart-coco.git
cd dart-coco
pub get

dart bin/dart_coco.dart --html -r path/to/lib -o report --lcov path/to/lcov.info

Report example #

Report index.html page:

Index Report Page

Coverage report collected from LCOV:

Coverage Report Page

Options #

  • --root (-r) - package root containing modules with dart files to analyse
  • --output (-o) - report output directory location
  • --html - HTML report format
  • --json - JSON report format
  • --help (-h) - Help page
  • --verbose (-v) - Enable detailed logging
  • --lcov - path to LCOV coverage report file

1.0.6 #

1.0.5 #

1.0.4+1 #

1.0.4 #

1.0.3 #

1.0.2 #

  • Removing unnecessary new keywords
  • Refactoring comments
  • Dart code formatting

1.0.1 #

  • Initial version created

example/lib/main.dart

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate dart_coco

2. Use it

The package has the following executables:


$ dart_coco

Use this package as a library

1. Depend on it

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


dependencies:
  dart_coco: ^1.0.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:dart_coco/dart_coco.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
29
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Analysis suggestions

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:dart_coco/dart_coco.dartpackage:dart_coco/reporter/reporter.dartpackage:dart_coco/analyzer/analyzer.dartpackage:dart_coco/cyclomatic/cyclomatic.dartpackage:analyzer/dart/ast/ast.dartpackage:analyzer/src/generated/utilities_dart.dartpackage:analyzer/src/dart/element/element.dartpackage:analyzer/src/summary2/reference.dartpackage:analyzer/dart/element/element.dartpackage:analyzer/src/task/api/model.dartpackage:analyzer/src/generated/source.dartpackage:analyzer/src/generated/source_io.dartpackage:analyzer/src/generated/java_io.dartdart:io

Package not compatible with runtime web

Because of the import of dart:io via the import chain package:dart_coco/dart_coco.dartpackage:dart_coco/reporter/reporter.dartpackage:dart_coco/analyzer/analyzer.dartpackage:dart_coco/cyclomatic/cyclomatic.dartpackage:analyzer/dart/ast/ast.dartpackage:analyzer/src/generated/utilities_dart.dartpackage:analyzer/src/dart/element/element.dartpackage:analyzer/src/summary2/reference.dartpackage:analyzer/dart/element/element.dartpackage:analyzer/src/task/api/model.dartpackage:analyzer/src/generated/source.dartpackage:analyzer/src/generated/source_io.dartpackage:analyzer/src/generated/java_io.dartdart:io

Health issues and suggestions

Document public APIs. (-0.56 points)

332 out of 337 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
analyzer ^0.39.7 0.39.11
args ^1.5.2 1.6.0
built_collection ^4.3.2 4.3.2
enum_to_string ^1.0.9 1.0.9
glob ^1.2.0 1.2.0
html ^0.14.0+3 0.14.0+3
intl ^0.16.0 0.16.1
path ^1.6.4 1.7.0
resource ^2.1.6 2.1.7
Transitive dependencies
_fe_analyzer_shared 5.0.0
async 2.4.1
charcode 1.1.3
collection 1.14.13
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
js 0.6.2
matcher 0.12.8
meta 1.1.8
node_interop 1.1.1
node_io 1.1.1
package_config 1.9.3
pedantic 1.9.0 1.9.1
pub_semver 1.4.4
quiver 2.1.3
source_span 1.7.0
stack_trace 1.9.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0
watcher 0.9.7+15
yaml 2.2.1
Dev dependencies
mockito ^4.1.1
test ^1.14.2
test_coverage ^0.4.1