Bug 955890 - Part 1: Fix DevTools JS warnings about some code paths not returning a value. r=rcampbell

This commit is contained in:
Chris Peterson 2013-12-31 19:28:42 -08:00
parent 8f8430cc24
commit 99ed2f11fc
6 changed files with 48 additions and 27 deletions

View File

@ -303,6 +303,7 @@ TabTarget.prototype = {
this._form = tab;
return true;
}
return false;
});
if (!this._form) {
this._form = aResponse.tabs[aResponse.selected];

View File

@ -35,6 +35,7 @@ loader.lazyGetter(this, "toolboxStrings", () => {
return bundle.formatStringFromName(name, args, args.length);
} catch (ex) {
Services.console.logStringMessage("Error reading '" + name + "'");
return null;
}
};
});
@ -585,6 +586,7 @@ Toolbox.prototype = {
deck.insertBefore(vbox, deck.childNodes[i]);
return true;
}
return false;
});
}
@ -867,7 +869,7 @@ Toolbox.prototype = {
*/
switchHost: function(hostType) {
if (hostType == this._host.type || !this._target.isLocalTab) {
return;
return null;
}
let newHost = this._createHost(hostType);
@ -1016,12 +1018,13 @@ Toolbox.prototype = {
// This is done after other destruction tasks since it may tear down
// fronts and the debugger transport which earlier destroy methods may
// require to complete.
if (this._target) {
let target = this._target;
this._target = null;
target.off("close", this.destroy);
return target.destroy();
if (!this._target) {
return null;
}
let target = this._target;
this._target = null;
target.off("close", this.destroy);
return target.destroy();
}).then(() => {
this.emit("destroyed");
// Free _host after the call to destroyed in order to let a chance

View File

@ -199,7 +199,7 @@ LayoutView.prototype = {
// If the view is dimmed, no need to do anything more.
if (this.dimmed) {
this.inspector.emit("layoutview-updated");
return;
return null;
}
for (let i in this.map) {
@ -247,7 +247,9 @@ LayoutView.prototype = {
}
this.inspector.emit("layoutview-updated");
return null;
});
this._lastRequest = lastRequest;
return this._lastRequest;
}

View File

@ -34,8 +34,10 @@ function doSearch(ctx, rev, query) {
let { cm } = ctx;
let state = getSearchState(cm);
if (state.query)
return searchNext(ctx, rev);
if (state.query) {
searchNext(ctx, rev);
return;
}
cm.operation(function () {
if (state.query) return;

View File

@ -145,8 +145,10 @@ function Editor(config) {
// Overwrite default config with user-provided, if needed.
Object.keys(config).forEach((k) => {
if (k != "extraKeys")
return this.config[k] = config[k];
if (k != "extraKeys") {
this.config[k] = config[k];
return;
}
if (!config.extraKeys)
return;
@ -161,11 +163,15 @@ function Editor(config) {
// indenting with tabs, insert one tab. Otherwise insert N
// whitespaces where N == indentUnit option.
this.config.extraKeys.Tab = (cm) => {
if (cm.somethingSelected())
return void cm.indentSelection("add");
if (cm.somethingSelected()) {
cm.indentSelection("add");
return;
}
if (this.config.indentWithTabs)
return void cm.replaceSelection("\t", "end", "+input");
if (this.config.indentWithTabs) {
cm.replaceSelection("\t", "end", "+input");
return;
}
var num = cm.getOption("indentUnit");
if (cm.getCursor().ch !== 0) num -= 1;
@ -250,8 +256,10 @@ Editor.prototype = {
let tail = { line: line, ch: this.getText(line).length };
// Shift-click on a gutter selects the whole line.
if (ev.shiftKey)
return void cm.setSelection(head, tail);
if (ev.shiftKey) {
cm.setSelection(head, tail);
return;
}
this.emit("gutterClick", line);
});
@ -325,12 +333,15 @@ Editor.prototype = {
replaceText: function (value, from, to) {
let cm = editors.get(this);
if (!from)
return void this.setText(value);
if (!from) {
this.setText(value);
return;
}
if (!to) {
let text = cm.getRange({ line: 0, ch: 0 }, from);
return void this.setText(text + value);
this.setText(text + value);
return;
}
cm.replaceRange(value, from, to);
@ -757,8 +768,10 @@ Editor.prototype = {
let cm = editors.get(this);
let ctx = { ed: this, cm: cm };
if (name === "initialize")
return void funcs[name](ctx);
if (name === "initialize") {
funcs[name](ctx);
return;
}
this[name] = funcs[name].bind(null, ctx);
});
@ -901,8 +914,10 @@ function controller(ed) {
"cmd_findAgain": "findNext"
};
if (map[cmd])
return void cm.execCommand(map[cmd]);
if (map[cmd]) {
cm.execCommand(map[cmd]);
return;
}
if (cmd == "cmd_gotoLine")
ed.jumpToLine(cm);

View File

@ -121,9 +121,7 @@ CssColor.prototype = {
},
get specialValue() {
if (SPECIALVALUES.has(this.authored)) {
return this.authored;
}
return SPECIALVALUES.has(this.authored) ? this.authored : null;
},
get name() {