From d257915f8dd7ee8656390a8e177d50600d160bc3 Mon Sep 17 00:00:00 2001 From: olegnn Date: Fri, 1 Sep 2023 15:52:09 +0200 Subject: [PATCH] `fmt` + CI tweaks --- .github/workflows/lint.yml | 6 +++--- pallets/core/src/common/mod.rs | 2 +- pallets/core/src/modules/accumulator/mod.rs | 5 ++--- pallets/core/src/modules/attest/mod.rs | 3 +-- pallets/core/src/modules/did/base/mod.rs | 6 ++++-- pallets/core/src/modules/did/benchmarks.rs | 2 +- pallets/core/src/modules/did/mod.rs | 2 +- pallets/core/src/modules/offchain_signatures/migration.rs | 4 ++-- pallets/core/src/modules/offchain_signatures/mod.rs | 3 +-- pallets/core/src/modules/offchain_signatures/params.rs | 2 +- pallets/core/src/modules/offchain_signatures/public_key.rs | 2 +- pallets/core/src/modules/offchain_signatures/schemes.rs | 4 ++-- pallets/core/src/modules/offchain_signatures/tests.rs | 2 +- pallets/core/src/modules/revoke/mod.rs | 3 +-- pallets/core/src/modules/revoke/tests.rs | 2 +- pallets/core/src/modules/status_list_credential/mod.rs | 3 +-- pallets/core/src/modules/status_list_credential/tests.rs | 2 +- pallets/core/src/util/hex.rs | 2 +- pallets/core/src/util/with_nonce.rs | 3 +-- 19 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index daf39980c..553536599 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: override: true components: rustfmt - name: Ensure Standard Formatting - run: cargo +nightly-2023-03-09 fmt -- --check --all + run: cargo +nightly-2023-03-09 fmt --all -- --check clippy: runs-on: ubuntu-latest @@ -29,6 +29,6 @@ jobs: with: toolchain: nightly-2023-03-09 override: true - components: rustfmt + components: clippy - name: Ensure `clippy` is happy - run: cargo +nightly-2023-03-09 clippy -- --all --all-targets + run: cargo +nightly-2023-03-09 clippy --all diff --git a/pallets/core/src/common/mod.rs b/pallets/core/src/common/mod.rs index 5b32ef499..4786a8256 100644 --- a/pallets/core/src/common/mod.rs +++ b/pallets/core/src/common/mod.rs @@ -10,4 +10,4 @@ pub use policy::*; pub use signatures::*; pub use state_change::*; pub use storage_version::*; -pub use types::*; \ No newline at end of file +pub use types::*; diff --git a/pallets/core/src/modules/accumulator/mod.rs b/pallets/core/src/modules/accumulator/mod.rs index 8977bfe95..e16a45f62 100644 --- a/pallets/core/src/modules/accumulator/mod.rs +++ b/pallets/core/src/modules/accumulator/mod.rs @@ -1,5 +1,5 @@ use crate::{ - common::{SigValue, StorageVersion, CurveType}, + common::{CurveType, SigValue, StorageVersion}, did, did::{Did, DidSignature}, util::{Bytes, IncId}, @@ -7,7 +7,6 @@ use crate::{ pub use actions::*; use arith_utils::DivCeil; use codec::{Decode, Encode}; -use sp_std::fmt::Debug; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, dispatch::{DispatchResult, Weight}, @@ -15,7 +14,7 @@ use frame_support::{ traits::Get, }; use frame_system::{self as system, ensure_signed}; -use sp_std::prelude::*; +use sp_std::{fmt::Debug, prelude::*}; pub use types::*; use weights::*; diff --git a/pallets/core/src/modules/attest/mod.rs b/pallets/core/src/modules/attest/mod.rs index 480ebd36e..abd9a8ea0 100644 --- a/pallets/core/src/modules/attest/mod.rs +++ b/pallets/core/src/modules/attest/mod.rs @@ -7,13 +7,12 @@ use crate::{ did::{self, Did, DidSignature}, }; use codec::{Decode, Encode}; -use sp_std::fmt::Debug; use frame_support::{ decl_error, decl_module, decl_storage, dispatch::DispatchResult, ensure, traits::Get, weights::Weight, }; use frame_system::{self as system, ensure_signed}; -use sp_std::prelude::*; +use sp_std::{fmt::Debug, prelude::*}; use weights::*; #[cfg(feature = "runtime-benchmarks")] diff --git a/pallets/core/src/modules/did/base/mod.rs b/pallets/core/src/modules/did/base/mod.rs index 2bd9563f2..eba238fb4 100644 --- a/pallets/core/src/modules/did/base/mod.rs +++ b/pallets/core/src/modules/did/base/mod.rs @@ -1,7 +1,9 @@ use crate::impl_wrapper; use codec::{Decode, Encode}; -use sp_std::fmt::Debug; -use sp_std::ops::{Index, RangeFull}; +use sp_std::{ + fmt::Debug, + ops::{Index, RangeFull}, +}; use super::*; diff --git a/pallets/core/src/modules/did/benchmarks.rs b/pallets/core/src/modules/did/benchmarks.rs index b47f574a7..0a298f7b5 100644 --- a/pallets/core/src/modules/did/benchmarks.rs +++ b/pallets/core/src/modules/did/benchmarks.rs @@ -1,10 +1,10 @@ use super::*; use crate::common::state_change::ToStateChange; use alloc::collections::BTreeSet; -use sp_std::iter::once; use frame_benchmarking::{benchmarks, whitelisted_caller}; use sp_application_crypto::Pair; use sp_core::{ed25519, U256}; +use sp_std::iter::once; #[cfg(not(feature = "std"))] use sp_std::prelude::*; use system::RawOrigin; diff --git a/pallets/core/src/modules/did/mod.rs b/pallets/core/src/modules/did/mod.rs index 448b89e45..2491fafcd 100644 --- a/pallets/core/src/modules/did/mod.rs +++ b/pallets/core/src/modules/did/mod.rs @@ -6,7 +6,6 @@ use crate::{ use arith_utils::DivCeil; use codec::{Decode, Encode}; -use sp_std::fmt::Debug; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, dispatch::DispatchResult, ensure, fail, traits::Get, weights::Weight, @@ -16,6 +15,7 @@ use sp_runtime::DispatchError; use sp_std::{ collections::btree_set::BTreeSet, convert::{TryFrom, TryInto}, + fmt::Debug, prelude::*, vec::Vec, }; diff --git a/pallets/core/src/modules/offchain_signatures/migration.rs b/pallets/core/src/modules/offchain_signatures/migration.rs index f944bf08f..492f97d57 100644 --- a/pallets/core/src/modules/offchain_signatures/migration.rs +++ b/pallets/core/src/modules/offchain_signatures/migration.rs @@ -1,6 +1,6 @@ use crate::{ - did::*, common::CurveType, + did::*, offchain_signatures::{ self, Config, OffchainPublicKey, OffchainSignatureParams, PublicKeys, SignatureParams, SignatureParamsOwner, SignatureParamsStorageKey, @@ -9,12 +9,12 @@ use crate::{ }; use alloc::vec; use codec::{Decode, Encode}; -use sp_std::fmt::Debug; use frame_support::{ traits::{Get, GetStorageVersion, PalletInfoAccess}, weights::Weight, *, }; +use sp_std::fmt::Debug; /// DID owner of the BBSPlus parameters. #[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd)] diff --git a/pallets/core/src/modules/offchain_signatures/mod.rs b/pallets/core/src/modules/offchain_signatures/mod.rs index 075e8c5d5..e3ee9fe2d 100644 --- a/pallets/core/src/modules/offchain_signatures/mod.rs +++ b/pallets/core/src/modules/offchain_signatures/mod.rs @@ -8,8 +8,7 @@ use crate::{ util::IncId, }; use codec::{Decode, Encode}; -use sp_std::fmt::Debug; -use sp_std::prelude::*; +use sp_std::{fmt::Debug, prelude::*}; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, diff --git a/pallets/core/src/modules/offchain_signatures/params.rs b/pallets/core/src/modules/offchain_signatures/params.rs index 9f579608c..f6329dfa4 100644 --- a/pallets/core/src/modules/offchain_signatures/params.rs +++ b/pallets/core/src/modules/offchain_signatures/params.rs @@ -1,8 +1,8 @@ use crate::{did::Did, offchain_signatures::schemes::*, util::IncId}; use codec::{Decode, Encode}; -use sp_std::fmt::Debug; use frame_support::{ensure, traits::Get, IterableStorageDoubleMap, StorageDoubleMap, StorageMap}; use sp_runtime::DispatchResult; +use sp_std::fmt::Debug; use super::{ AddOffchainSignatureParams, BBSPlusPublicKey, Config, Error, Event, Module, PSPublicKey, diff --git a/pallets/core/src/modules/offchain_signatures/public_key.rs b/pallets/core/src/modules/offchain_signatures/public_key.rs index e3063234a..3956ebdc4 100644 --- a/pallets/core/src/modules/offchain_signatures/public_key.rs +++ b/pallets/core/src/modules/offchain_signatures/public_key.rs @@ -4,9 +4,9 @@ use crate::{ util::IncId, }; use codec::{Decode, Encode}; -use sp_std::fmt::Debug; use frame_support::{ensure, traits::Get, IterableStorageDoubleMap, StorageDoubleMap}; use sp_runtime::DispatchResult; +use sp_std::fmt::Debug; use super::{ AddOffchainSignaturePublicKey, Config, Error, Event, Module, OffchainSignatureParams, diff --git a/pallets/core/src/modules/offchain_signatures/schemes.rs b/pallets/core/src/modules/offchain_signatures/schemes.rs index d63472e04..1cdb773bb 100644 --- a/pallets/core/src/modules/offchain_signatures/schemes.rs +++ b/pallets/core/src/modules/offchain_signatures/schemes.rs @@ -1,8 +1,8 @@ -use crate::{offchain_signatures::SignatureParams, common::CurveType, util::Bytes}; +use crate::{common::CurveType, offchain_signatures::SignatureParams, util::Bytes}; use codec::{Decode, Encode}; -use sp_std::fmt::Debug; use frame_support::StorageDoubleMap; use sp_runtime::traits::CheckedConversion; +use sp_std::fmt::Debug; use super::{OffchainSignatureParams, SignatureParamsStorageKey}; use crate::offchain_signatures::OffchainPublicKey; diff --git a/pallets/core/src/modules/offchain_signatures/tests.rs b/pallets/core/src/modules/offchain_signatures/tests.rs index a0b7b1755..78cd32fc4 100644 --- a/pallets/core/src/modules/offchain_signatures/tests.rs +++ b/pallets/core/src/modules/offchain_signatures/tests.rs @@ -1,9 +1,9 @@ use super::*; use crate::{ + common::CurveType, did::{tests::check_did_detail, AddControllers}, offchain_signatures, tests::common::*, - common::CurveType, util::Bytes, }; use alloc::collections::BTreeMap; diff --git a/pallets/core/src/modules/revoke/mod.rs b/pallets/core/src/modules/revoke/mod.rs index e1aec4638..ee96398d4 100644 --- a/pallets/core/src/modules/revoke/mod.rs +++ b/pallets/core/src/modules/revoke/mod.rs @@ -9,8 +9,7 @@ use crate::{ }; use alloc::collections::BTreeSet; use codec::{Decode, Encode}; -use sp_std::{fmt::Debug, marker::PhantomData}; -use sp_std::vec::Vec; +use sp_std::{fmt::Debug, marker::PhantomData, vec::Vec}; pub use actions::*; use frame_support::{ diff --git a/pallets/core/src/modules/revoke/tests.rs b/pallets/core/src/modules/revoke/tests.rs index 19c298ed0..faa89732a 100644 --- a/pallets/core/src/modules/revoke/tests.rs +++ b/pallets/core/src/modules/revoke/tests.rs @@ -8,9 +8,9 @@ use crate::{ util::{Action, WithNonce}, }; use alloc::collections::BTreeMap; -use sp_std::{iter::once, marker::PhantomData}; use frame_support::assert_noop; use sp_core::{sr25519, U256}; +use sp_std::{iter::once, marker::PhantomData}; pub fn get_pauth + Clone>( action: &A, diff --git a/pallets/core/src/modules/status_list_credential/mod.rs b/pallets/core/src/modules/status_list_credential/mod.rs index 5163447b3..f70618f32 100644 --- a/pallets/core/src/modules/status_list_credential/mod.rs +++ b/pallets/core/src/modules/status_list_credential/mod.rs @@ -10,11 +10,10 @@ use crate::{ util::{Action, NonceError, WithNonce}, }; use alloc::vec::*; -use sp_std::fmt::Debug; use frame_support::{decl_error, decl_event, decl_module, decl_storage, pallet_prelude::*}; use frame_system as system; use frame_system::ensure_signed; -use sp_std::prelude::*; +use sp_std::{fmt::Debug, prelude::*}; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarks; diff --git a/pallets/core/src/modules/status_list_credential/tests.rs b/pallets/core/src/modules/status_list_credential/tests.rs index b5a27a40d..03a0e35b3 100644 --- a/pallets/core/src/modules/status_list_credential/tests.rs +++ b/pallets/core/src/modules/status_list_credential/tests.rs @@ -8,10 +8,10 @@ use crate::{ util::{Action, WithNonce}, }; use alloc::collections::BTreeMap; -use sp_std::{iter::empty, marker::PhantomData}; use frame_support::{assert_noop, assert_ok}; use sp_core::sr25519; use sp_runtime::DispatchError; +use sp_std::{iter::empty, marker::PhantomData}; type Mod = super::Pallet; diff --git a/pallets/core/src/util/hex.rs b/pallets/core/src/util/hex.rs index 69537b1b7..bd4f7f7fd 100644 --- a/pallets/core/src/util/hex.rs +++ b/pallets/core/src/util/hex.rs @@ -1,9 +1,9 @@ -use sp_std::{fmt, marker::PhantomData}; use serde::{ self, de::{Error, Visitor}, }; use serde_hex::FromHex; +use sp_std::{fmt, marker::PhantomData}; struct HexStrVisitor(PhantomData); diff --git a/pallets/core/src/util/with_nonce.rs b/pallets/core/src/util/with_nonce.rs index 6d513e030..d4da2ffdf 100644 --- a/pallets/core/src/util/with_nonce.rs +++ b/pallets/core/src/util/with_nonce.rs @@ -1,7 +1,6 @@ use codec::{Decode, Encode}; -use sp_std::fmt::Debug; use sp_runtime::{traits::CheckedAdd, DispatchError}; -use sp_std::convert::TryInto; +use sp_std::{convert::TryInto, fmt::Debug}; /// Wrapper for any kind of entity with a nonce. /// Nonces are mostly used for replay protection.