@@ -222,12 +222,17 @@ impl Crate {
222222 cargo_clippy_path : & PathBuf ,
223223 target_dir_index : & AtomicUsize ,
224224 thread_limit : usize ,
225+ total_crates_to_lint : usize ,
225226 ) -> Vec < ClippyWarning > {
226227 // advance the atomic index by one
227- let idx = target_dir_index. fetch_add ( 1 , Ordering :: SeqCst ) ;
228+ let index = target_dir_index. fetch_add ( 1 , Ordering :: SeqCst ) ;
228229 // "loop" the index within 0..thread_limit
229- let idx = idx % thread_limit;
230- println ! ( "Linting {} {} in target dir {:?}" , & self . name, & self . version, idx) ;
230+ let target_dir_index = index % thread_limit;
231+ let perc = ( ( index * 100 ) as f32 / total_crates_to_lint as f32 ) as u8 ;
232+ println ! (
233+ "{}/{} {}% Linting {} {} in target dir {:?}" ,
234+ index, total_crates_to_lint, perc, & self . name, & self . version, target_dir_index
235+ ) ;
231236 let cargo_clippy_path = std:: fs:: canonicalize ( cargo_clippy_path) . unwrap ( ) ;
232237
233238 let shared_target_dir = clippy_project_root ( ) . join ( "target/lintcheck/shared_target_dir" ) ;
@@ -244,7 +249,10 @@ impl Crate {
244249
245250 let all_output = std:: process:: Command :: new ( & cargo_clippy_path)
246251 // use the looping index to create individual target dirs
247- . env ( "CARGO_TARGET_DIR" , shared_target_dir. join ( format ! ( "_{:?}" , idx) ) )
252+ . env (
253+ "CARGO_TARGET_DIR" ,
254+ shared_target_dir. join ( format ! ( "_{:?}" , target_dir_index) ) ,
255+ )
248256 // lint warnings will look like this:
249257 // src/cargo/ops/cargo_compile.rs:127:35: warning: usage of `FromIterator::from_iter`
250258 . args ( & args)
@@ -466,7 +474,7 @@ pub fn run(clap_config: &ArgMatches) {
466474 . into_iter ( )
467475 . map ( |krate| krate. download_and_extract ( ) )
468476 . filter ( |krate| krate. name == only_one_crate)
469- . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path, & AtomicUsize :: new ( 0 ) , 1 ) )
477+ . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path, & AtomicUsize :: new ( 0 ) , 1 , 1 ) )
470478 . flatten ( )
471479 . collect ( )
472480 } else {
@@ -484,11 +492,13 @@ pub fn run(clap_config: &ArgMatches) {
484492 // Rayon seems to return thread count so half that for core count
485493 let num_cpus: usize = rayon:: current_num_threads ( ) / 2 ;
486494
495+ let num_crates = crates. len ( ) ;
496+
487497 // check all crates (default)
488498 crates
489499 . into_par_iter ( )
490500 . map ( |krate| krate. download_and_extract ( ) )
491- . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path, & counter, num_cpus) )
501+ . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path, & counter, num_cpus, num_crates ) )
492502 . flatten ( )
493503 . collect ( )
494504 } ;
0 commit comments