Closed max-m closed 3 years ago
Clippy seems to be unhappy with code I didn’t touch. Here’s a diff of the changes Clippy proposes:
diff --git a/src/lib.rs b/src/lib.rs
index 927eede..e7e4881 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,4 @@
+use cargo_metadata::camino::Utf8PathBuf;
use serde_derive::Serialize;
use std::collections::{HashMap, HashSet};
@@ -31,28 +32,25 @@ impl DependencyDetails {
let authors = if package.authors.is_empty() {
None
} else {
- Some(package.authors.to_owned().join("|"))
+ Some(package.authors.clone().join("|"))
};
Self {
- name: package.name.to_owned(),
- version: package.version.to_owned(),
+ name: package.name.clone(),
+ version: package.version.clone(),
authors,
- repository: package.repository.to_owned(),
+ repository: package.repository.clone(),
license: package.license.as_ref().map(|s| normalize(&s)),
- license_file: package
- .license_file
- .to_owned()
- .map(|f| f.into_string()),
+ license_file: package.license_file.clone().map(Utf8PathBuf::into_string),
description: package
.description
- .to_owned()
+ .clone()
.map(|s| s.trim().replace("\n", " ")),
}
}
}
pub fn get_dependencies_from_cargo_lock(
- metadata_command: cargo_metadata::MetadataCommand,
+ metadata_command: &cargo_metadata::MetadataCommand,
avoid_dev_deps: bool,
avoid_build_deps: bool,
) -> Result<Vec<DependencyDetails>> {
diff --git a/src/main.rs b/src/main.rs
index c2ab82b..206b098 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -115,7 +115,7 @@ fn write_json(dependencies: &[cargo_license::DependencyDetails]) -> cargo_licens
}
#[derive(Debug, StructOpt)]
-#[allow(clippy::clippy::struct_excessive_bools)]
+#[allow(clippy::struct_excessive_bools)]
#[structopt(
bin_name = "cargo license",
about = "Cargo subcommand to see licenses of dependencies."
@@ -215,7 +215,7 @@ fn run() -> cargo_license::Result<()> {
}
let dependencies = cargo_license::get_dependencies_from_cargo_lock(
- cmd,
+ &cmd,
opt.avoid_dev_deps,
opt.avoid_build_deps,
)?;
Additionally Clippy would also like documentation about possible errors on get_dependencies_from_cargo_lock
.
If I understand it correctly that function might fail if:
stdout
or stderr
Thanks. The deps bump was merges at #49.
Hi, I use
cargo-license
as library in thebuild.rs
of one of my projects to embed a list of dependencies and their licenses in my binary and noticed that some dependencies likecargo_metadata
were outdated. I’ve usedcargo upgrade
to bump the dependencies and fixed the resulting issues that prevented successful compilation.cargo test
completed without errors so I assume everything went fine :smile: