@@ -496,7 +496,7 @@ fn gather_stats(clippy_warnings: &[ClippyWarning]) -> (String, HashMap<&String,
496
496
497
497
/// check if the latest modification of the logfile is older than the modification date of the
498
498
/// clippy binary, if this is true, we should clean the lintchec shared target directory and recheck
499
- fn lintcheck_needs_rerun ( toml_path : & PathBuf ) -> bool {
499
+ fn lintcheck_needs_rerun ( lintcheck_logs_path : & PathBuf ) -> bool {
500
500
let clippy_modified: std:: time:: SystemTime = {
501
501
let mut times = [ CLIPPY_DRIVER_PATH , CARGO_CLIPPY_PATH ] . iter ( ) . map ( |p| {
502
502
std:: fs:: metadata ( p)
@@ -505,17 +505,17 @@ fn lintcheck_needs_rerun(toml_path: &PathBuf) -> bool {
505
505
. expect ( "failed to get modification date" )
506
506
} ) ;
507
507
// the oldest modification of either of the binaries
508
- std:: cmp:: min ( times. next ( ) . unwrap ( ) , times. next ( ) . unwrap ( ) )
508
+ std:: cmp:: max ( times. next ( ) . unwrap ( ) , times. next ( ) . unwrap ( ) )
509
509
} ;
510
510
511
- let logs_modified: std:: time:: SystemTime = std:: fs:: metadata ( toml_path )
511
+ let logs_modified: std:: time:: SystemTime = std:: fs:: metadata ( lintcheck_logs_path )
512
512
. expect ( "failed to get metadata of file" )
513
513
. modified ( )
514
514
. expect ( "failed to get modification date" ) ;
515
515
516
- // if clippys modification time is smaller (older) than the logs mod time, we need to rerun
517
- // lintcheck
518
- clippy_modified < logs_modified
516
+ // time is represented in seconds since X
517
+ // logs_modified 2 and clippy_modified 5 means clippy binary is older and we need to recheck
518
+ logs_modified < clippy_modified
519
519
}
520
520
521
521
/// lintchecks `main()` function
@@ -528,7 +528,7 @@ pub fn run(clap_config: &ArgMatches) {
528
528
529
529
// if the clippy bin is newer than our logs, throw away target dirs to force clippy to
530
530
// refresh the logs
531
- if lintcheck_needs_rerun ( & config. sources_toml_path ) {
531
+ if lintcheck_needs_rerun ( & config. lintcheck_results_path ) {
532
532
let shared_target_dir = "target/lintcheck/shared_target_dir" ;
533
533
match std:: fs:: metadata ( & shared_target_dir) {
534
534
Ok ( metadata) => {
@@ -538,8 +538,7 @@ pub fn run(clap_config: &ArgMatches) {
538
538
. expect ( "failed to remove target/lintcheck/shared_target_dir" ) ;
539
539
}
540
540
} ,
541
- Err ( _) => { // dir probably does not exist, don't remove anything
542
- } ,
541
+ Err ( _) => { /* dir probably does not exist, don't remove anything */ } ,
543
542
}
544
543
}
545
544
@@ -566,6 +565,8 @@ pub fn run(clap_config: &ArgMatches) {
566
565
let crates = read_crates ( & config. sources_toml_path ) ;
567
566
let old_stats = read_stats_from_file ( & config. lintcheck_results_path ) ;
568
567
568
+ let counter = AtomicUsize :: new ( 1 ) ;
569
+
569
570
let clippy_warnings: Vec < ClippyWarning > = if let Some ( only_one_crate) = clap_config. value_of ( "only" ) {
570
571
// if we don't have the specified crate in the .toml, throw an error
571
572
if !crates. iter ( ) . any ( |krate| {
@@ -595,8 +596,6 @@ pub fn run(clap_config: &ArgMatches) {
595
596
if config. max_jobs > 1 {
596
597
// run parallel with rayon
597
598
598
- let counter = AtomicUsize :: new ( 0 ) ;
599
-
600
599
// Ask rayon for thread count. Assume that half of that is the number of physical cores
601
600
// Use one target dir for each core so that we can run N clippys in parallel.
602
601
// We need to use different target dirs because cargo would lock them for a single build otherwise,
@@ -623,7 +622,7 @@ pub fn run(clap_config: &ArgMatches) {
623
622
crates
624
623
. into_iter ( )
625
624
. map ( |krate| krate. download_and_extract ( ) )
626
- . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path, & AtomicUsize :: new ( 0 ) , 1 , num_crates) )
625
+ . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path, & counter , 1 , num_crates) )
627
626
. flatten ( )
628
627
. collect ( )
629
628
}
0 commit comments