DanielaValero/fit-commit-js

View on GitHub
lib/validators/util/util.js

Summary

Maintainability
A
1 hr
Test Coverage

Function comaStringToArray has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function comaStringToArray( stringToArray ) {
  let newArray = [];

  if ( stringToArray !== undefined ) {
    if ( R.is( String, stringToArray ) ) {
Severity: Minor
Found in lib/validators/util/util.js - About 1 hr 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

Assignment can be replaced with operator assignment.
Open

          count = count + matchedValues.length;
Severity: Minor
Found in lib/validators/util/util.js by eslint

require or disallow assignment operator shorthand where possible (operator-assignment)

JavaScript provides shorthand operators that combine variable assignment and some simple mathematical operations. For example, x = x + 4 can be shortened to x += 4. The supported shorthand forms are as follows:

Shorthand | Separate
-----------|------------
 x += y    | x = x + y
 x -= y    | x = x - y
 x *= y    | x = x * y
 x /= y    | x = x / y
 x %= y    | x = x % y
 x <<= y   | x = x << y
 x >>= y   | x = x >> y
 x >>>= y  | x = x >>> y
 x &= y    | x = x & y
 x ^= y    | x = x ^ y
 x |= y    | x = x | y

Rule Details

This rule requires or disallows assignment operator shorthand where possible.

Options

This rule has a single string option:

  • "always" (default) requires assignment operator shorthand where possible
  • "never" disallows assignment operator shorthand

always

Examples of incorrect code for this rule with the default "always" option:

/*eslint operator-assignment: ["error", "always"]*/

x = x + y;
x = y * x;
x[0] = x[0] / y;
x.y = x.y << z;

Examples of correct code for this rule with the default "always" option:

/*eslint operator-assignment: ["error", "always"]*/

x = y;
x += y;
x = y * z;
x = (x * y) * z;
x[0] /= y;
x[foo()] = x[foo()] % 2;
x = y + x; // `+` is not always commutative (e.g. x = "abc")

never

Examples of incorrect code for this rule with the "never" option:

/*eslint operator-assignment: ["error", "never"]*/

x *= y;
x ^= (y + z) / foo();

Examples of correct code for this rule with the "never" option:

/*eslint operator-assignment: ["error", "never"]*/

x = x + y;
x.y = x.y / a.b;

When Not To Use It

Use of operator assignment shorthand is a stylistic choice. Leaving this rule turned off would allow developers to choose which style is more readable on a case-by-case basis. Source: http://eslint.org/docs/rules/

Unary operator '++' used.
Open

          count++;
Severity: Minor
Found in lib/validators/util/util.js by eslint

disallow the unary operators ++ and -- (no-plusplus)

Because the unary ++ and -- operators are subject to automatic semicolon insertion, differences in whitespace can change semantics of source code.

var i = 10;
var j = 20;

i ++
j
// i = 11, j = 20
var i = 10;
var j = 20;

i
++
j
// i = 10, j = 21

Rule Details

This rule disallows the unary operators ++ and --.

Examples of incorrect code for this rule:

/*eslint no-plusplus: "error"*/

var foo = 0;
foo++;

var bar = 42;
bar--;

for (i = 0; i < l; i++) {
    return;
}

Examples of correct code for this rule:

/*eslint no-plusplus: "error"*/

var foo = 0;
foo += 1;

var bar = 42;
bar -= 1;

for (i = 0; i < l; i += 1) {
    return;
}

Options

This rule has an object option.

  • "allowForLoopAfterthoughts": true allows unary operators ++ and -- in the afterthought (final expression) of a for loop.

allowForLoopAfterthoughts

Examples of correct code for this rule with the { "allowForLoopAfterthoughts": true } option:

/*eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }]*/

for (i = 0; i < l; i++) {
    return;
}

for (i = 0; i < l; i--) {
    return;
}

Source: http://eslint.org/docs/rules/

There are no issues that match your filters.

Category
Status