diff --git a/extensions/ql-vscode/src/view/common/CodePaths/CodePaths.tsx b/extensions/ql-vscode/src/view/common/CodePaths/CodePaths.tsx index 56809523781..2ae4bf1d1af 100644 --- a/extensions/ql-vscode/src/view/common/CodePaths/CodePaths.tsx +++ b/extensions/ql-vscode/src/view/common/CodePaths/CodePaths.tsx @@ -12,6 +12,18 @@ const ShowPathsLink = styled(VSCodeLink)` cursor: pointer; `; +const Label = styled.span` + color: var(--vscode-descriptionForeground); + margin-left: 10px; +`; + +function getShortestPathLength(codeFlows: CodeFlow[]): number { + const allPathLengths = codeFlows + .map((codeFlow) => codeFlow.threadFlows.length) + .flat(); + return Math.min(...allPathLengths); +} + export type CodePathsProps = { codeFlows: CodeFlow[]; ruleDescription: string; @@ -40,6 +52,9 @@ export const CodePaths = ({ return ( <> Show paths + ); }; diff --git a/extensions/ql-vscode/src/view/common/CodePaths/__tests__/CodePaths.spec.tsx b/extensions/ql-vscode/src/view/common/CodePaths/__tests__/CodePaths.spec.tsx index bfea6df23bf..971fdd29a66 100644 --- a/extensions/ql-vscode/src/view/common/CodePaths/__tests__/CodePaths.spec.tsx +++ b/extensions/ql-vscode/src/view/common/CodePaths/__tests__/CodePaths.spec.tsx @@ -24,6 +24,14 @@ describe(CodePaths.name, () => { expect(screen.getByText("Show paths")).toBeInTheDocument(); }); + it("renders shortest path for code flows", () => { + render(); + + expect(screen.getByTestId("shortest-path-length")).toHaveTextContent( + "(Shortest: 1)", + ); + }); + it("posts extension message when 'show paths' link clicked", async () => { render();