Avoid else blocks when we're returning early
This commit is contained in:
@@ -30,21 +30,26 @@ export function Location({
|
||||
}: Props): JSX.Element {
|
||||
const resolvableLoc = useMemo(() => tryGetResolvableLocation(loc), [loc]);
|
||||
const displayLabel = useMemo(() => convertNonPrintableChars(label), [label]);
|
||||
|
||||
if (loc === undefined) {
|
||||
return <NonClickableLocation msg={displayLabel} />;
|
||||
} else if (isStringLoc(loc)) {
|
||||
return <a href={loc}>{loc}</a>;
|
||||
} else if (databaseUri === undefined || resolvableLoc === undefined) {
|
||||
return <NonClickableLocation msg={displayLabel} locationHint={title} />;
|
||||
} else {
|
||||
return (
|
||||
<ClickableLocation
|
||||
loc={resolvableLoc}
|
||||
label={displayLabel}
|
||||
databaseUri={databaseUri}
|
||||
title={title}
|
||||
handleClick={handleClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (isStringLoc(loc)) {
|
||||
return <a href={loc}>{loc}</a>;
|
||||
}
|
||||
|
||||
if (databaseUri === undefined || resolvableLoc === undefined) {
|
||||
return <NonClickableLocation msg={displayLabel} locationHint={title} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ClickableLocation
|
||||
loc={resolvableLoc}
|
||||
label={displayLabel}
|
||||
databaseUri={databaseUri}
|
||||
title={title}
|
||||
handleClick={handleClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,9 @@ export function SarifLocation({
|
||||
);
|
||||
if (parsedLoc === undefined || "hint" in parsedLoc) {
|
||||
return <Location label={text || "[no location]"} title={parsedLoc?.hint} />;
|
||||
} else if (isWholeFileLoc(parsedLoc)) {
|
||||
}
|
||||
|
||||
if (isWholeFileLoc(parsedLoc)) {
|
||||
return (
|
||||
<Location
|
||||
loc={parsedLoc}
|
||||
@@ -43,7 +45,9 @@ export function SarifLocation({
|
||||
handleClick={handleClick}
|
||||
/>
|
||||
);
|
||||
} else if (isLineColumnLoc(parsedLoc)) {
|
||||
}
|
||||
|
||||
if (isLineColumnLoc(parsedLoc)) {
|
||||
return (
|
||||
<Location
|
||||
loc={parsedLoc}
|
||||
@@ -58,7 +62,7 @@ export function SarifLocation({
|
||||
handleClick={handleClick}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user