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/resources/BackgroundServiceView.js b/front_end/resources/BackgroundServiceView.js
index fec6f91..fe52daf 100644
--- a/front_end/resources/BackgroundServiceView.js
+++ b/front_end/resources/BackgroundServiceView.js
@@ -127,8 +127,9 @@
_refreshView() {
this._clearView();
const events = this._model.getEvents(this._serviceName).filter(event => this._acceptEvent(event));
- for (const event of events)
+ for (const event of events) {
this._addEvent(event);
+ }
}
/**
@@ -161,11 +162,13 @@
*/
_onRecordingStateChanged(event) {
const state = /** @type {!Resources.BackgroundServiceModel.RecordingState} */ (event.data);
- if (state.serviceName !== this._serviceName)
+ if (state.serviceName !== this._serviceName) {
return;
+ }
- if (state.isRecording === this._recordButton.toggled())
+ if (state.isRecording === this._recordButton.toggled()) {
return;
+ }
this._recordButton.setToggled(state.isRecording);
this._showPreview(this._selectedEventNode);
@@ -176,15 +179,17 @@
*/
_onEventReceived(event) {
const serviceEvent = /** @type {!Protocol.BackgroundService.BackgroundServiceEvent} */ (event.data);
- if (!this._acceptEvent(serviceEvent))
+ if (!this._acceptEvent(serviceEvent)) {
return;
+ }
this._addEvent(serviceEvent);
}
_onOriginChanged() {
// No need to refresh the view if we are already showing all events.
- if (this._originCheckbox.checked())
+ if (this._originCheckbox.checked()) {
return;
+ }
this._refreshView();
}
@@ -234,8 +239,9 @@
// Try to get the scope of the Service Worker registration to be more user-friendly.
const registration = this._serviceWorkerManager.registrations().get(serviceEvent.serviceWorkerRegistrationId);
- if (registration)
+ if (registration) {
swScope = registration.scopeURL.substr(registration.securityOrigin.length);
+ }
return {
id: this._dataGrid.rootNode().children.length + 1,
@@ -253,11 +259,13 @@
* @return {boolean}
*/
_acceptEvent(event) {
- if (event.service !== this._serviceName)
+ if (event.service !== this._serviceName) {
return false;
+ }
- if (this._originCheckbox.checked())
+ if (this._originCheckbox.checked()) {
return true;
+ }
// Trim the trailing '/'.
const origin = event.origin.substr(0, event.origin.length - 1);
@@ -296,13 +304,15 @@
* @param {?Resources.BackgroundServiceView.EventDataNode} dataNode
*/
_showPreview(dataNode) {
- if (this._selectedEventNode && this._selectedEventNode === dataNode)
+ if (this._selectedEventNode && this._selectedEventNode === dataNode) {
return;
+ }
this._selectedEventNode = dataNode;
- if (this._preview)
+ if (this._preview) {
this._preview.detach();
+ }
if (this._selectedEventNode) {
this._preview = this._selectedEventNode.createPreview();
@@ -349,8 +359,9 @@
const stream = new Bindings.FileOutputStream();
const accepted = await stream.open(fileName);
- if (!accepted)
+ if (!accepted) {
return;
+ }
const events = this._model.getEvents(this._serviceName).filter(event => this._acceptEvent(event));
await stream.write(JSON.stringify(events, undefined, 2));