stezu/gulp-grandma

View on GitHub

Showing 7 of 7 total issues

Function reportErrors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function reportErrors(file, done) {

  return function callback(err, json) {

    if (err) {
Severity: Minor
Found in lib/util.js - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Unexpected newline before return statement.
Open

  return function callback(err, json) {
Severity: Minor
Found in lib/util.js by eslint

require an empty line before return statements (newline-before-return)

There is no hardfast rule about whether empty lines should precede return statements in JavaScript. However, clearly delineating where a function is returning can greatly increase the readability and clarity of the code. For example:

function foo(bar) {
  var baz = 'baz';
  if (!bar) {
    bar = baz;
    return bar;
  }
  return bar;
}

Adding newlines visibly separates the return statements from the previous lines, making it clear where the function exits and what value it returns:

function foo(bar) {
  var baz = 'baz';

  if (!bar) {
    bar = baz;

    return bar;
  }

  return bar;
}

Rule Details

This rule requires an empty line before return statements to increase code clarity, except when the return is alone inside a statement group (such as an if statement). In the latter case, the return statement does not need to be delineated by virtue of it being alone. Comments are ignored and do not count as empty lines.

Examples of incorrect code for this rule:

/*eslint newline-before-return: "error"*/

function foo() {

    return;
}

function foo(bar) {
    if (!bar) {

        return;
    }
}

function foo(bar) {
    if (!bar) {
        return;
    }
    return bar;
}

function foo() {

    // comment
    return;
}

function foo(bar) {
    if (!bar) {
        return;
    }
    /* multi-line
    comment */
    return bar;
}

Examples of correct code for this rule:

/*eslint newline-before-return: "error"*/

function foo() {
    return;
}

function foo(bar) {
    if (!bar) return;
}

function foo(bar) {
    if (!bar) { return };
}

function foo(bar) {
    if (!bar) {
        return;
    }
}

function foo(bar) {
    if (!bar) {
        return;
    }

    return bar;
}

When Not To Use It

You can safely disable this rule if you do not have any strict conventions about whitespace before return statements.

Related Rules

Definition for rule 'unicode-bom' was not found
Open

var gulp = require('gulp');
Severity: Minor
Found in gulpfile.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Definition for rule 'unicode-bom' was not found
Open

var path = require('path');
Severity: Minor
Found in lib/util.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Definition for rule 'unicode-bom' was not found
Open

var through = require('through2');
Severity: Minor
Found in lib/gulp-grandma.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Unexpected newline before return statement.
Open

  return new PluginError(_.extend({
Severity: Minor
Found in lib/util.js by eslint

require an empty line before return statements (newline-before-return)

There is no hardfast rule about whether empty lines should precede return statements in JavaScript. However, clearly delineating where a function is returning can greatly increase the readability and clarity of the code. For example:

function foo(bar) {
  var baz = 'baz';
  if (!bar) {
    bar = baz;
    return bar;
  }
  return bar;
}

Adding newlines visibly separates the return statements from the previous lines, making it clear where the function exits and what value it returns:

function foo(bar) {
  var baz = 'baz';

  if (!bar) {
    bar = baz;

    return bar;
  }

  return bar;
}

Rule Details

This rule requires an empty line before return statements to increase code clarity, except when the return is alone inside a statement group (such as an if statement). In the latter case, the return statement does not need to be delineated by virtue of it being alone. Comments are ignored and do not count as empty lines.

Examples of incorrect code for this rule:

/*eslint newline-before-return: "error"*/

function foo() {

    return;
}

function foo(bar) {
    if (!bar) {

        return;
    }
}

function foo(bar) {
    if (!bar) {
        return;
    }
    return bar;
}

function foo() {

    // comment
    return;
}

function foo(bar) {
    if (!bar) {
        return;
    }
    /* multi-line
    comment */
    return bar;
}

Examples of correct code for this rule:

/*eslint newline-before-return: "error"*/

function foo() {
    return;
}

function foo(bar) {
    if (!bar) return;
}

function foo(bar) {
    if (!bar) { return };
}

function foo(bar) {
    if (!bar) {
        return;
    }
}

function foo(bar) {
    if (!bar) {
        return;
    }

    return bar;
}

When Not To Use It

You can safely disable this rule if you do not have any strict conventions about whitespace before return statements.

Related Rules

TODO found
Open

TODO: Automagically generate API docs using JSDoc and put them somewhere in the repository.
Severity: Minor
Found in README.md by fixme
Severity
Category
Status
Source
Language