From 4c0148c0e0aa9b1911ad5ce52e1016dfd1251e55 Mon Sep 17 00:00:00 2001 From: mjsterckx Date: Thu, 9 Feb 2023 22:26:38 +0000 Subject: [PATCH 1/2] Makefile: changed Rust lint clippy to the one included in SDK --- Makefile.toml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 1b378ed5a7c..41b5a52cc9d 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -439,14 +439,21 @@ rc=0 export VARIANT="${BUILDSYS_VARIANT}" # For rust first-party source code -if ! cargo clippy \ - --manifest-path ${BUILDSYS_TOOLS_DIR}/Cargo.toml \ +if ! docker run --rm \ + -v "$(pwd)":/tmp \ + "${BUILDSYS_SDK_IMAGE}" \ + cargo clippy \ + --manifest-path /tmp/tools/Cargo.toml \ --locked -- -D warnings --no-deps; then rc=1 fi -if ! cargo clippy \ - --manifest-path ${BUILDSYS_SOURCES_DIR}/Cargo.toml \ +if ! docker run --rm \ + -v "$(pwd)":/tmp \ + -e VARIANT \ + "${BUILDSYS_SDK_IMAGE}" \ + cargo clippy \ + --manifest-path /tmp/sources/Cargo.toml \ --locked -- -D warnings --no-deps; then rc=1 fi From 54bb6bce557c0e2889d5bfa5df5aab2f12530c8b Mon Sep 17 00:00:00 2001 From: mjsterckx Date: Tue, 28 Feb 2023 22:10:44 +0000 Subject: [PATCH 2/2] tools: fixed clippy lint warnings --- tools/pubsys/src/repo.rs | 45 +++++++++++++++++++++++---------- tools/testsys-config/src/lib.rs | 5 +++- tools/testsys/src/error.rs | 5 +++- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/tools/pubsys/src/repo.rs b/tools/pubsys/src/repo.rs index efadccf4ed4..940f5918d09 100644 --- a/tools/pubsys/src/repo.rs +++ b/tools/pubsys/src/repo.rs @@ -644,20 +644,23 @@ mod error { #[snafu(display("Failed to add new target '{}' to repo: {}", path.display(), source))] AddTarget { path: PathBuf, - source: tough::error::Error, + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, }, #[snafu(display("Failed to build target metadata from path '{}': {}", path.display(), source))] BuildTarget { path: PathBuf, - source: tough::schema::Error, + #[snafu(source(from(tough::schema::Error, Box::new)))] + source: Box, }, #[snafu(display("Failed to copy target '{}' to '{}': {}", target.display(), path.display(), source))] CopyTarget { target: PathBuf, path: PathBuf, - source: tough::error::Error, + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, }, #[snafu(display("Error reading config: {}", source))] @@ -667,7 +670,10 @@ mod error { CreateDir { path: PathBuf, source: io::Error }, #[snafu(display("Failed to create repo editor from given repo: {}", source))] - EditorFromRepo { source: tough::error::Error }, + EditorFromRepo { + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, + }, #[snafu(display("Failed to read '{}': {}", path.display(), source))] File { path: PathBuf, source: io::Error }, @@ -685,7 +691,8 @@ mod error { LinkTarget { target: PathBuf, path: PathBuf, - source: tough::error::Error, + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, }, #[snafu(display("Failed to write Manifest to '{}': {}", path.display(), source))] @@ -701,7 +708,10 @@ mod error { MissingRepoUrls { repo: String }, #[snafu(display("Failed to create new repo editor: {}", source))] - NewEditor { source: tough::error::Error }, + NewEditor { + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, + }, #[snafu(display("Repo does not have a manifest.json: {}", metadata_url))] NoManifest { metadata_url: Url }, @@ -718,7 +728,8 @@ mod error { #[snafu(display("Failed to read target '{}' from repo: {}", target, source))] ReadTarget { target: String, - source: tough::error::Error, + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, }, #[snafu(display("Failed to create async runtime: {}", source))] @@ -727,7 +738,8 @@ mod error { #[snafu(display("Failed to parse target name from string '{}': {}", target, source))] ParseTargetName { target: String, - source: tough::error::Error, + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, }, #[snafu(display("Repo exists at '{}' - remove it and try again", path.display()))] @@ -743,31 +755,38 @@ mod error { ))] RepoLoad { metadata_base_url: Url, - source: tough::error::Error, + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, }, #[snafu(display("Requested repository does not exist: '{}'", url))] RepoNotFound { url: Url }, #[snafu(display("Failed to sign repository: {}", source))] - RepoSign { source: tough::error::Error }, + RepoSign { + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, + }, #[snafu(display("Failed to write repository to {}: {}", path.display(), source))] RepoWrite { path: PathBuf, - source: tough::error::Error, + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, }, #[snafu(display("Failed to set targets expiration to {}: {}", expiration, source))] SetTargetsExpiration { expiration: DateTime, - source: tough::error::Error, + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, }, #[snafu(display("Failed to set targets version to {}: {}", version, source))] SetTargetsVersion { version: u64, - source: tough::error::Error, + #[snafu(source(from(tough::error::Error, Box::new)))] + source: Box, }, #[snafu(display("Failed to set waves from '{}': {}", wave_policy_path.display(), source))] diff --git a/tools/testsys-config/src/lib.rs b/tools/testsys-config/src/lib.rs index e25d3c787fe..7aa87c51ab9 100644 --- a/tools/testsys-config/src/lib.rs +++ b/tools/testsys-config/src/lib.rs @@ -454,7 +454,10 @@ mod error { context(false), display("Failed to create template for cluster name: {}", source) )] - TemplateError { source: handlebars::TemplateError }, + TemplateError { + #[snafu(source(from(handlebars::TemplateError, Box::new)))] + source: Box, + }, #[snafu( context(false), diff --git a/tools/testsys/src/error.rs b/tools/testsys/src/error.rs index 2ce68b836b3..2e21f2dad1d 100644 --- a/tools/testsys/src/error.rs +++ b/tools/testsys/src/error.rs @@ -44,7 +44,10 @@ pub enum Error { context(false), display("Unable create template from yaml: {}", source) )] - HandlebarsTemplate { source: handlebars::TemplateError }, + HandlebarsTemplate { + #[snafu(source(from(handlebars::TemplateError, Box::new)))] + source: Box, + }, #[snafu(display("Unable to create map from {}: {}", what, source))] IntoMap { what: String, source: model::Error },