Bug 1436389 - Update complexity rules to adapt for the algorithm in the new ESLint. r?Mossop draft
authorMark Banner <standard8@mozilla.com>
Wed, 07 Feb 2018 16:16:09 +0000
changeset 752256 2a5e1644326e5526d50952c0f4e129a698aa9483
parent 752255 d103e80994b83b25baa95424de7ca1f598d3e100
child 752257 8611f12f80f2fa350afef441ef8bef7ad12a1d5f
push id98202
push userbmo:standard8@mozilla.com
push dateWed, 07 Feb 2018 19:25:55 +0000
reviewersMossop
bugs1436389
milestone60.0a1
Bug 1436389 - Update complexity rules to adapt for the algorithm in the new ESLint. r?Mossop MozReview-Commit-ID: 1LlfamNvBEM
accessible/.eslintrc.js
browser/.eslintrc.js
browser/base/content/tabbrowser.xml
browser/components/migration/.eslintrc.js
browser/extensions/formautofill/.eslintrc.js
devtools/.eslintrc.js
toolkit/.eslintrc.js
toolkit/components/passwordmgr/.eslintrc.js
toolkit/components/satchel/.eslintrc.js
toolkit/mozapps/extensions/.eslintrc.js
tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
--- a/accessible/.eslintrc.js
+++ b/accessible/.eslintrc.js
@@ -1,14 +1,14 @@
 "use strict";
 
 module.exports = {
   "rules": {
     // Warn about cyclomatic complexity in functions.
-    "complexity": ["error", 42],
+    "complexity": ["error", 47],
 
     // XXX These are rules that are enabled in the recommended configuration, but
     // disabled here due to failures when initially implemented. They should be
     // removed (and hence enabled) at some stage.
     "consistent-return": "off",
     "no-unexpected-multiline": "off",
     "no-unsafe-finally": "off",
     "no-useless-call": "off",
--- a/browser/.eslintrc.js
+++ b/browser/.eslintrc.js
@@ -1,15 +1,15 @@
 "use strict";
 
 module.exports = {
   "rules": {
     // XXX Bug 1326071 - This should be reduced down - probably to 20 or to
     // be removed & synced with the mozilla/recommended value.
-    "complexity": ["error", {"max": 40}],
+    "complexity": ["error", {"max": 44}],
 
     // Disallow empty statements. This will report an error for:
     // try { something(); } catch (e) {}
     // but will not report it for:
     // try { something(); } catch (e) { /* Silencing the error because ...*/ }
     // which is a valid use case.
     "no-empty": "error",
 
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -637,16 +637,17 @@
             onProgressChange64(aWebProgress, aRequest,
                                aCurSelfProgress, aMaxSelfProgress,
                                aCurTotalProgress, aMaxTotalProgress) {
               return this.onProgressChange(aWebProgress, aRequest,
                 aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress,
                 aMaxTotalProgress);
             },
 
+            /* eslint-disable complexity */
             onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
               if (!aRequest)
                 return;
 
               const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
               const nsIChannel = Components.interfaces.nsIChannel;
               let location, originalLocation;
               try {
@@ -838,16 +839,17 @@
                                  nsIWebProgressListener.STATE_STOP)) {
                 // reset cached temporary values at beginning and end
                 this.mMessage = "";
                 this.mTotalProgress = 0;
               }
               this.mStateFlags = aStateFlags;
               this.mStatus = aStatus;
             },
+            /* eslint-enable complexity */
 
             onLocationChange(aWebProgress, aRequest, aLocation,
                              aFlags) {
               // OnLocationChange is called for both the top-level content
               // and the subframes.
               let topLevel = aWebProgress.isTopLevel;
 
               if (topLevel) {
--- a/browser/components/migration/.eslintrc.js
+++ b/browser/components/migration/.eslintrc.js
@@ -1,15 +1,15 @@
 "use strict";
 
 module.exports = {
   "rules": {
     "block-scoped-var": "error",
     "comma-dangle": ["error", "always-multiline"],
-    "complexity": ["error", {"max": 21}],
+    "complexity": ["error", {"max": 22}],
     "indent-legacy": ["error", 2, {"SwitchCase": 1, "ArrayExpression": "first", "ObjectExpression": "first"}],
     "max-nested-callbacks": ["error", 3],
     "new-parens": "error",
     "no-extend-native": "error",
     "no-fallthrough": ["error", { "commentPattern": ".*[Ii]ntentional(?:ly)?\\s+fall(?:ing)?[\\s-]*through.*" }],
     "no-multi-str": "error",
     "no-return-assign": "error",
     "no-sequences": "error",
--- a/browser/extensions/formautofill/.eslintrc.js
+++ b/browser/extensions/formautofill/.eslintrc.js
@@ -53,17 +53,17 @@ module.exports = {
     // since only let and const are used, see "no-var").
     "block-scoped-var": "error",
 
     // Allow trailing commas for easy list extension.  Having them does not
     // impair readability, but also not required either.
     "comma-dangle": ["error", "always-multiline"],
 
     // Warn about cyclomatic complexity in functions.
-    "complexity": ["error", {"max": 20}],
+    "complexity": ["error", {"max": 26}],
 
     // Enforce dots on the next line with property name.
     "dot-location": ["error", "property"],
 
     // Maximum length of a line.
     // This should be 100 but too many lines were longer than that so set a
     // conservative upper bound for now.
     "max-len": ["error", 140],
--- a/devtools/.eslintrc.js
+++ b/devtools/.eslintrc.js
@@ -76,17 +76,17 @@ module.exports = {
     // start and end braces on the same line.
     "brace-style": ["error", "1tbs", {"allowSingleLine": false}],
     // Require camel case names
     "camelcase": "error",
     // Allow trailing commas for easy list extension.  Having them does not
     // impair readability, but also not required either.
     "comma-dangle": "off",
     // Warn about cyclomatic complexity in functions.
-    "complexity": ["error", 35],
+    "complexity": ["error", 53],
     // Don't warn for inconsistent naming when capturing this (not so important
     // with auto-binding fat arrow functions).
     "consistent-this": "off",
     // Enforce curly brace conventions for all control statements.
     "curly": "error",
     // Don't require a default case in switch statements. Avoid being forced to
     // add a bogus default when you know all possible cases are handled.
     "default-case": "off",
--- a/toolkit/.eslintrc.js
+++ b/toolkit/.eslintrc.js
@@ -1,11 +1,11 @@
 "use strict";
 
 module.exports = {
   rules: {
     // XXX Bug 1326071 - This should be reduced down - probably to 20 or to
     // be removed & synced with the mozilla/recommended value.
-    "complexity": ["error", 41],
+    "complexity": ["error", 44],
 
     "mozilla/no-task": "error",
   }
 };
--- a/toolkit/components/passwordmgr/.eslintrc.js
+++ b/toolkit/components/passwordmgr/.eslintrc.js
@@ -1,12 +1,12 @@
 "use strict";
 
 module.exports = {
 
   "rules": {
     // XXX Bug 1358949 - This should be reduced down - probably to 20 or to
     // be removed & synced with the mozilla/recommended value.
-    "complexity": ["error", 43],
+    "complexity": ["error", 56],
 
     "no-unused-vars": ["error", {"args": "none", "vars": "local", "varsIgnorePattern": "^(ids|ignored|unused)$"}],
   }
 };
--- a/toolkit/components/satchel/.eslintrc.js
+++ b/toolkit/components/satchel/.eslintrc.js
@@ -4,17 +4,17 @@ module.exports = {
   rules: {
     "mozilla/balanced-listeners": "error",
     "mozilla/var-only-at-top-level": "error",
 
     "array-bracket-spacing": ["error", "never"],
     "block-scoped-var": "error",
     "comma-dangle": ["error", "always-multiline"],
     complexity: ["error", {
-      max: 20,
+      max: 23,
     }],
     curly: ["error", "all"],
     "dot-location": ["error", "property"],
     "indent-legacy": ["error", 2, {
       SwitchCase: 1,
       CallExpression: {
         arguments: "first",
       },
--- a/toolkit/mozapps/extensions/.eslintrc.js
+++ b/toolkit/mozapps/extensions/.eslintrc.js
@@ -1,12 +1,12 @@
 "use strict";
 
 module.exports = {
   "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 mozilla/recommended value.
-    "complexity": ["error", {"max": 60}],
+    "complexity": ["error", {"max": 68}],
 
     "no-unused-vars": ["error", {"args": "none", "varsIgnorePattern": "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$"}],
   }
 };
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
@@ -114,17 +114,17 @@ module.exports = {
     // No space before always a space after a comma
     "comma-spacing": ["error", {"after": true, "before": false}],
 
     // Commas at the end of the line not the start
     "comma-style": "error",
 
     // Warn about cyclomatic complexity in functions.
     // XXX Get this down to 20?
-    "complexity": ["error", 32],
+    "complexity": ["error", 34],
 
     // Don't require spaces around computed properties
     "computed-property-spacing": ["error", "never"],
 
     // Functions must always return something or nothing
     "consistent-return": "error",
 
     // Require braces around blocks that start a new line