Skip to content

Commit e1439da

Browse files
committed
WIP address no-unnecessary-condition
1 parent e6e45a6 commit e1439da

9 files changed

Lines changed: 12 additions & 35 deletions

File tree

src/actions/profile-view.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,6 @@ export function isolateProcess(
10801080
for (const localTrack of localTracks) {
10811081
if (
10821082
localTrack.type === 'thread' &&
1083-
localTrack.threadIndex !== undefined &&
10841083
oldSelectedThreadIndexes.has(localTrack.threadIndex)
10851084
) {
10861085
newSelectedThreadIndexes.add(localTrack.threadIndex);

src/actions/receive-profile.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ async function _extractJsonFromResponse(
10961096
message = 'The network request to load the profile was aborted.';
10971097
} else if (fileType === 'application/json') {
10981098
message = 'The profile’s JSON could not be decoded.';
1099-
} else if (fileType === null && arrayBuffer !== null) {
1099+
} else if (arrayBuffer !== null) {
11001100
// If the content type is not specified, use a raw array buffer
11011101
// to fallback to other supported profile formats.
11021102
return arrayBuffer;
@@ -1163,10 +1163,6 @@ export function retrieveProfileOrZipFromUrl(
11631163
serializedProfile,
11641164
profileUrl
11651165
);
1166-
if (profile === undefined) {
1167-
throw new Error('Unable to parse the profile.');
1168-
}
1169-
11701166
await dispatch(loadProfile(profile, {}, initialLoad));
11711167
break;
11721168
}

src/app-logic/url-handling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ const _upgraders: {
892892
// will not be preserved.
893893
const transforms = parseTransforms(query.transforms);
894894

895-
if (!transforms || transforms.length === 0) {
895+
if (transforms.length === 0) {
896896
// We don't have any transforms to upgrade.
897897
return;
898898
}

src/profile-logic/profile-data.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,15 +2773,11 @@ export function getThreadProcessDetails(
27732773
): string {
27742774
let label = `${friendlyThreadName}\n`;
27752775
label += `Thread: "${thread.name}"`;
2776-
if (thread.tid !== undefined) {
2777-
label += ` (${thread.tid})`;
2778-
}
2776+
label += ` (${thread.tid})`;
27792777

27802778
if (thread.processType) {
27812779
label += `\nProcess: "${thread.processType}"`;
2782-
if (thread.pid !== undefined) {
2783-
label += ` (${thread.pid})`;
2784-
}
2780+
label += ` (${thread.pid})`;
27852781
}
27862782

27872783
if (thread.isPrivateBrowsing) {

src/profile-logic/tracks.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,7 @@ function _getDefaultLocalTrackOrder(
144144
if (tracks[a].type === 'thread' && tracks[b].type === 'thread' && profile) {
145145
const idxA = tracks[a].threadIndex;
146146
const idxB = tracks[b].threadIndex;
147-
if (idxA === undefined || idxB === undefined) {
148-
return -1;
149-
}
150-
if (profile && profile.meta.keepProfileThreadOrder) {
147+
if (profile.meta.keepProfileThreadOrder) {
151148
return idxA - idxB;
152149
}
153150
const nameA = profile.threads[idxA].name;

src/selectors/profile.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export const getMarkerSchemaByName: Selector<MarkerSchemaByName> =
274274

275275
type CounterSelectors = ReturnType<typeof _createCounterSelectors>;
276276

277-
const _counterSelectors: { [key: number]: CounterSelectors } = {};
277+
const _counterSelectors: Partial<Record<number, CounterSelectors>> = {};
278278
export const getCounterSelectors = (index: CounterIndex): CounterSelectors => {
279279
let selectors = _counterSelectors[index];
280280
if (!selectors) {
@@ -629,11 +629,6 @@ export const getHiddenTrackCount: Selector<HiddenTrackCount> = createSelector(
629629
if (globalTrackIndex === -1) {
630630
throw new Error('Unable to find a global track from the given pid.');
631631
}
632-
if (!hiddenLocalTracks) {
633-
throw new Error(
634-
'Unable to find the hidden local tracks from the given pid'
635-
);
636-
}
637632

638633
if (hiddenGlobalTracks.has(globalTrackIndex)) {
639634
// The entire process group is hidden, count all of the tracks.
@@ -805,10 +800,6 @@ export const getProfileFilterSortedPageData: Selector<SortedTabPageData> =
805800
}
806801
for (const threadIndex of threadIndexes.values()) {
807802
const threadScore = threadActivityScores[threadIndex];
808-
if (!threadScore) {
809-
throw new Error('Failed to find the thread score!');
810-
}
811-
812803
tabScore += threadScore.boostedSampleScore;
813804
}
814805
pageDataWithScore.push({

src/selectors/zipped-profiles.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ export const getZipFileMaxDepth: Selector<number> = createSelector(
7474
* render a file picker to load profiles from the zip file.
7575
*/
7676
export const getZipFileTreeOrNull: Selector<ZipFiles.ZipFileTree | null> =
77-
createSelector(getZipFileTable, getProfileUrl, (zipFileTable, zipFileUrl) =>
78-
zipFileTable === null
79-
? null
80-
: new ZipFiles.ZipFileTree(zipFileTable, zipFileUrl)
77+
createSelector(
78+
getZipFileTable,
79+
getProfileUrl,
80+
(zipFileTable, zipFileUrl) =>
81+
new ZipFiles.ZipFileTree(zipFileTable, zipFileUrl)
8182
);
8283

8384
/**

src/symbolicator-cli/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ export async function run(options: CliOptions) {
9494

9595
// Load the profile.
9696
const profile = await unserializeProfileOfArbitraryFormat(byteBufferCopy);
97-
if (profile === undefined) {
98-
throw new Error('Unable to parse the profile.');
99-
}
10097

10198
const symbolStoreDB = new InMemorySymbolDB();
10299

src/types/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export type TableViewOptions = {
6767
readonly fixedColumnWidths: Array<CssPixels> | null;
6868
};
6969

70-
export type TableViewOptionsPerTab = { [K in TabSlug]: TableViewOptions };
70+
export type TableViewOptionsPerTab = Partial<Record<TabSlug, TableViewOptions>>;
7171

7272
export type RightClickedCallNode = {
7373
readonly threadsKey: ThreadsKey;

0 commit comments

Comments
 (0)