Bug 1356322 - [eslint] Reduce the cyclomatic complexity in browser/components/ r?jaws
This patch causes browser/components/ to use the same max complexity as in
browser/ (currently 42). There are only 4 functions which exceed this value;
they've been annotated to disable the eslint complexity warning. This will
help us to catch any new functions in browser/components/ that are too
complex.
MozReview-Commit-ID: FGZxdoVL4mY
deleted file mode 100644
--- a/browser/components/.eslintrc.js
+++ /dev/null
@@ -1,9 +0,0 @@
-"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", 61],
- }
-};
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -196,16 +196,17 @@ BrowserGlue.prototype = {
}
delay = delay <= MAX_DELAY ? delay : MAX_DELAY;
Cu.import("resource://services-sync/main.js");
Weave.Service.scheduler.delayedAutoConnect(delay);
},
// nsIObserver implementation
+ // eslint-disable-next-line complexity
observe: function BG_observe(subject, topic, data) {
switch (topic) {
case "notifications-open-settings":
this._openPreferences("privacy");
break;
case "prefservice:after-app-defaults":
this._onAppDefaults();
break;
@@ -1567,16 +1568,17 @@ BrowserGlue.prototype = {
let clickCallback = (subject, topic, data) => {
if (topic != "alertclickcallback")
return;
this._openPreferences("sync");
}
AlertsService.showAlertNotification(null, title, body, true, null, clickCallback);
},
+ // eslint-disable-next-line complexity
_migrateUI: function BG__migrateUI() {
const UI_VERSION = 44;
const BROWSER_DOCURL = "chrome://browser/content/browser.xul";
let currentUIVersion;
if (Services.prefs.prefHasUserValue("browser.migration.version")) {
currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
} else {
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -3233,16 +3233,17 @@ var SessionStoreInternal = {
* JS object
* @param aOptions
* {overwriteTabs: true} to overwrite existing tabs w/ new ones
* {isFollowUp: true} if this is not the restoration of the 1st window
* {firstWindow: true} if this is the first non-private window we're
* restoring in this session, that might open an
* external link as well
*/
+ // eslint-disable-next-line complexity
restoreWindow: function ssi_restoreWindow(aWindow, winData, aOptions = {}) {
let overwriteTabs = aOptions && aOptions.overwriteTabs;
let isFollowUp = aOptions && aOptions.isFollowUp;
let firstWindow = aOptions && aOptions.firstWindow;
// See SessionStoreInternal.restoreTabs for a description of what
// selectTab represents.
let selectTab = (overwriteTabs ? parseInt(winData.selected || 1, 10) : 0);
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -289,16 +289,17 @@ this.UITour = {
Services.prefs.clearUserPref(PREF_SEENPAGEIDS);
return;
}
Services.prefs.setCharPref(PREF_SEENPAGEIDS,
JSON.stringify([...this.seenPageIDs]));
},
+ // eslint-disable-next-line complexity
onPageEvent(aMessage, aEvent) {
let browser = aMessage.target;
let window = browser.ownerGlobal;
// Does the window have tabs? We need to make sure since windowless browsers do
// not have tabs.
if (!window.gBrowser) {
// When using windowless browsers we don't have a valid |window|. If that's the case,