@@ -63,20 +63,26 @@ impl KrateSource {
63
63
}
64
64
65
65
impl Krate {
66
- fn run_clippy_lints ( & self , cargo_clippy_path : & PathBuf ) -> String {
66
+ fn run_clippy_lints ( & self , cargo_clippy_path : & PathBuf ) -> Vec < String > {
67
67
let cargo_clippy_path = std:: fs:: canonicalize ( cargo_clippy_path) . unwrap ( ) ;
68
68
let project_root = & self . path ;
69
69
dbg ! ( & cargo_clippy_path) ;
70
70
dbg ! ( & project_root) ;
71
71
72
72
let output = std:: process:: Command :: new ( cargo_clippy_path)
73
- . args ( & [ "--" , "--message-format=short" , "--" , "--cap-lints=warn" , ] )
73
+ . args ( & [ "--" , "--message-format=short" , "--" , "--cap-lints=warn" ] )
74
74
. current_dir ( project_root)
75
- . output ( ) ;
76
- let output: String = String :: from_utf8_lossy ( & output. unwrap ( ) . stderr ) . lines ( ) . filter ( |line|line. contains ( ": warning: " ) ) . collect ( ) ;
77
- // output.lines().for_each(|l| println!("{}", l));
78
- //dbg!(&output);
79
-
75
+ . output ( )
76
+ . unwrap ( ) ;
77
+ let mut output = String :: from_utf8_lossy ( & output. stderr ) ;
78
+ let output: Vec < & str > = output. lines ( ) . collect ( ) ;
79
+ let mut output: Vec < String > = output
80
+ . into_iter ( )
81
+ . filter ( |line| line. contains ( ": warning: " ) )
82
+ . map ( |l| l. to_string ( ) )
83
+ . collect ( ) ;
84
+
85
+ output. sort ( ) ;
80
86
output
81
87
}
82
88
}
@@ -113,10 +119,13 @@ pub fn run() {
113
119
) ;
114
120
115
121
// download and extract the crates, then run clippy on them and collect clippys warnings
116
- let clippy_lint_results: Vec < String > = krates
122
+ let clippy_lint_results: Vec < Vec < String > > = krates
117
123
. into_iter ( )
118
124
. map ( |krate| krate. download_and_extract ( ) )
119
125
. map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path) )
120
- . collect :: < Vec < String > > ( ) ;
121
- dbg ! ( clippy_lint_results) ;
126
+ . collect ( ) ;
127
+
128
+ let results: Vec < String > = clippy_lint_results. into_iter ( ) . flatten ( ) . collect ( ) ;
129
+
130
+ results. iter ( ) . for_each ( |l| println ! ( "{}" , l) ) ;
122
131
}
0 commit comments