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/console/ConsoleSidebar.js b/front_end/console/ConsoleSidebar.js
index 8154fb9..d3292fc 100644
--- a/front_end/console/ConsoleSidebar.js
+++ b/front_end/console/ConsoleSidebar.js
@@ -67,16 +67,18 @@
}
clear() {
- for (const treeElement of this._treeElements)
+ for (const treeElement of this._treeElements) {
treeElement.clear();
+ }
}
/**
* @param {!Console.ConsoleViewMessage} viewMessage
*/
onMessageAdded(viewMessage) {
- for (const treeElement of this._treeElements)
+ for (const treeElement of this._treeElements) {
treeElement.onMessageAdded(viewMessage);
+ }
}
/**
@@ -84,8 +86,9 @@
* @return {boolean}
*/
shouldBeVisible(viewMessage) {
- if (!this._selectedTreeElement)
+ if (!this._selectedTreeElement) {
return true;
+ }
return this._selectedTreeElement._filter.shouldBeVisible(viewMessage);
}
@@ -113,8 +116,9 @@
this._filter = filter;
this._countElement = this.listItemElement.createChild('span', 'count');
const leadingIcons = [UI.Icon.create('largeicon-navigator-file')];
- if (badge)
+ if (badge) {
leadingIcons.push(badge);
+ }
this.setLeadingIcons(leadingIcons);
this._messageCount = 0;
}
@@ -183,8 +187,9 @@
const message = viewMessage.consoleMessage();
const shouldIncrementCounter = message.type !== SDK.ConsoleMessage.MessageType.Command &&
message.type !== SDK.ConsoleMessage.MessageType.Result && !message.isGroupMessage();
- if (!this._filter.shouldBeVisible(viewMessage) || !shouldIncrementCounter)
+ if (!this._filter.shouldBeVisible(viewMessage) || !shouldIncrementCounter) {
return;
+ }
const child = this._childElement(message.url);
child.incrementAndUpdateCounter();
this._messageCount++;
@@ -198,20 +203,23 @@
_childElement(url) {
const urlValue = url || null;
let child = this._urlTreeElements.get(urlValue);
- if (child)
+ if (child) {
return child;
+ }
const filter = this._filter.clone();
const parsedURL = urlValue ? urlValue.asParsedURL() : null;
- if (urlValue)
+ if (urlValue) {
filter.name = parsedURL ? parsedURL.displayName : urlValue;
- else
+ } else {
filter.name = Common.UIString('<other>');
+ }
filter.parsedFilters.push({key: Console.ConsoleFilter.FilterType.Url, text: urlValue, negative: false});
const badge = parsedURL ? this._badgePool.badgeForURL(parsedURL) : null;
child = new Console.ConsoleSidebar.URLGroupTreeElement(filter, badge);
- if (urlValue)
+ if (urlValue) {
child.tooltip = urlValue;
+ }
this._urlTreeElements.set(urlValue, child);
this.appendChild(child);
return child;