1.0.3 • Published 5 years ago

grunt-escomplex-report v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

grunt-escomplex-report

NPM version Build Status Coverage Status Dependency Status devDependency Status Built with Grunt

NPM Downloads

Software complexity analysis for JavaScript projects.

Table of Contents

Installation

You need node >= 4, npm and grunt >= 0.4.5 installed and your project build managed by a Gruntfile with the necessary modules listed in package.json. If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

$ npm install grunt-escomplex-report --save-dev

Configuration

Add the escomplex-report entry with the task configuration to the options of the grunt.initConfig method:

grunt.initConfig({
  'escomplex-report': {
    all: {
      src: ['../../src/**/!(*.spec)+(.js)'],
      options: {
        output: 'complexity.txt'
      }
    }
  }
});

Default options support the most usual usage scenario:

'escomplex-report': {
  options: {
    format: 'plain',
    output: null,
    onlyfailures: true,
    silent: false,
    newmi: true,
    force: false
  },
  ...
}

Task Options

force

Type: Boolean Default value: false

If set to true, it suppresses complexity failures. Instead of making the Grunt fail, the errors will be written only to the console.

format:

Type: String Default value: null

Specify the output format of the report.

output

Type: String Default value: null

Specify an output file for the report.

ignoreerrors

Type: Boolean Default value: false

Ignore parser errors.

maxfiles

Type: Number Default value: 1024

Specify the maximum number of files to have open at any point.

maxfod

Type: Number Default value: null

Specify the per-project first-order density threshold.

maxcost

Type: Number Default value: null

Specify the per-project change cost threshold.

maxsize

Type: Number Default value: null

Specify the per-project core size threshold.

minmi

Type: Number Default value: null

Specify the per-module maintainability index threshold.

maxcyc

Type: Number Default value: null

Specify the per-function cyclomatic complexity threshold.

maxcycden

Type: Number Default value: null

Specify the per-function cyclomatic complexity density threshold.

maxhd

Type: Number Default value: null

Specify the per-function Halstead difficulty threshold.

maxhv

Type: Number Default value: null

Specify the per-function Halstead volume threshold.

maxhe

Type: Number Default value: null

Specify the per-function Halstead effort threshold.

onlyfailures

Type: Boolean Default value: true

Report only modules and functions, which failed the complexity checks.

silent

Type: Boolean Default value: false

Do not write any output to the console.

logicalor

Type: Boolean Default value: false

Cisregard operator || as source of cyclomatic complexity.

switchcase

Type: Boolean Default value: false

Disregard switch statements as source of cyclomatic complexity.

forin

Type: Boolean Default value: false

Treat for...in statements as source of cyclomatic complexity.

trycatch

Type: Boolean Default value: false

Treat catch clauses as source of cyclomatic complexity.

newmi

Type: Boolean Default value: true

Use the Microsoft-variant maintainability index (scale of 0 to 100).

nocoresize

Type: Boolean Default value: false

Do not calculate core size or visibility matrix.

Task Data

src

Type: String|Array|Object Default value: []

Source files to have their complexity checked. Grunt file list specification.

Loading

Load the plugin in Gruntfile.js:

grunt.loadNpmTasks('grunt-escomplex-report');

Build

Call the escomplex-report task:

$ grunt escomplex-report

or integrate it to your build sequence in Gruntfile.js:

grunt.registerTask('default', ['escomplex-report', ...]);

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 2018-05-03 v1.0.1 Supported installation if NPM proxy cache is used
  • 2018-04-27 v1.0.0 Dropped support of Node.js 4
  • 2018-01-29 v0.0.1 Initial release

License

Copyright (c) 2018-2019 Ferdinand Prantl

Licensed under the MIT license.