glc

gulp-limit-complexity

Limit complexity in JavaScript projects by failing build if function exceed limits

Showing:

Popularity

Downloads/wk

6

GitHub Stars

0

Maintenance

Last Commit

7yrs ago

Contributors

1

Package

Dependencies

6

Size (min+gzip)

59.1KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

gulp limit complexity

Limit complexity in JavaScript projects by failing build if function exceed limits.

Build Status

Code Climate

Coverage Status

Dependencies

NPM version

Using Mozilla's JavaScript tree mapper to parse functions, and escomplex to calculate the complexity of every function. This is mainly useful for keeping third-party developers honest and to a certain level of quality. Can also be useful on large teams as a kind of contract for how complex or readable their code must be.

##Install


npm install gulp-limit-complexity

##Example


var limitComplexity = require('gulp-limit-complexity');

gulp.task('complexity', function () {
    return gulp.src(path.src.js)
        .pipe(limitComplexity({
            cyclomatic: 4, //maximum of 4 code paths through any function
            halstead: {
                vocabulary: 10 //maximum of ten for vocabulary
            }
        }));
});

##Another example


var limitComplexity = require('gulp-limit-complexity');

gulp.task('complexity', function () {
    return gulp.src(path.src.js)
        .pipe(limitComplexity({
            halstead: {
                difficulty: 14 //difficulty represents readability
            },
            params: 3 //functions can only have a maximum of three parameters
        }));
});

##Another example


var limitComplexity = require('gulp-limit-complexity');

gulp.task('complexity', function () {
    return gulp.src(path.src.js)
        .pipe(limitComplexity({
            halstead: {
                operands {
                    distinct: 6 //only six unique operands each function
                }
            }
        }));
});

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100