From 4282d74c396b9a79da8ba468e6dce7f1c0752092 Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Thu, 29 Feb 2024 09:57:27 +0900 Subject: [PATCH] add substrate fmt config --- .github/workflows/check-pull-request.yml | 3 ++- runtime/bajun/src/lib.rs | 25 ++++++++++++------------ runtime/bajun/src/proxy_type.rs | 4 ++-- rustfmt.toml | 22 +++++++++++++++------ 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/.github/workflows/check-pull-request.yml b/.github/workflows/check-pull-request.yml index 4c33d02..a6a897d 100644 --- a/.github/workflows/check-pull-request.yml +++ b/.github/workflows/check-pull-request.yml @@ -33,7 +33,8 @@ jobs: continue-on-error: false steps: - uses: actions/checkout@v4 - - run: cargo fmt --all -- --check + # some settings are only available in nightly. + - run: cargo +nightly fmt --all -- --check lint: if: ${{ !startsWith(github.head_ref, 'release/') }} diff --git a/runtime/bajun/src/lib.rs b/runtime/bajun/src/lib.rs index ee88a3d..c39c3b4 100644 --- a/runtime/bajun/src/lib.rs +++ b/runtime/bajun/src/lib.rs @@ -44,16 +44,17 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use frame_support::pallet_prelude::ConstU32; -use frame_support::traits::fungible::HoldConsideration; -use frame_support::traits::tokens::{PayFromAccount, UnityAssetBalanceConversion}; -use frame_support::traits::{LinearStoragePrice, TransformOrigin}; use frame_support::{ construct_runtime, dispatch::DispatchClass, genesis_builder_helper::{build_config, create_default_config}, + pallet_prelude::ConstU32, parameter_types, - traits::{AsEnsureOriginWithArg, ConstBool, Contains}, + traits::{ + fungible::HoldConsideration, + tokens::{PayFromAccount, UnityAssetBalanceConversion}, + AsEnsureOriginWithArg, ConstBool, Contains, LinearStoragePrice, TransformOrigin, + }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, @@ -83,8 +84,10 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use staging_xcm::latest::prelude::BodyId; use pallet_nfts::{AttributeNamespace, Call as NftsCall}; -use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling}; -use parachains_common::{BlockNumber, Hash, Header}; +use parachains_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + BlockNumber, Hash, Header, +}; use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; use sp_runtime::traits::{IdentifyAccount, IdentityLookup, Verify}; @@ -334,14 +337,10 @@ impl Contains for BaseCallFilter { match call { RuntimeCall::Nft(NftsCall::set_attribute { namespace, .. }) if namespace == &AttributeNamespace::CollectionOwner => - { - true - }, + true, RuntimeCall::Nft(NftsCall::set_attribute { namespace, .. }) if namespace != &AttributeNamespace::CollectionOwner => - { - false - }, + false, _ => true, } } diff --git a/runtime/bajun/src/proxy_type.rs b/runtime/bajun/src/proxy_type.rs index fd20587..3f0152d 100644 --- a/runtime/bajun/src/proxy_type.rs +++ b/runtime/bajun/src/proxy_type.rs @@ -85,8 +85,8 @@ impl InstanceFilter for ProxyType { }, ProxyType::IdentityJudgement => matches!( c, - RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) - | RuntimeCall::Utility(..) + RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) | + RuntimeCall::Utility(..) ), ProxyType::CancelProxy => { matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })) diff --git a/rustfmt.toml b/rustfmt.toml index 2b1327d..c342153 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,14 +1,24 @@ # Basic -hard_tabs = true -max_width = 100 +edition = "2021" +hard_tabs = true +max_width = 100 use_small_heuristics = "Max" # Imports +imports_granularity = "Crate" reorder_imports = true -reorder_modules = true # Consistency newline_style = "Unix" # Misc -chain_width = 80 -match_arm_leading_pipes = "Preserve" +chain_width = 80 +spaces_around_ranges = false +binop_separator = "Back" +reorder_impl_items = false +match_arm_leading_pipes = "Preserve" +match_arm_blocks = false match_block_trailing_comma = true -use_field_init_shorthand = true +trailing_comma = "Vertical" +trailing_semicolon = false +use_field_init_shorthand = true +# Format comments +comment_width = 100 +wrap_comments = true