diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 760ef9749c7b4fe37e96c30a2cec87b43aa5dc9f..aa2b90ab3bdf5251bc14c8bcd3cbb3c2ab0a92a0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -77,7 +77,7 @@ clippy: stage: check <<: *docker-env script: - - cargo clippy --verbose -- -D warnings; + - cargo clippy --verbose --all-targets --all-features -- -D warnings; #### stage: test (all features) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 416eaa280e4155d56b4b2caaf1472b94a40aec26..2d1b0216929f23775b1e8a589c800c6fb937e614 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -643,10 +643,7 @@ mod tests_ci_only { /// Modifies the `Cargo.toml` under the supplied `cargo_toml_path` by /// setting `optimization-passes` in `[package.metadata.contract]` to `passes`. - fn write_optimization_passes_into_manifest( - cargo_toml_path: &PathBuf, - passes: OptimizationPasses, - ) { + fn write_optimization_passes_into_manifest(cargo_toml_path: &Path, passes: OptimizationPasses) { let manifest_path = ManifestPath::new(cargo_toml_path).expect("manifest path creation failed"); let mut manifest = Manifest::new(manifest_path.clone()).expect("manifest creation failed"); @@ -760,7 +757,7 @@ mod tests_ci_only { with_new_contract_project(|manifest_path| { // given write_optimization_passes_into_manifest( - &manifest_path.clone().into(), + manifest_path.as_ref(), OptimizationPasses::Three, ); let cmd = BuildCommand { @@ -798,7 +795,7 @@ mod tests_ci_only { with_new_contract_project(|manifest_path| { // given write_optimization_passes_into_manifest( - &manifest_path.clone().into(), + manifest_path.as_ref(), OptimizationPasses::Three, ); let cmd = BuildCommand { diff --git a/src/cmd/deploy.rs b/src/cmd/deploy.rs index 839fac2b73f301ec932e97745e65141869cf522a..2c58f754c8102e8f64ef781083cce7dfe8837e1a 100644 --- a/src/cmd/deploy.rs +++ b/src/cmd/deploy.rs @@ -66,7 +66,7 @@ pub(crate) fn execute_deploy( let events = cli.put_code_and_watch(&signer, &code).await?; let code_stored = events .code_stored()? - .ok_or(anyhow::anyhow!("Failed to find CodeStored event"))?; + .context("Failed to find CodeStored event")?; Ok(code_stored.code_hash) }) diff --git a/src/cmd/instantiate.rs b/src/cmd/instantiate.rs index 786bb1d32631413939b2c1bd7603fac7560e22ab..f451dab100656b46b1839e3f62b50f3ccf5b4a52 100644 --- a/src/cmd/instantiate.rs +++ b/src/cmd/instantiate.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with cargo-contract. If not, see . -use anyhow::Result; +use anyhow::{Context, Result}; use subxt::{balances::Balances, contracts::*, system::System, ClientBuilder, DefaultNodeRuntime}; use crate::{ExtrinsicOpts, HexData}; @@ -43,7 +43,7 @@ pub(crate) fn execute_instantiate( .await?; let instantiated = events .instantiated()? - .ok_or(anyhow::anyhow!("Failed to find Instantiated event"))?; + .context("Failed to find Instantiated event")?; Ok(instantiated.contract) }) diff --git a/src/cmd/metadata.rs b/src/cmd/metadata.rs index 8cd8184e4f52f32ec11a1f93b32de563c0a05487..6dbe5b4b10a513269f8dafb331e02460a5efc56a 100644 --- a/src/cmd/metadata.rs +++ b/src/cmd/metadata.rs @@ -228,6 +228,7 @@ mod tests { cmd, crate_metadata::CrateMetadata, util::tests::with_new_contract_project, BuildArtifacts, ManifestPath, OptimizationPasses, UnstableFlags, Verbosity, }; + use anyhow::Context; use contract_metadata::*; use serde_json::{Map, Value}; use std::{fmt::Write, fs}; @@ -249,9 +250,9 @@ mod tests { fn package_mut(&mut self) -> anyhow::Result<&mut value::Table> { self.toml .get_mut("package") - .ok_or(anyhow::anyhow!("package section not found"))? + .context("package section not found")? .as_table_mut() - .ok_or(anyhow::anyhow!("package section should be a table")) + .context("package section should be a table") } /// Add a key/value to the `[package.metadata.contract.user]` section @@ -264,19 +265,15 @@ mod tests { .entry("metadata") .or_insert(value::Value::Table(Default::default())) .as_table_mut() - .ok_or(anyhow::anyhow!("metadata section should be a table"))? + .context("metadata section should be a table")? .entry("contract") .or_insert(value::Value::Table(Default::default())) .as_table_mut() - .ok_or(anyhow::anyhow!( - "metadata.contract section should be a table" - ))? + .context("metadata.contract section should be a table")? .entry("user") .or_insert(value::Value::Table(Default::default())) .as_table_mut() - .ok_or(anyhow::anyhow!( - "metadata.contract.user section should be a table" - ))? + .context("metadata.contract.user section should be a table")? .insert(key.into(), value); Ok(()) } @@ -393,9 +390,7 @@ mod tests { .insert("some-user-provided-field".into(), "and-its-value".into()); expected_user_metadata.insert( "more-user-provided-fields".into(), - serde_json::Value::Array( - vec!["and".into(), "their".into(), "values".into()].into(), - ), + serde_json::Value::Array(vec!["and".into(), "their".into(), "values".into()]), ); assert_eq!(build_byte_str(&expected_hash.0[..]), hash.as_str().unwrap()); diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 7db38880436f6c58b0f0221b7fdc7f82fc6843ad..fba2d0b052014e8f1e8b6da9cb2a0543bc6e5ce8 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -188,17 +188,15 @@ impl Manifest { .entry("package") .or_insert(value::Value::Table(Default::default())) .as_table_mut() - .ok_or(anyhow::anyhow!("package section should be a table"))? + .context("package section should be a table")? .entry("metadata") .or_insert(value::Value::Table(Default::default())) .as_table_mut() - .ok_or(anyhow::anyhow!("metadata section should be a table"))? + .context("metadata section should be a table")? .entry("contract") .or_insert(value::Value::Table(Default::default())) .as_table_mut() - .ok_or(anyhow::anyhow!( - "metadata.contract section should be a table" - ))? + .context("metadata.contract section should be a table")? .insert( "optimization-passes".to_string(), value::Value::String(passes.to_string()),