Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1347884 - Enable eslint cyclomatic complexity rule at existing le…
Browse files Browse the repository at this point in the history
…vels. r=jaws

Enable the rule with the maximums set to avoid current failures, except for test_form_autocomplete which is very
high (82). The levels are set per major area, with existing warnings being changed to errors.

MozReview-Commit-ID: 37M6Ry0Mr1c
  • Loading branch information
Standard8 committed Mar 16, 2017
1 parent dcb7c4a commit 9415a6a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 5 deletions.
9 changes: 9 additions & 0 deletions browser/components/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";

module.exports = {
rules: {
// XXX Bug 1326071 - This should be reduced down - probably to 20 or to
// be removed & synced with the toolkit/.eslintrc.js value.
"complexity": ["error", {"max": 69}],
}
};
3 changes: 1 addition & 2 deletions browser/components/migration/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = { // eslint-disable-line no-undef
"comma-dangle": "off",
"comma-spacing": ["warn", {"before": false, "after": true}],
"comma-style": ["warn", "last"],
// "complexity": "warn",
"complexity": ["error", {"max": 21}],
"consistent-return": "error",
//"curly": "error",
"dot-notation": "error",
Expand Down Expand Up @@ -79,4 +79,3 @@ module.exports = { // eslint-disable-line no-undef
"yoda": "error"
}
};

2 changes: 1 addition & 1 deletion browser/extensions/formautofill/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = { // eslint-disable-line no-undef
"comma-dangle": ["error", "always-multiline"],

// Warn about cyclomatic complexity in functions.
"complexity": "warn",
"complexity": ["error", {"max": 20}],

// Don't warn for inconsistent naming when capturing this (not so important
// with auto-binding fat arrow functions).
Expand Down
8 changes: 8 additions & 0 deletions toolkit/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ module.exports = {
// Commas at the end of the line not the start
// "comma-style": "error",

// Warn about cyclomatic complexity in functions.
// XXX Bug 1326071 - This should be reduced down - probably to 20.
"complexity": ["error", {"max": 48}],

// Don't require spaces around computed properties
"computed-property-spacing": ["error", "never"],

Expand Down Expand Up @@ -54,6 +58,10 @@ module.exports = {
// Unix linebreaks
"linebreak-style": ["error", "unix"],

// Don't enforce the maximum depth that blocks can be nested. The complexity
// rule is a better rule to check this.
"max-depth": "off",

// Always require parenthesis for new calls
// "new-parens": "error",

Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/narrate/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = { // eslint-disable-line no-undef
"comma-dangle": "off",
"comma-spacing": ["warn", {"before": false, "after": true}],
"comma-style": ["warn", "last"],
"complexity": "warn",
"complexity": ["error", {"max": 20}],
"consistent-return": "error",
"curly": "error",
"dot-location": ["warn", "property"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
* to listen to for when the search is complete.
* - some items still use setTimeout
*/
function runTest() {
function runTest() { // eslint-disable-line complexity
testNum++;

ok(true, "Starting test #" + testNum);
Expand Down
5 changes: 5 additions & 0 deletions toolkit/mozapps/extensions/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

module.exports = { // eslint-disable-line no-undef
"rules": {
// Warn about cyclomatic complexity in functions.
// XXX Bug 1326071 - This should be reduced down - probably to 20 or to
// be removed & synced with the toolkit/.eslintrc.js value.
"complexity": ["error", {"max": 60}],

// No using undeclared variables
"no-undef": "error",

Expand Down

0 comments on commit 9415a6a

Please sign in to comment.