gulp-limit-complexity

    0.5.3 • Public • Published

    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
                    }
                }
            }));
    });
     

    Install

    npm i gulp-limit-complexity

    DownloadsWeekly Downloads

    0

    Version

    0.5.3

    License

    ISC

    Last publish

    Collaborators

    • danestuckel