Always add braces to single-line if-statements
The Chromium/Google style guides does not enforce curly braces for
single-line if-statements, but does strongly recommend doing so. Adding
braces will improve code readability, by visually separating code
blocks. This will also prevent issues where accidental additions are
pushed to the "else"-clause instead of in the if-block.
This CL also updates the presubmit `eslint` to run the fix with the
correct configuration. It will now fix all issues it can fix.
Change-Id: I4b616f21a99393f168dec743c0bcbdc7f5db04a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1821526
Commit-Queue: Tim Van der Lippe <[email protected]>
Reviewed-by: Yang Guo <[email protected]>
Reviewed-by: Jeff Fisher <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#701070}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 7e0bdbe2d7f9fc2386bfaefda3cc29c66ccc18f9
diff --git a/front_end/ui/ActionRegistry.js b/front_end/ui/ActionRegistry.js
index 32a5f3f..a4b37a1 100644
--- a/front_end/ui/ActionRegistry.js
+++ b/front_end/ui/ActionRegistry.js
@@ -19,17 +19,19 @@
* @this {UI.ActionRegistry}
*/
function registerExtension(extension) {
- if (!extension.canInstantiate())
+ if (!extension.canInstantiate()) {
return;
+ }
const actionId = extension.descriptor()['actionId'];
console.assert(actionId);
console.assert(!this._actionsById.get(actionId));
const action = new UI.Action(extension);
- if (!action.category() || action.title())
+ if (!action.category() || action.title()) {
this._actionsById.set(actionId, action);
- else
+ } else {
console.error(`Category actions require a title for command menu: ${actionId}`);
+ }
}
}
@@ -49,8 +51,9 @@
const extensions = [];
actionIds.forEach(function(actionId) {
const action = this._actionsById.get(actionId);
- if (action)
+ if (action) {
extensions.push(action._extension);
+ }
}, this);
return context.applicableExtensions(extensions).valuesArray().map(extensionToAction.bind(this));
@@ -137,8 +140,9 @@
* @param {boolean} enabled
*/
setEnabled(enabled) {
- if (this._enabled === enabled)
+ if (this._enabled === enabled) {
return;
+ }
this._enabled = enabled;
this.dispatchEventToListeners(UI.Action.Events.Enabled, enabled);
@@ -180,8 +184,9 @@
const options = this._extension.descriptor()['options'];
if (options) {
for (const pair of options) {
- if (pair['value'] !== this._toggled)
+ if (pair['value'] !== this._toggled) {
title = pair['title'];
+ }
}
}
return ls(title);
@@ -199,8 +204,9 @@
*/
setToggled(toggled) {
console.assert(this.toggleable(), 'Shouldn\'t be toggling an untoggleable action', this.id());
- if (this._toggled === toggled)
+ if (this._toggled === toggled) {
return;
+ }
this._toggled = toggled;
this.dispatchEventToListeners(UI.Action.Events.Toggled, toggled);