Skip to content

Commit e1c284b

Browse files
committed
lintcheck: cleanup, fix --only for git crates, better error msgs
1 parent 9ab505a commit e1c284b

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

clippy_dev/src/lintcheck.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::{fmt, fs::write, path::PathBuf};
1616
use clap::ArgMatches;
1717
use serde::{Deserialize, Serialize};
1818
use serde_json::Value;
19-
//use git2::Repository;
2019

2120
// use this to store the crates when interacting with the crates.toml file
2221
#[derive(Debug, Serialize, Deserialize)]
@@ -42,7 +41,8 @@ enum CrateSource {
4241
}
4342

4443
// represents the extracted sourcecode of a crate
45-
// we actually don't need to special-case git repos here because it does not matter for clippy, yay! (clippy only needs a simple path)
44+
// we actually don't need to special-case git repos here because it does not matter for clippy, yay!
45+
// (clippy only needs a simple path)
4646
#[derive(Debug)]
4747
struct Crate {
4848
version: String,
@@ -229,7 +229,10 @@ fn read_crates() -> Vec<CrateSource> {
229229
if tk.versions.is_some() && (tk.git_url.is_some() || tk.git_hash.is_some())
230230
|| tk.git_hash.is_some() != tk.git_url.is_some()
231231
{
232-
dbg!(tk);
232+
dbg!(&tk);
233+
if tk.git_hash.is_some() != tk.git_url.is_some() {
234+
panic!("Encountered TomlCrate with only one of git_hash and git_url!")
235+
}
233236
unreachable!("Failed to translate TomlCrate into CrateSource!");
234237
}
235238
});
@@ -287,14 +290,20 @@ pub fn run(clap_config: &ArgMatches) {
287290
let crates = read_crates();
288291

289292
let clippy_warnings: Vec<ClippyWarning> = if let Some(only_one_crate) = clap_config.value_of("only") {
290-
// if we don't have the specified crated in the .toml, throw an error
291-
/* if !crates.iter().any(|krate| krate.name == only_one_crate) {
293+
// if we don't have the specified crate in the .toml, throw an error
294+
if !crates.iter().any(|krate| {
295+
let name = match krate {
296+
CrateSource::CratesIo { name, .. } => name,
297+
CrateSource::Git { name, .. } => name,
298+
};
299+
name == only_one_crate
300+
}) {
292301
eprintln!(
293302
"ERROR: could not find crate '{}' in clippy_dev/lintcheck_crates.toml",
294303
only_one_crate
295304
);
296305
std::process::exit(1);
297-
} */ //@FIXME
306+
}
298307

299308
// only check a single crate that was passed via cmdline
300309
crates

lintcheck-logs/logs.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
clippy 0.1.51 (3e4179766 2021-02-03)
1+
clippy 0.1.51 (7f5bb7fd0 2021-02-06)
22

33
cargo-0.49.0//home/matthias/.rustup/toolchains/nightly-2021-02-03-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/macros/mod.rs:409:34 clippy::match_same_arms "this `match` has identical arm bodies"
44
cargo-0.49.0/build.rs:1:null clippy::cargo_common_metadata "package `cargo` is missing `package.categories` metadata"
@@ -855,6 +855,7 @@ cargo-0.49.0/src/cargo/ops/cargo_install.rs:37:1 clippy::missing_errors_doc "doc
855855
cargo-0.49.0/src/cargo/ops/cargo_install.rs:454:22 clippy::redundant_closure_for_method_calls "redundant closure found"
856856
cargo-0.49.0/src/cargo/ops/cargo_install.rs:483:5 clippy::items_after_statements "adding items after statements is confusing, since items exist from the start of the scope"
857857
cargo-0.49.0/src/cargo/ops/cargo_install.rs:683:1 clippy::missing_errors_doc "docs for function returning `Result` missing `# Errors` section"
858+
cargo-0.49.0/src/cargo/ops/cargo_install.rs:708:5 clippy::manual_flatten "unnecessary `if let` since only the `Some` variant of the iterator element is used"
858859
cargo-0.49.0/src/cargo/ops/cargo_new.rs:101:5 clippy::missing_errors_doc "docs for function returning `Result` missing `# Errors` section"
859860
cargo-0.49.0/src/cargo/ops/cargo_new.rs:245:5 clippy::items_after_statements "adding items after statements is confusing, since items exist from the start of the scope"
860861
cargo-0.49.0/src/cargo/ops/cargo_new.rs:251:5 clippy::items_after_statements "adding items after statements is confusing, since items exist from the start of the scope"
@@ -3216,7 +3217,7 @@ ripgrep-12.1.1/crates/core/search.rs:533:5 clippy::cast_precision_loss "casting
32163217
ripgrep-12.1.1/crates/core/subject.rs:20:1 clippy::module_name_repetitions "item name starts with its containing module's name"
32173218
ripgrep-12.1.1/crates/core/subject.rs:4:1 clippy::single_component_path_imports "this import is redundant"
32183219
syn-1.0.54/build.rs:1:null clippy::cargo_common_metadata "package `syn` is missing `package.keywords` metadata"
3219-
syn-1.0.54/build.rs:1:null clippy::multiple_crate_versions "could not read cargo metadata: `cargo metadata` exited with an error: Downloading crates ...\n Downloaded httparse v1.3.5\n Downloaded tokio v0.2.25\n Downloaded syn-test-suite v0.0.0\nerror: failed to verify the checksum of `syn-test-suite v0.0.0`"
3220+
syn-1.0.54/build.rs:1:null clippy::multiple_crate_versions "could not read cargo metadata: `cargo metadata` exited with an error: Downloading crates ...\n Downloaded syn-test-suite v0.0.0\nerror: failed to verify the checksum of `syn-test-suite v0.0.0`"
32203221
syn-1.0.54/src/generics.rs:174:5 clippy::missing_panics_doc "docs for function which may panic missing `# Panics` section"
32213222
syn-1.0.54/src/lib.rs:1:null clippy::cargo_common_metadata "package `syn` is missing `package.keywords` metadata"
32223223
syn-1.0.54/src/lib.rs:1:null clippy::multiple_crate_versions "could not read cargo metadata: `cargo metadata` exited with an error: Downloading crates ...\n Downloaded syn-test-suite v0.0.0\nerror: failed to verify the checksum of `syn-test-suite v0.0.0`"
@@ -3425,6 +3426,7 @@ clippy::explicit_deref_methods 1
34253426
clippy::from_iter_instead_of_collect 1
34263427
clippy::from_over_into 1
34273428
clippy::int_plus_one 1
3429+
clippy::manual_flatten 1
34283430
clippy::manual_saturating_arithmetic 1
34293431
clippy::mem_replace_with_default 1
34303432
clippy::nonminimal_bool 1

0 commit comments

Comments
 (0)