lintcheck: cleanup, fix --only for git crates, better error msgs

This commit is contained in:
Matthias Krüger 2021-02-06 12:04:31 +01:00
parent 9ab505a3c7
commit e1c284bff7
2 changed files with 19 additions and 8 deletions

View File

@ -16,7 +16,6 @@ use std::{fmt, fs::write, path::PathBuf};
use clap::ArgMatches;
use serde::{Deserialize, Serialize};
use serde_json::Value;
//use git2::Repository;
// use this to store the crates when interacting with the crates.toml file
#[derive(Debug, Serialize, Deserialize)]
@ -42,7 +41,8 @@ enum CrateSource {
}
// represents the extracted sourcecode of a crate
// 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)
// 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)
#[derive(Debug)]
struct Crate {
version: String,
@ -229,7 +229,10 @@ fn read_crates() -> Vec<CrateSource> {
if tk.versions.is_some() && (tk.git_url.is_some() || tk.git_hash.is_some())
|| tk.git_hash.is_some() != tk.git_url.is_some()
{
dbg!(tk);
dbg!(&tk);
if tk.git_hash.is_some() != tk.git_url.is_some() {
panic!("Encountered TomlCrate with only one of git_hash and git_url!")
}
unreachable!("Failed to translate TomlCrate into CrateSource!");
}
});
@ -287,14 +290,20 @@ pub fn run(clap_config: &ArgMatches) {
let crates = read_crates();
let clippy_warnings: Vec<ClippyWarning> = if let Some(only_one_crate) = clap_config.value_of("only") {
// if we don't have the specified crated in the .toml, throw an error
/* if !crates.iter().any(|krate| krate.name == only_one_crate) {
// if we don't have the specified crate in the .toml, throw an error
if !crates.iter().any(|krate| {
let name = match krate {
CrateSource::CratesIo { name, .. } => name,
CrateSource::Git { name, .. } => name,
};
name == only_one_crate
}) {
eprintln!(
"ERROR: could not find crate '{}' in clippy_dev/lintcheck_crates.toml",
only_one_crate
);
std::process::exit(1);
} */ //@FIXME
}
// only check a single crate that was passed via cmdline
crates

View File

@ -1,4 +1,4 @@
clippy 0.1.51 (3e4179766 2021-02-03)
clippy 0.1.51 (7f5bb7fd0 2021-02-06)
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"
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
cargo-0.49.0/src/cargo/ops/cargo_install.rs:454:22 clippy::redundant_closure_for_method_calls "redundant closure found"
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"
cargo-0.49.0/src/cargo/ops/cargo_install.rs:683:1 clippy::missing_errors_doc "docs for function returning `Result` missing `# Errors` section"
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"
cargo-0.49.0/src/cargo/ops/cargo_new.rs:101:5 clippy::missing_errors_doc "docs for function returning `Result` missing `# Errors` section"
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"
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
ripgrep-12.1.1/crates/core/subject.rs:20:1 clippy::module_name_repetitions "item name starts with its containing module's name"
ripgrep-12.1.1/crates/core/subject.rs:4:1 clippy::single_component_path_imports "this import is redundant"
syn-1.0.54/build.rs:1:null clippy::cargo_common_metadata "package `syn` is missing `package.keywords` metadata"
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`"
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`"
syn-1.0.54/src/generics.rs:174:5 clippy::missing_panics_doc "docs for function which may panic missing `# Panics` section"
syn-1.0.54/src/lib.rs:1:null clippy::cargo_common_metadata "package `syn` is missing `package.keywords` metadata"
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
clippy::from_iter_instead_of_collect 1
clippy::from_over_into 1
clippy::int_plus_one 1
clippy::manual_flatten 1
clippy::manual_saturating_arithmetic 1
clippy::mem_replace_with_default 1
clippy::nonminimal_bool 1