@@ -63,20 +63,26 @@ impl KrateSource {
6363}
6464
6565impl Krate {
66- fn run_clippy_lints ( & self , cargo_clippy_path : & PathBuf ) -> String {
66+ fn run_clippy_lints ( & self , cargo_clippy_path : & PathBuf ) -> Vec < String > {
6767 let cargo_clippy_path = std:: fs:: canonicalize ( cargo_clippy_path) . unwrap ( ) ;
6868 let project_root = & self . path ;
6969 dbg ! ( & cargo_clippy_path) ;
7070 dbg ! ( & project_root) ;
7171
7272 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" ] )
7474 . 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 ( ) ;
8086 output
8187 }
8288}
@@ -113,10 +119,13 @@ pub fn run() {
113119 ) ;
114120
115121 // 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
117123 . into_iter ( )
118124 . map ( |krate| krate. download_and_extract ( ) )
119125 . 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) ) ;
122131}
0 commit comments