@@ -222,12 +222,17 @@ impl Crate {
222
222
cargo_clippy_path : & PathBuf ,
223
223
target_dir_index : & AtomicUsize ,
224
224
thread_limit : usize ,
225
+ total_crates_to_lint : usize ,
225
226
) -> Vec < ClippyWarning > {
226
227
// 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 ) ;
228
229
// "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
+ ) ;
231
236
let cargo_clippy_path = std:: fs:: canonicalize ( cargo_clippy_path) . unwrap ( ) ;
232
237
233
238
let shared_target_dir = clippy_project_root ( ) . join ( "target/lintcheck/shared_target_dir" ) ;
@@ -244,7 +249,10 @@ impl Crate {
244
249
245
250
let all_output = std:: process:: Command :: new ( & cargo_clippy_path)
246
251
// 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
+ )
248
256
// lint warnings will look like this:
249
257
// src/cargo/ops/cargo_compile.rs:127:35: warning: usage of `FromIterator::from_iter`
250
258
. args ( & args)
@@ -466,7 +474,7 @@ pub fn run(clap_config: &ArgMatches) {
466
474
. into_iter ( )
467
475
. map ( |krate| krate. download_and_extract ( ) )
468
476
. 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 ) )
470
478
. flatten ( )
471
479
. collect ( )
472
480
} else {
@@ -484,11 +492,13 @@ pub fn run(clap_config: &ArgMatches) {
484
492
// Rayon seems to return thread count so half that for core count
485
493
let num_cpus: usize = rayon:: current_num_threads ( ) / 2 ;
486
494
495
+ let num_crates = crates. len ( ) ;
496
+
487
497
// check all crates (default)
488
498
crates
489
499
. into_par_iter ( )
490
500
. 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 ) )
492
502
. flatten ( )
493
503
. collect ( )
494
504
} ;
0 commit comments