Skip to content

Commit 202c46c

Browse files
committed
remove duplicate code and other cleanup
1 parent 0351988 commit 202c46c

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

clippy_dev/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
2-
authors = ["Philipp Hansch <[email protected]>"]
3-
edition = "2018"
42
name = "clippy_dev"
53
version = "0.0.1"
4+
authors = ["Philipp Hansch <[email protected]>"]
5+
edition = "2018"
66

77
[dependencies]
88
bytecount = "0.6"

clippy_dev/src/crater.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ use std::{fs::write, path::PathBuf};
1414

1515
use serde::{Deserialize, Serialize};
1616

17-
// crate data we stored in the toml, can have multiple versions.
18-
// if so, one TomlKrate maps to several KrateSources
17+
// use this to store the crates when interacting with the crates.toml file
18+
#[derive(Debug, Serialize, Deserialize)]
19+
struct CrateList {
20+
crates: HashMap<String, Vec<String>>,
21+
}
22+
23+
// crate data we stored in the toml, can have multiple versions per crate
24+
// A single TomlCrate is laster mapped to several CrateSources in that case
1925
struct TomlCrate {
2026
name: String,
2127
versions: Vec<String>,
@@ -28,12 +34,6 @@ struct CrateSource {
2834
version: String,
2935
}
3036

31-
// use this to store the crates when interacting with the crates.toml file
32-
#[derive(Debug, Serialize, Deserialize)]
33-
struct CrateList {
34-
crates: HashMap<String, Vec<String>>,
35-
}
36-
3737
// represents the extracted sourcecode of a crate
3838
#[derive(Debug)]
3939
struct Crate {
@@ -70,14 +70,8 @@ impl CrateSource {
7070
// unzip the tarball
7171
let ungz_tar = flate2::read::GzDecoder::new(std::fs::File::open(&krate_file_path).unwrap());
7272
// extract the tar archive
73-
let mut archiv = tar::Archive::new(ungz_tar);
74-
archiv.unpack(&extract_dir).expect("Failed to extract!");
75-
76-
// unzip the tarball
77-
let ungz_tar = flate2::read::GzDecoder::new(std::fs::File::open(&krate_file_path).unwrap());
78-
// extract the tar archive
79-
let mut archiv = tar::Archive::new(ungz_tar);
80-
archiv.unpack(&extract_dir).expect("Failed to extract!");
73+
let mut archive = tar::Archive::new(ungz_tar);
74+
archive.unpack(&extract_dir).expect("Failed to extract!");
8175
}
8276
// crate is extracted, return a new Krate object which contains the path to the extracted
8377
// sources that clippy can check
@@ -132,7 +126,7 @@ impl Crate {
132126
})
133127
.collect();
134128

135-
// sort messages alphabtically to avoid noise in the logs
129+
// sort messages alphabetically to avoid noise in the logs
136130
output.sort();
137131
output
138132
}

mini-crater/logs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,7 @@ iron-0.6.1/src/request/mod.rs:85:24: binding's name is too similar to existing b
14231423
iron-0.6.1/src/request/url.rs:109:5: this method could have a `#[must_use]` attribute
14241424
iron-0.6.1/src/request/url.rs:117:5: this method could have a `#[must_use]` attribute
14251425
iron-0.6.1/src/request/url.rs:124:9: use of deprecated macro `try`: use the `?` operator instead
1426+
iron-0.6.1/src/request/url.rs:129:1: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
14261427
iron-0.6.1/src/request/url.rs:21:14: you should put bare URLs between `<`/`>` or make a proper Markdown link
14271428
iron-0.6.1/src/request/url.rs:22:5: docs for function returning `Result` missing `# Errors` section
14281429
iron-0.6.1/src/request/url.rs:31:5: docs for function returning `Result` missing `# Errors` section

0 commit comments

Comments
 (0)