@@ -834,14 +834,14 @@ impl<'a> Scanner<'a> {
834834
835835 let ( tx, rx) = bounded :: < Finding > ( 8192 ) ;
836836 let ( progress_tx, progress_rx) = bounded :: < usize > ( 1000 ) ;
837-
837+
838838 // Spawn a thread to collect progress updates
839839 let progress_handle = if let Some ( ref callback) = self . config . progress_callback {
840840 let callback = callback. clone ( ) ;
841841 Some ( std:: thread:: spawn ( move || {
842842 let mut processed = 0 ;
843843 let mut findings_count = 0 ;
844-
844+
845845 while let Ok ( _) = progress_rx. recv ( ) {
846846 processed += 1 ;
847847 callback ( processed, total_files, findings_count) ;
@@ -851,41 +851,44 @@ impl<'a> Scanner<'a> {
851851 None
852852 } ;
853853
854- files. par_iter ( ) . for_each_with ( ( tx. clone ( ) , progress_tx. clone ( ) ) , |( tx, progress_tx) , path| {
855- if let Some ( lang) = Self :: detect_language ( path) {
856- if let Ok ( bytes) = Self :: load_file ( path) {
857- let unit = ScanUnit {
858- path : path. clone ( ) ,
859- lang,
860- bytes : bytes. clone ( ) ,
861- } ;
862- // Strip comments once and reuse
863- let stripped = strip_comments ( lang, & bytes) ;
864- let stripped_s = String :: from_utf8_lossy ( & stripped) ;
865- let index = LineIndex :: new ( stripped_s. as_bytes ( ) ) ;
866-
867- let mut em = Emitter {
868- tx : tx. clone ( ) ,
869- rx : rx. clone ( ) ,
870- } ;
871- for det in & self . detectors {
872- if !det. languages ( ) . contains ( & lang) {
873- continue ;
874- }
875- if !prefilter_hit ( det, & stripped) {
876- continue ;
854+ files. par_iter ( ) . for_each_with (
855+ ( tx. clone ( ) , progress_tx. clone ( ) ) ,
856+ |( tx, progress_tx) , path| {
857+ if let Some ( lang) = Self :: detect_language ( path) {
858+ if let Ok ( bytes) = Self :: load_file ( path) {
859+ let unit = ScanUnit {
860+ path : path. clone ( ) ,
861+ lang,
862+ bytes : bytes. clone ( ) ,
863+ } ;
864+ // Strip comments once and reuse
865+ let stripped = strip_comments ( lang, & bytes) ;
866+ let stripped_s = String :: from_utf8_lossy ( & stripped) ;
867+ let index = LineIndex :: new ( stripped_s. as_bytes ( ) ) ;
868+
869+ let mut em = Emitter {
870+ tx : tx. clone ( ) ,
871+ rx : rx. clone ( ) ,
872+ } ;
873+ for det in & self . detectors {
874+ if !det. languages ( ) . contains ( & lang) {
875+ continue ;
876+ }
877+ if !prefilter_hit ( det, & stripped) {
878+ continue ;
879+ }
880+ let _ = det. scan_optimized ( & unit, & stripped_s, & index, & mut em) ;
877881 }
878- let _ = det. scan_optimized ( & unit, & stripped_s, & index, & mut em) ;
879882 }
880883 }
881- }
882- // Signal that this file has been processed
883- let _ = progress_tx . send ( 1 ) ;
884- } ) ;
884+ // Signal that this file has been processed
885+ let _ = progress_tx . send ( 1 ) ;
886+ } ,
887+ ) ;
885888
886889 drop ( tx) ;
887890 drop ( progress_tx) ;
888-
891+
889892 for f in rx. iter ( ) {
890893 findings. push ( f) ;
891894 }
0 commit comments