Skip to content

Commit

Permalink
Add eslint rule no-else-return
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatum committed Aug 27, 2018
1 parent 4a1de1c commit aef72da
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 94 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ module.exports = {
'prefer-promise-reject-errors': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'no-else-return': 'error',
},
settings: {
react: {
Expand Down
3 changes: 1 addition & 2 deletions src/actions/zipped-profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ export function viewProfileFromPathInZipFile(
if (zipFileIndex === -1) {
dispatch(showErrorForNoFileInZip(pathInZipFile));
return Promise.resolve();
} else {
return dispatch(viewProfileFromZip(zipFileIndex));
}
return dispatch(viewProfileFromZip(zipFileIndex));
};
}

Expand Down
103 changes: 49 additions & 54 deletions src/components/shared/MarkerTooltipContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,61 +629,56 @@ function getMarkerDetails(
)}
</div>
);
} else {
return (
<div className="tooltipDetails">
{_markerDetail('status', 'Status', data.status)}
{_markerDetailNullable('url', 'URL', data.URI)}
{_markerDetailNullable(
'redirect_url',
'Redirect URL',
data.RedirectURI
)}
{_markerDetail('pri', 'Priority', data.pri)}
{_markerDetailBytesNullable(
'count',
'Requested bytes',
data.count
)}
{_markerDetailDeltaTimeNullable(
'domainLookup',
'Domain lookup in total',
data.domainLookupEnd,
data.domainLookupStart
)}
{_markerDetailDeltaTimeNullable(
'connect',
'Connection in total',
data.connectEnd,
data.connectStart
)}
{_markerDetailDeltaTimeNullable(
'tcpConnect',
'TCP connection in total',
data.tcpConnectEnd,
data.connectStart
)}
{_markerDetailDeltaTimeNullable(
'secureConnectionStart',
'Start of secure connection at',
data.secureConnectionStart,
data.tcpConnectEnd
)}
{_markerDetailDeltaTimeNullable(
'requestStart',
'Start of request at',
data.requestStart,
data.connectStart
)}
{_markerDetailDeltaTimeNullable(
'response',
'Response time',
data.responseEnd,
data.responseStart
)}
</div>
);
}
return (
<div className="tooltipDetails">
{_markerDetail('status', 'Status', data.status)}
{_markerDetailNullable('url', 'URL', data.URI)}
{_markerDetailNullable(
'redirect_url',
'Redirect URL',
data.RedirectURI
)}
{_markerDetail('pri', 'Priority', data.pri)}
{_markerDetailBytesNullable('count', 'Requested bytes', data.count)}
{_markerDetailDeltaTimeNullable(
'domainLookup',
'Domain lookup in total',
data.domainLookupEnd,
data.domainLookupStart
)}
{_markerDetailDeltaTimeNullable(
'connect',
'Connection in total',
data.connectEnd,
data.connectStart
)}
{_markerDetailDeltaTimeNullable(
'tcpConnect',
'TCP connection in total',
data.tcpConnectEnd,
data.connectStart
)}
{_markerDetailDeltaTimeNullable(
'secureConnectionStart',
'Start of secure connection at',
data.secureConnectionStart,
data.tcpConnectEnd
)}
{_markerDetailDeltaTimeNullable(
'requestStart',
'Start of request at',
data.requestStart,
data.connectStart
)}
{_markerDetailDeltaTimeNullable(
'response',
'Response time',
data.responseEnd,
data.responseStart
)}
</div>
);
}
case 'Styles': {
return [
Expand Down
13 changes: 6 additions & 7 deletions src/components/timeline/TrackContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,13 @@ class TimelineTrackContextMenu extends PureComponent<Props> {

if (rightClickedTrack.type === 'global') {
return globalTrackNames[rightClickedTrack.trackIndex];
} else {
const localTrackNames = localTrackNamesByPid.get(rightClickedTrack.pid);
if (localTrackNames === undefined) {
console.error('Expected to find a local track name for the given pid.');
return 'Unknown Track';
}
return localTrackNames[rightClickedTrack.trackIndex];
}
const localTrackNames = localTrackNamesByPid.get(rightClickedTrack.pid);
if (localTrackNames === undefined) {
console.error('Expected to find a local track name for the given pid.');
return 'Unknown Track';
}
return localTrackNames[rightClickedTrack.trackIndex];
}

renderIsolateProcess() {
Expand Down
34 changes: 16 additions & 18 deletions src/profile-logic/convert-markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export function upgradeGCMinorMarker(marker8: Object): GCMinorMarkerPayload {
marker8.nursery.status = 'nursery empty';
}
return Object.assign(marker8);
} else {
/*
}
/*
* This is the old format for GCMinor, rename some
* properties to the more sensible names in the newer
* format and set the status.
Expand All @@ -29,23 +29,21 @@ export function upgradeGCMinorMarker(marker8: Object): GCMinorMarkerPayload {
* promotion_rate, leave them so that anyone opening the
* raw json data can still see them in converted profiles.
*/
const marker = Object.assign(marker8, {
nursery: Object.assign(marker8.nursery, {
status: 'complete',
bytes_used: marker8.nursery.nursery_bytes,
// cur_capacity cannot be filled in.
new_capacity: marker8.nursery.new_nursery_bytes,
phase_times: marker8.nursery.timings,
}),
});
delete marker.nursery.nursery_bytes;
delete marker.nursery.new_nursery_bytes;
delete marker.nursery.timings;
return marker;
}
} else {
return marker8;
const marker = Object.assign(marker8, {
nursery: Object.assign(marker8.nursery, {
status: 'complete',
bytes_used: marker8.nursery.nursery_bytes,
// cur_capacity cannot be filled in.
new_capacity: marker8.nursery.new_nursery_bytes,
phase_times: marker8.nursery.timings,
}),
});
delete marker.nursery.nursery_bytes;
delete marker.nursery.new_nursery_bytes;
delete marker.nursery.timings;
return marker;
}
return marker8;
}

/*
Expand Down
17 changes: 8 additions & 9 deletions src/reducers/profile-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,16 +661,15 @@ export const getRightClickedThreadIndex = createSelector(
if (rightClickedTrack.type === 'global') {
const track = globalTracks[rightClickedTrack.trackIndex];
return track.type === 'process' ? track.mainThreadIndex : null;
} else {
const { pid, trackIndex } = rightClickedTrack;
const localTracks = ensureExists(
localTracksByPid.get(pid),
'No local tracks found at that pid.'
);
const track = localTracks[trackIndex];

return track.type === 'thread' ? track.threadIndex : null;
}
const { pid, trackIndex } = rightClickedTrack;
const localTracks = ensureExists(
localTracksByPid.get(pid),
'No local tracks found at that pid.'
);
const track = localTracks[trackIndex];

return track.type === 'thread' ? track.threadIndex : null;
}
);
export const getGlobalTrackNames = createSelector(
Expand Down
6 changes: 2 additions & 4 deletions src/utils/format-numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ export function formatBytes(bytes: number): string {
return formatNumber(bytes / 1024, 3, 2) + 'KB';
} else if (bytes < 1024 * 1024 * 1024) {
return formatNumber(bytes / (1024 * 1024), 3, 2) + 'MB';
} else {
return formatNumber(bytes / (1024 * 1024 * 1024), 3, 2) + 'GB';
}
return formatNumber(bytes / (1024 * 1024 * 1024), 3, 2) + 'GB';
}

export function formatSI(num: number): string {
Expand All @@ -73,9 +72,8 @@ export function formatSI(num: number): string {
return formatNumber(num / 1000, 3, 2) + 'K';
} else if (num < 1000 * 1000 * 1000) {
return formatNumber(num / (1000 * 1000), 3, 2) + 'M';
} else {
return formatNumber(num / (1000 * 1000 * 1000), 3, 2) + 'G';
}
return formatNumber(num / (1000 * 1000 * 1000), 3, 2) + 'G';
}

export function formatMicroseconds(
Expand Down

0 comments on commit aef72da

Please sign in to comment.