Skip to content

Commit 20617d2

Browse files
committed
feature: show shortest path in codepath UI
1 parent 7f6f9c9 commit 20617d2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

extensions/ql-vscode/src/view/common/CodePaths/CodePaths.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ const ShowPathsLink = styled(VSCodeLink)`
1212
cursor: pointer;
1313
`;
1414

15+
const Label = styled.span`
16+
color: var(--vscode-descriptionForeground);
17+
margin-right: 10px;
18+
margin-left: 10px;
19+
`;
20+
1521
export type CodePathsProps = {
1622
codeFlows: CodeFlow[];
1723
ruleDescription: string;
@@ -37,9 +43,14 @@ export const CodePaths = ({
3743
});
3844
};
3945

46+
const allPathLengths = codeFlows
47+
.map((codeFlow) => codeFlow.threadFlows.length)
48+
.flat();
49+
const shortestPath = Math.min(...allPathLengths);
4050
return (
4151
<>
4252
<ShowPathsLink onClick={onShowPathsClick}>Show paths</ShowPathsLink>
53+
<Label>(Shortest: {shortestPath})</Label>
4354
</>
4455
);
4556
};

0 commit comments

Comments
 (0)