Bug 1330791 - Enable no-else-return rule for eslint in /services and fix associated errors. r=markh

MozReview-Commit-ID: 7Os4uZQCDox

--HG--
extra : rebase_source : 8d14b02c97b8024268b5625a633393e75efed117
This commit is contained in:
Jared Wein 2017-01-12 18:14:54 -05:00
parent f60caed47a
commit d3dba448bd
13 changed files with 46 additions and 61 deletions

View File

@ -11,7 +11,6 @@ module.exports = {
"brace-style": "warn",
"consistent-return": "warn",
"no-cond-assign": "warn",
"no-else-return": "warn",
"no-ex-assign": "warn",
"no-func-assign": "warn",
"no-native-reassign": "warn",

View File

@ -92,8 +92,7 @@ StringBundle.prototype = {
get(key, args) {
if (args)
return this.stringBundle.formatStringFromName(key, args, args.length);
else
return this.stringBundle.GetStringFromName(key);
return this.stringBundle.GetStringFromName(key);
},
/**

View File

@ -260,12 +260,11 @@ this.CryptoUtils = {
forceJS) {
if (Svc.Crypto.deriveKeyFromPassphrase && !forceJS) {
return Svc.Crypto.deriveKeyFromPassphrase(passphrase, salt, keyLength);
} else {
// Fall back to JS implementation.
// 4096 is hardcoded in WeaveCrypto, so do so here.
return CryptoUtils.pbkdf2Generate(passphrase, atob(salt), 4096,
keyLength);
}
// Fall back to JS implementation.
// 4096 is hardcoded in WeaveCrypto, so do so here.
return CryptoUtils.pbkdf2Generate(passphrase, atob(salt), 4096,
keyLength);
},
/**

View File

@ -30,9 +30,8 @@ function deepEqual(actual, expected) {
return true;
} else if (typeof actual != "object" && typeof expected != "object") {
return actual == expected;
} else {
return objEquiv(actual, expected);
}
return objEquiv(actual, expected);
}
function isUndefinedOrNull(value) {

View File

@ -161,14 +161,13 @@ this.FxAccountsProfileClient.prototype = {
// "response.success" means status code is 200
if (request.response.success) {
return resolve(body);
} else {
return reject(new FxAccountsProfileClientError({
error: body.error || ERROR_UNKNOWN,
errno: body.errno || ERRNO_UNKNOWN_ERROR,
code: request.response.status,
message: body.message || body,
}));
}
return reject(new FxAccountsProfileClientError({
error: body.error || ERROR_UNKNOWN,
errno: body.errno || ERRNO_UNKNOWN_ERROR,
code: request.response.status,
message: body.message || body,
}));
};
if (method === "GET") {

View File

@ -491,9 +491,8 @@ function validationHelper(params, expected) {
} catch (e) {
if (typeof expected === "string") {
return do_check_eq(e.toString(), expected);
} else {
return do_check_true(e.toString().match(expected));
}
return do_check_true(e.toString().match(expected));
}
throw new Error("Validation helper error");
}

View File

@ -296,9 +296,8 @@ AddonsReconciler.prototype = {
if (element == listener) {
this._log.debug("Removing change listener.");
return false;
} else {
return true;
}
return true;
}.bind(this));
},

View File

@ -314,9 +314,8 @@ AddonUtilsInternal.prototype = {
if (param.indexOf("src=") == 0) {
return "src=sync";
} else {
return param;
}
return param;
});
addon.sourceURI.query = params.join("&");

View File

@ -407,9 +407,8 @@ this.BrowserIDManager.prototype = {
// field directly and instead call a isSyncKeyValid() function
// that we can override.
return "99999999999999999999999999";
} else {
return null;
}
return null;
},
set syncKey(value) {

View File

@ -662,11 +662,9 @@ Sync11Service.prototype = {
// Last-ditch case.
return false;
} else {
// No update needed: we're good!
return true;
}
// No update needed: we're good!
return true;
} catch (ex) {
// This means no keys are present, or there's a network error.
this._log.debug("Failed to fetch and verify keys", ex);
@ -1222,20 +1220,19 @@ Sync11Service.prototype = {
return false;
}
return true;
} else {
if (!this.upgradeSyncKey(meta.payload.syncID)) {
this._log.warn("Failed to upgrade sync key. Failing remote setup.");
return false;
}
if (!this.verifyAndFetchSymmetricKeys(infoResponse)) {
this._log.warn("Failed to fetch symmetric keys. Failing remote setup.");
return false;
}
return true;
}
if (!this.upgradeSyncKey(meta.payload.syncID)) {
this._log.warn("Failed to upgrade sync key. Failing remote setup.");
return false;
}
if (!this.verifyAndFetchSymmetricKeys(infoResponse)) {
this._log.warn("Failed to fetch symmetric keys. Failing remote setup.");
return false;
}
return true;
},
/**

View File

@ -473,20 +473,19 @@ add_task(async function test_refreshCertificateOn401() {
headers: {"content-type": "application/json"},
body: JSON.stringify({}),
};
} else {
didReturn200 = true;
return {
status: 200,
headers: {"content-type": "application/json"},
body: JSON.stringify({
id: "id",
key: "key",
api_endpoint: "http://example.com/",
uid: "uid",
duration: 300,
})
};
}
didReturn200 = true;
return {
status: 200,
headers: {"content-type": "application/json"},
body: JSON.stringify({
id: "id",
key: "key",
api_endpoint: "http://example.com/",
uid: "uid",
duration: 300,
})
};
});
browseridManager._tokenServerClient = mockTSC;

View File

@ -217,9 +217,8 @@ PlacesItem.prototype = {
folder_parts[i]);
if (subfolder_id == -1) {
return -1;
} else {
folder_id = subfolder_id;
}
folder_id = subfolder_id;
}
return folder_id;
},

View File

@ -167,12 +167,11 @@ FormData.prototype = {
// this item doesn't exist yet in the db, so we need to insert it
return FormDB.insertValue(this.fieldname, this.value,
this.hours_to_us(this.date));
} else {
/* Right now, we ignore this case. If bug 552531 is ever fixed,
we might need to add code here to update the firstUsed or
lastUsed fields, as appropriate.
*/
}
/* Right now, we ignore this case. If bug 552531 is ever fixed,
we might need to add code here to update the firstUsed or
lastUsed fields, as appropriate.
*/
});
},