Skip to content

Commit ca2ba79

Browse files
committed
style: Fix code formatting with cargo fmt
- Apply consistent formatting across all Rust files - Fix spacing and indentation issues in progress reporting code - Ensure code follows Rust style guidelines
1 parent 11a4891 commit ca2ba79

File tree

2 files changed

+35
-32
lines changed

2 files changed

+35
-32
lines changed

crates/cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn main() -> Result<()> {
155155
.progress_chars("#>-"),
156156
);
157157
pb.set_message("Scanning files...");
158-
158+
159159
cfg.progress_callback = Some(Arc::new(move |processed, total, findings| {
160160
pb.set_length(total as u64);
161161
pb.set_position(processed as u64);

crates/scanner-core/src/lib.rs

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)