diff --git a/extensions/ql-vscode/src/view/results/AlertTableResultRow.tsx b/extensions/ql-vscode/src/view/results/AlertTableResultRow.tsx index 7daf9926aa4..eb2dfb39b4f 100644 --- a/extensions/ql-vscode/src/view/results/AlertTableResultRow.tsx +++ b/extensions/ql-vscode/src/view/results/AlertTableResultRow.tsx @@ -4,7 +4,7 @@ import type { Result as ResultKeysResult, ResultKey, } from "./result-keys"; -import { getAllPaths, keyToString } from "./result-keys"; +import { getAllPaths, getShortestPath, keyToString } from "./result-keys"; import { info, listUnordered } from "./octicons"; import { selectableZebraStripe } from "./result-table-utils"; import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell"; @@ -12,6 +12,7 @@ import { useCallback, useMemo } from "react"; import { SarifLocation } from "./locations/SarifLocation"; import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations"; import { AlertTablePathRow } from "./AlertTablePathRow"; +import { VSCodeBadge } from "@vscode/webview-ui-toolkit/react"; interface Props { result: Result; @@ -99,6 +100,9 @@ export function AlertTableResultRow(props: Props) { onClick={handleDropdownClick} /> {listUnordered} + + {getShortestPath(result)} + {msg} )} diff --git a/extensions/ql-vscode/src/view/results/result-keys.ts b/extensions/ql-vscode/src/view/results/result-keys.ts index 0875da2cbad..efafffb7c81 100644 --- a/extensions/ql-vscode/src/view/results/result-keys.ts +++ b/extensions/ql-vscode/src/view/results/result-keys.ts @@ -103,6 +103,12 @@ export function equalsNotUndefined( ); } +export function getShortestPath(result: SarifResult): number { + const paths = getAllPaths(result); + const allPathLengths = paths.map((path) => path.locations.length); + return Math.min(...allPathLengths); +} + /** * Returns the list of paths in the given SARIF result. *