Skip to content

Commit 1f16294

Browse files
Avoid else blocks when we're returning early
1 parent 679266c commit 1f16294

2 files changed

Lines changed: 25 additions & 16 deletions

File tree

extensions/ql-vscode/src/view/results/locations/Location.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,26 @@ export function Location({
3030
}: Props): JSX.Element {
3131
const resolvableLoc = useMemo(() => tryGetResolvableLocation(loc), [loc]);
3232
const displayLabel = useMemo(() => convertNonPrintableChars(label), [label]);
33+
3334
if (loc === undefined) {
3435
return <NonClickableLocation msg={displayLabel} />;
35-
} else if (isStringLoc(loc)) {
36+
}
37+
38+
if (isStringLoc(loc)) {
3639
return <a href={loc}>{loc}</a>;
37-
} else if (databaseUri === undefined || resolvableLoc === undefined) {
40+
}
41+
42+
if (databaseUri === undefined || resolvableLoc === undefined) {
3843
return <NonClickableLocation msg={displayLabel} locationHint={title} />;
39-
} else {
40-
return (
41-
<ClickableLocation
42-
loc={resolvableLoc}
43-
label={displayLabel}
44-
databaseUri={databaseUri}
45-
title={title}
46-
handleClick={handleClick}
47-
/>
48-
);
4944
}
45+
46+
return (
47+
<ClickableLocation
48+
loc={resolvableLoc}
49+
label={displayLabel}
50+
databaseUri={databaseUri}
51+
title={title}
52+
handleClick={handleClick}
53+
/>
54+
);
5055
}

extensions/ql-vscode/src/view/results/locations/SarifLocation.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ export function SarifLocation({
3333
);
3434
if (parsedLoc === undefined || "hint" in parsedLoc) {
3535
return <Location label={text || "[no location]"} title={parsedLoc?.hint} />;
36-
} else if (isWholeFileLoc(parsedLoc)) {
36+
}
37+
38+
if (isWholeFileLoc(parsedLoc)) {
3739
return (
3840
<Location
3941
loc={parsedLoc}
@@ -43,7 +45,9 @@ export function SarifLocation({
4345
handleClick={handleClick}
4446
/>
4547
);
46-
} else if (isLineColumnLoc(parsedLoc)) {
48+
}
49+
50+
if (isLineColumnLoc(parsedLoc)) {
4751
return (
4852
<Location
4953
loc={parsedLoc}
@@ -58,7 +62,7 @@ export function SarifLocation({
5862
handleClick={handleClick}
5963
/>
6064
);
61-
} else {
62-
return null;
6365
}
66+
67+
return null;
6468
}

0 commit comments

Comments
 (0)