diff --git a/lib/rules/complexity.js b/lib/rules/complexity.js index e0313fa78f1..323fdbff8ea 100644 --- a/lib/rules/complexity.js +++ b/lib/rules/complexity.js @@ -126,20 +126,6 @@ module.exports = { } } - /** - * Increase the logical path complexity in context - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function increaseLogicalComplexity(node) { - - // Avoiding && - if (node.operator === "||") { - increaseComplexity(); - } - } - //-------------------------------------------------------------------------- // Public API //-------------------------------------------------------------------------- @@ -154,7 +140,7 @@ module.exports = { CatchClause: increaseComplexity, ConditionalExpression: increaseComplexity, - LogicalExpression: increaseLogicalComplexity, + LogicalExpression: increaseComplexity, ForStatement: increaseComplexity, ForInStatement: increaseComplexity, ForOfStatement: increaseComplexity, diff --git a/tests/lib/rules/complexity.js b/tests/lib/rules/complexity.js index b1b031173dd..9e2b5d92b5d 100644 --- a/tests/lib/rules/complexity.js +++ b/tests/lib/rules/complexity.js @@ -51,7 +51,7 @@ ruleTester.run("complexity", rule, { { code: "function a(x) {return x === 4 ? 3 : 5;}", options: [2] }, { code: "function a(x) {return x === 4 ? 3 : (x === 3 ? 2 : 1);}", options: [3] }, { code: "function a(x) {return x || 4;}", options: [2] }, - { code: "function a(x) {x && 4;}", options: [1] }, + { code: "function a(x) {x && 4;}", options: [2] }, { code: "function a(x) {switch(x){case 1: 1; break; case 2: 2; break; default: 3;}}", options: [3] }, { code: "function a(x) {switch(x){case 1: 1; break; case 2: 2; break; default: if(x == 'foo') {5;};}}", options: [4] }, { code: "function a(x) {while(true) {'foo';}}", options: [2] }, @@ -80,7 +80,7 @@ ruleTester.run("complexity", rule, { { code: "function a(x) {return x === 4 ? 3 : 5;}", options: [1], errors: 1 }, { code: "function a(x) {return x === 4 ? 3 : (x === 3 ? 2 : 1);}", options: [2], errors: 1 }, { code: "function a(x) {return x || 4;}", options: [1], errors: 1 }, - { code: "function a(x) {x && 4;}", options: [0], errors: 1 }, + { code: "function a(x) {x && 4;}", options: [1], errors: 1 }, { code: "function a(x) {switch(x){case 1: 1; break; case 2: 2; break; default: 3;}}", options: [2], errors: 1 }, { code: "function a(x) {switch(x){case 1: 1; break; case 2: 2; break; default: if(x == 'foo') {5;};}}", options: [3], errors: 1 }, { code: "function a(x) {while(true) {'foo';}}", options: [1], errors: 1 },