@@ -4,12 +4,7 @@ import {FileScanResult} from './provider';
44import { SeverityFirstLetter , TreeView , TreeViewDisplayedData } from './types' ;
55import { ScanType , SEVERITY_PRIORITIES } from '../../constants' ;
66import { cliService } from '../../services/CliService' ;
7-
8- interface RefreshTreeViewDataArgs {
9- detections : AnyDetection [ ] ;
10- treeView ?: TreeView ;
11- scanType : ScanType ;
12- }
7+ import { scanResultsService } from '../../services/ScanResultsService' ;
138
149interface ValueItem {
1510 fullFilePath : string ;
@@ -20,25 +15,21 @@ type SeverityCounted = { [severity: string]: number };
2015
2116const VSCODE_ENTRY_LINE_NUMBER = 1 ;
2217
23- export function refreshTreeViewData (
24- args : RefreshTreeViewDataArgs
25- ) : void {
26- const { detections, treeView, scanType} = args ;
27- if ( treeView === undefined ) {
28- return ;
29- }
30-
18+ export const refreshTreeViewData = (
19+ scanType : ScanType , treeView : TreeView
20+ ) => {
3121 const projectRoot = cliService . getProjectRootDirectory ( ) ;
22+ const detections = scanResultsService . getDetections ( scanType ) ;
3223
33- const { provider} = treeView ;
3424 const affectedFiles : FileScanResult [ ] = [ ] ;
3525 const detectionsMapped = mapDetectionsByFileName ( detections , scanType ) ;
3626 detectionsMapped . forEach ( ( vulnerabilities , fullFilePath ) => {
3727 const projectRelativePath = path . relative ( projectRoot , fullFilePath ) ;
3828 affectedFiles . push ( new FileScanResult ( projectRelativePath , fullFilePath , vulnerabilities ) ) ;
3929 } ) ;
40- provider . refresh ( affectedFiles , scanType ) ;
41- }
30+
31+ treeView . provider . refresh ( affectedFiles , scanType ) ;
32+ } ;
4233
4334const _getSecretValueItem = ( detection : SecretDetection ) : ValueItem => {
4435 const { type, detection_details, severity} = detection ;
@@ -108,10 +99,10 @@ const _getSastValueItem = (detection: SastDetection): ValueItem => {
10899 return { fullFilePath : file_path , data : valueItem } ;
109100} ;
110101
111- function mapDetectionsByFileName (
102+ const mapDetectionsByFileName = (
112103 detections : AnyDetection [ ] ,
113104 scanType : ScanType ,
114- ) : Map < string , TreeViewDisplayedData [ ] > {
105+ ) : Map < string , TreeViewDisplayedData [ ] > => {
115106 const resultMap : Map < string , TreeViewDisplayedData [ ] > = new Map ( ) ;
116107
117108 detections . forEach ( ( detection ) => {
@@ -139,9 +130,9 @@ function mapDetectionsByFileName(
139130 } ) ;
140131
141132 return resultMap ;
142- }
133+ } ;
143134
144- function mapSeverityToFirstLetter ( severity : string ) : SeverityFirstLetter {
135+ const mapSeverityToFirstLetter = ( severity : string ) : SeverityFirstLetter => {
145136 switch ( severity . toLowerCase ( ) ) {
146137 case 'info' :
147138 return SeverityFirstLetter . Info ;
@@ -158,7 +149,7 @@ function mapSeverityToFirstLetter(severity: string): SeverityFirstLetter {
158149 `Supplied unsupported severity ${ severity } , can not map to severity first letter`
159150 ) ;
160151 }
161- }
152+ } ;
162153
163154export const mapScanResultsToSeverityStatsString = ( scanResults : FileScanResult [ ] ) : string => {
164155 const severityToCount : SeverityCounted = { } ;
0 commit comments