File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
extensions/ql-vscode/src/view/common/CodePaths Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,18 @@ const ShowPathsLink = styled(VSCodeLink)`
12
12
cursor: pointer;
13
13
` ;
14
14
15
+ const Label = styled . span `
16
+ color: var(--vscode-descriptionForeground);
17
+ margin-left: 10px;
18
+ ` ;
19
+
20
+ function getShortestPathLength ( codeFlows : CodeFlow [ ] ) : number {
21
+ const allPathLengths = codeFlows
22
+ . map ( ( codeFlow ) => codeFlow . threadFlows . length )
23
+ . flat ( ) ;
24
+ return Math . min ( ...allPathLengths ) ;
25
+ }
26
+
15
27
export type CodePathsProps = {
16
28
codeFlows : CodeFlow [ ] ;
17
29
ruleDescription : string ;
@@ -40,6 +52,9 @@ export const CodePaths = ({
40
52
return (
41
53
< >
42
54
< ShowPathsLink onClick = { onShowPathsClick } > Show paths</ ShowPathsLink >
55
+ < Label data-testid = "shortest-path-length" >
56
+ (Shortest: { getShortestPathLength ( codeFlows ) } )
57
+ </ Label >
43
58
</ >
44
59
) ;
45
60
} ;
Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ describe(CodePaths.name, () => {
24
24
expect ( screen . getByText ( "Show paths" ) ) . toBeInTheDocument ( ) ;
25
25
} ) ;
26
26
27
+ it ( "renders shortest path for code flows" , ( ) => {
28
+ render ( ) ;
29
+
30
+ expect ( screen . getByTestId ( "shortest-path-length" ) ) . toHaveTextContent (
31
+ "(Shortest: 1)" ,
32
+ ) ;
33
+ } ) ;
34
+
27
35
it ( "posts extension message when 'show paths' link clicked" , async ( ) => {
28
36
render ( ) ;
29
37
You can’t perform that action at this time.
0 commit comments