Skip to content

Commit

Permalink
remove duplicate code and other cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Dec 23, 2020
1 parent 0351988 commit 202c46c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions clippy_dev/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
authors = ["Philipp Hansch <dev@phansch.net>"]
edition = "2018"
name = "clippy_dev"
version = "0.0.1"
authors = ["Philipp Hansch <dev@phansch.net>"]
edition = "2018"

[dependencies]
bytecount = "0.6"
Expand Down
28 changes: 11 additions & 17 deletions clippy_dev/src/crater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ use std::{fs::write, path::PathBuf};

use serde::{Deserialize, Serialize};

// crate data we stored in the toml, can have multiple versions.
// if so, one TomlKrate maps to several KrateSources
// use this to store the crates when interacting with the crates.toml file
#[derive(Debug, Serialize, Deserialize)]
struct CrateList {
crates: HashMap<String, Vec<String>>,
}

// crate data we stored in the toml, can have multiple versions per crate
// A single TomlCrate is laster mapped to several CrateSources in that case
struct TomlCrate {
name: String,
versions: Vec<String>,
Expand All @@ -28,12 +34,6 @@ struct CrateSource {
version: String,
}

// use this to store the crates when interacting with the crates.toml file
#[derive(Debug, Serialize, Deserialize)]
struct CrateList {
crates: HashMap<String, Vec<String>>,
}

// represents the extracted sourcecode of a crate
#[derive(Debug)]
struct Crate {
Expand Down Expand Up @@ -70,14 +70,8 @@ impl CrateSource {
// unzip the tarball
let ungz_tar = flate2::read::GzDecoder::new(std::fs::File::open(&krate_file_path).unwrap());
// extract the tar archive
let mut archiv = tar::Archive::new(ungz_tar);
archiv.unpack(&extract_dir).expect("Failed to extract!");

// unzip the tarball
let ungz_tar = flate2::read::GzDecoder::new(std::fs::File::open(&krate_file_path).unwrap());
// extract the tar archive
let mut archiv = tar::Archive::new(ungz_tar);
archiv.unpack(&extract_dir).expect("Failed to extract!");
let mut archive = tar::Archive::new(ungz_tar);
archive.unpack(&extract_dir).expect("Failed to extract!");
}
// crate is extracted, return a new Krate object which contains the path to the extracted
// sources that clippy can check
Expand Down Expand Up @@ -132,7 +126,7 @@ impl Crate {
})
.collect();

// sort messages alphabtically to avoid noise in the logs
// sort messages alphabetically to avoid noise in the logs
output.sort();
output
}
Expand Down
1 change: 1 addition & 0 deletions mini-crater/logs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,7 @@ iron-0.6.1/src/request/mod.rs:85:24: binding's name is too similar to existing b
iron-0.6.1/src/request/url.rs:109:5: this method could have a `#[must_use]` attribute
iron-0.6.1/src/request/url.rs:117:5: this method could have a `#[must_use]` attribute
iron-0.6.1/src/request/url.rs:124:9: use of deprecated macro `try`: use the `?` operator instead
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
iron-0.6.1/src/request/url.rs:21:14: you should put bare URLs between `<`/`>` or make a proper Markdown link
iron-0.6.1/src/request/url.rs:22:5: docs for function returning `Result` missing `# Errors` section
iron-0.6.1/src/request/url.rs:31:5: docs for function returning `Result` missing `# Errors` section
Expand Down

0 comments on commit 202c46c

Please sign in to comment.