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 <tvanderlippe@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Jeff Fisher <jeffish@microsoft.com>
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/audits/AuditsStatusView.js b/front_end/audits/AuditsStatusView.js
index c480e78..c8a67a5 100644
--- a/front_end/audits/AuditsStatusView.js
+++ b/front_end/audits/AuditsStatusView.js
@@ -96,8 +96,9 @@
}
hide() {
- if (this._dialog.isShowing())
+ if (this._dialog.isShowing()) {
this._dialog.hide();
+ }
}
/**
@@ -111,8 +112,9 @@
* @param {?string} message
*/
updateStatus(message) {
- if (!message || !this._statusText)
+ if (!message || !this._statusText) {
return;
+ }
if (message.startsWith('Cancel')) {
this._commitTextChange(Common.UIString('Cancelling\u2026'));
@@ -142,8 +144,9 @@
* @return {string}
*/
_getMessageForPhase(phase) {
- if (phase.message)
+ if (phase.message) {
return phase.message;
+ }
const deviceType = Audits.RuntimeSettings.find(item => item.setting.name === 'audits.device_type').setting.get();
const throttling = Audits.RuntimeSettings.find(item => item.setting.name === 'audits.throttling').setting.get();
@@ -163,15 +166,17 @@
}
_resetProgressBarClasses() {
- if (!this._progressBar)
+ if (!this._progressBar) {
return;
+ }
this._progressBar.className = 'audits-progress-bar';
}
_scheduleFastFactCheck() {
- if (!this._currentPhase || this._scheduledFastFactTimeout)
+ if (!this._currentPhase || this._scheduledFastFactTimeout) {
return;
+ }
this._scheduledFastFactTimeout = setTimeout(() => {
this._updateFastFactIfNecessary();
@@ -183,10 +188,12 @@
_updateFastFactIfNecessary() {
const now = performance.now();
- if (now - this._textChangedAt < Audits.StatusView.fastFactRotationInterval)
+ if (now - this._textChangedAt < Audits.StatusView.fastFactRotationInterval) {
return;
- if (!this._fastFactsQueued.length)
+ }
+ if (!this._fastFactsQueued.length) {
return;
+ }
const fastFactIndex = Math.floor(Math.random() * this._fastFactsQueued.length);
this._scheduleTextChange(ls`\ud83d\udca1 ${this._fastFactsQueued[fastFactIndex]}`);
@@ -197,8 +204,9 @@
* @param {string} text
*/
_commitTextChange(text) {
- if (!this._statusText)
+ if (!this._statusText) {
return;
+ }
this._textChangedAt = performance.now();
this._statusText.textContent = text;
}
@@ -207,8 +215,9 @@
* @param {string} text
*/
_scheduleTextChange(text) {
- if (this._scheduledTextChangeTimeout)
+ if (this._scheduledTextChangeTimeout) {
clearTimeout(this._scheduledTextChangeTimeout);
+ }
const msSinceLastChange = performance.now() - this._textChangedAt;
const msToTextChange = Audits.StatusView.minimumTextVisibilityDuration - msSinceLastChange;