33import importlib
44import os
55from typing import List , NamedTuple
6+ from tqdm import tqdm
67
78
89class ScanResult (NamedTuple ):
910 file_path : str
1011 line_number : int
1112 title : str
1213 message : str
13- severity : str # New field for severity
14+ severity : str
1415
1516
1617class Scanner :
@@ -28,14 +29,21 @@ def _load_checks(self):
2829
2930 def scan (self , path : str ) -> List [ScanResult ]:
3031 results = []
32+ files_to_scan = []
33+
34+ # Collect all files to scan
3135 if os .path .isfile (path ):
32- results . extend ( self . _scan_file ( path ) )
36+ files_to_scan . append ( path )
3337 elif os .path .isdir (path ):
3438 for root , _ , files in os .walk (path ):
3539 for file in files :
3640 if any (file .endswith (ext ) for ext in self .config .get_file_extensions ()):
37- file_path = os .path .join (root , file )
38- results .extend (self ._scan_file (file_path ))
41+ files_to_scan .append (os .path .join (root , file ))
42+
43+ # Scan files with progress bar
44+ for file_path in tqdm (files_to_scan , desc = "Scanning files" , unit = "file" ):
45+ results .extend (self ._scan_file (file_path ))
46+
3947 return results
4048
4149 def _scan_file (self , file_path : str ) -> List [ScanResult ]:
@@ -52,4 +60,4 @@ def _scan_file(self, file_path: str) -> List[ScanResult]:
5260 message = result .line_content ,
5361 severity = check .severity
5462 ))
55- return results
63+ return results
0 commit comments