Skip to content

Commit 1545249

Browse files
committed
WIP address no-unnecessary-condition
1 parent 5e3f6f6 commit 1545249

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
@@ -893,7 +893,7 @@ const _upgraders: {
893893
// will not be preserved.
894894
const transforms = parseTransforms(query.transforms);
895895

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

src/profile-logic/profile-data.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,15 +2788,11 @@ export function getThreadProcessDetails(
27882788
): string {
27892789
let label = `${friendlyThreadName}\n`;
27902790
label += `Thread: "${thread.name}"`;
2791-
if (thread.tid !== undefined) {
2792-
label += ` (${thread.tid})`;
2793-
}
2791+
label += ` (${thread.tid})`;
27942792

27952793
if (thread.processType) {
27962794
label += `\nProcess: "${thread.processType}"`;
2797-
if (thread.pid !== undefined) {
2798-
label += ` (${thread.pid})`;
2799-
}
2795+
label += ` (${thread.pid})`;
28002796
}
28012797

28022798
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
@@ -278,7 +278,7 @@ export const getMarkerSchemaByName: Selector<MarkerSchemaByName> =
278278

279279
type CounterSelectors = ReturnType<typeof _createCounterSelectors>;
280280

281-
const _counterSelectors: { [key: number]: CounterSelectors } = {};
281+
const _counterSelectors: Partial<Record<number, CounterSelectors>> = {};
282282
export const getCounterSelectors = (index: CounterIndex): CounterSelectors => {
283283
let selectors = _counterSelectors[index];
284284
if (!selectors) {
@@ -633,11 +633,6 @@ export const getTrackCount: Selector<TrackCount> = createSelector(
633633
if (globalTrackIndex === -1) {
634634
throw new Error('Unable to find a global track from the given pid.');
635635
}
636-
if (!hiddenLocalTracks) {
637-
throw new Error(
638-
'Unable to find the hidden local tracks from the given pid'
639-
);
640-
}
641636

642637
if (hiddenGlobalTracks.has(globalTrackIndex)) {
643638
// The entire process group is hidden, count all of the tracks.
@@ -809,10 +804,6 @@ export const getProfileFilterSortedPageData: Selector<SortedTabPageData> =
809804
}
810805
for (const threadIndex of threadIndexes.values()) {
811806
const threadScore = threadActivityScores[threadIndex];
812-
if (!threadScore) {
813-
throw new Error('Failed to find the thread score!');
814-
}
815-
816807
tabScore += threadScore.boostedSampleScore;
817808
}
818809
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
@@ -87,9 +87,6 @@ export async function run(options: CliOptions) {
8787

8888
// Load the profile.
8989
const profile = await unserializeProfileOfArbitraryFormat(bytes);
90-
if (profile === undefined) {
91-
throw new Error('Unable to parse the profile.');
92-
}
9390

9491
const symbolStoreDB = new InMemorySymbolDB();
9592

src/types/state.ts

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

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

7777
export type RightClickedCallNode = {
7878
readonly threadsKey: ThreadsKey;

0 commit comments

Comments
 (0)