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/network/RequestTimingView.js b/front_end/network/RequestTimingView.js
index 2623fbf..8b7a8d2 100644
--- a/front_end/network/RequestTimingView.js
+++ b/front_end/network/RequestTimingView.js
@@ -96,8 +96,9 @@
* @param {number} end
*/
function addRange(name, start, end) {
- if (start < Number.MAX_VALUE && start <= end)
+ if (start < Number.MAX_VALUE && start <= end) {
result.push({name: name, start: start, end: end});
+ }
}
/**
@@ -106,8 +107,9 @@
*/
function firstPositive(numbers) {
for (let i = 0; i < numbers.length; ++i) {
- if (numbers[i] > 0)
+ if (numbers[i] > 0) {
return numbers[i];
+ }
}
return undefined;
}
@@ -118,8 +120,9 @@
* @param {number} end
*/
function addOffsetRange(name, start, end) {
- if (start >= 0 && end >= 0)
+ if (start >= 0 && end >= 0) {
addRange(name, startTime + (start / 1000), startTime + (end / 1000));
+ }
}
const timing = request.timing;
@@ -142,11 +145,13 @@
const pushEnd = timing.pushEnd || endTime;
// Only show the part of push that happened after the navigation/reload.
// Pushes that happened on the same connection before we started main request will not be shown.
- if (pushEnd > navigationStart)
+ if (pushEnd > navigationStart) {
addRange(Network.RequestTimeRangeNames.Push, Math.max(timing.pushStart, navigationStart), pushEnd);
+ }
}
- if (issueTime < startTime)
+ if (issueTime < startTime) {
addRange(Network.RequestTimeRangeNames.Queueing, issueTime, startTime);
+ }
const responseReceived = (request.responseReceivedTime - startTime) * 1000;
if (request.fetchedViaServiceWorker) {
@@ -229,14 +234,17 @@
if (rangeName === Network.RequestTimeRangeNames.Push) {
createHeader(Common.UIString('Server Push'));
} else if (rangeName === Network.RequestTimeRangeNames.Queueing) {
- if (!queueingHeader)
+ if (!queueingHeader) {
queueingHeader = createHeader(ls`Resource Scheduling`);
+ }
} else if (Network.RequestTimingView.ConnectionSetupRangeNames.has(rangeName)) {
- if (!connectionHeader)
+ if (!connectionHeader) {
connectionHeader = createHeader(Common.UIString('Connection Start'));
+ }
} else {
- if (!dataHeader)
+ if (!dataHeader) {
dataHeader = createHeader(Common.UIString('Request/Response'));
+ }
}
const left = (scale * (range.start - startTime));
@@ -271,8 +279,9 @@
footer.createChild('td').createTextChild(Number.secondsToString(totalDuration, true));
const serverTimings = request.serverTimings;
- if (!serverTimings)
+ if (!serverTimings) {
return tableElement;
+ }
const lastTimingRightEdge = right === undefined ? 100 : right;
@@ -306,16 +315,18 @@
metric.title = description;
const row = tr.createChild('td').createChild('div', 'network-timing-row');
- if (serverTiming.value === null)
+ if (serverTiming.value === null) {
return;
+ }
const left = scale * (endTime - startTime - (serverTiming.value / 1000));
if (left >= 0) { // don't chart values too big or too small
const bar = row.createChild('span', 'network-timing-bar server-timing');
bar.style.left = left + '%';
bar.style.right = right + '%';
bar.textContent = '\u200B'; // Important for 0-time items to have 0 width.
- if (!isTotal)
+ if (!isTotal) {
bar.style.backgroundColor = colorGenerator.colorForID(serverTiming.metric);
+ }
}
const label = tr.createChild('td').createChild('div', 'network-timing-bar-title');
label.textContent = Number.millisToString(serverTiming.value, true);
@@ -356,8 +367,9 @@
}
_refresh() {
- if (this._tableElement)
+ if (this._tableElement) {
this._tableElement.remove();
+ }
this._tableElement = Network.RequestTimingView.createTimingTable(this._request, this._calculator);
this._tableElement.classList.add('resource-timing-table');