Skip to content

Commit

Permalink
Enforce consistent and correct toml formatting (#2518)
Browse files Browse the repository at this point in the history
Using taplo, fixes all our broken and inconsistent toml formatting and
adds CI to keep them tidy.

If people want we can customise the format rules as described here
https://taplo.tamasfe.dev/configuration/formatter-options.html

@ggwpez, I suggest zepter is used only for checking features are
propagated, and leave formatting for taplo to avoid duplicate work and
conflicts.

TODO
- [x] Use `exclude = [...]` syntax in taplo file to ignore zombienet
tests instead of deleting the dir

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
  • Loading branch information
3 people authored Dec 1, 2023
1 parent 5213263 commit 4a293bc
Show file tree
Hide file tree
Showing 364 changed files with 2,325 additions and 2,287 deletions.
52 changes: 26 additions & 26 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build]
rustdocflags = [
"-Dwarnings",
"-Arustdoc::redundant_explicit_links", # stylistic
"-Dwarnings",
"-Arustdoc::redundant_explicit_links", # stylistic
]

# An auto defined `clippy` feature was introduced,
Expand All @@ -12,30 +12,30 @@ rustdocflags = [
# RUSTFLAGS= cargo clippy
[target.'cfg(feature = "cargo-clippy")']
rustflags = [
"-Aclippy::all",
"-Dclippy::correctness",
"-Aclippy::if-same-then-else",
"-Asuspicious_double_ref_op",
"-Dclippy::complexity",
"-Aclippy::zero-prefixed-literal", # 00_1000_000
"-Aclippy::type_complexity", # raison d'etre
"-Aclippy::nonminimal-bool", # maybe
"-Aclippy::borrowed-box", # Reasonable to fix this one
"-Aclippy::too-many-arguments", # (Turning this on would lead to)
"-Aclippy::unnecessary_cast", # Types may change
"-Aclippy::identity-op", # One case where we do 0 +
"-Aclippy::useless_conversion", # Types may change
"-Aclippy::unit_arg", # styalistic.
"-Aclippy::option-map-unit-fn", # styalistic
"-Aclippy::bind_instead_of_map", # styalistic
"-Aclippy::erasing_op", # E.g. 0 * DOLLARS
"-Aclippy::eq_op", # In tests we test equality.
"-Aclippy::while_immutable_condition", # false positives
"-Aclippy::needless_option_as_deref", # false positives
"-Aclippy::derivable_impls", # false positives
"-Aclippy::stable_sort_primitive", # prefer stable sort
"-Aclippy::extra-unused-type-parameters", # stylistic
"-Aclippy::default_constructed_unit_structs", # stylistic
"-Aclippy::all",
"-Dclippy::correctness",
"-Aclippy::if-same-then-else",
"-Asuspicious_double_ref_op",
"-Dclippy::complexity",
"-Aclippy::zero-prefixed-literal", # 00_1000_000
"-Aclippy::type_complexity", # raison d'etre
"-Aclippy::nonminimal-bool", # maybe
"-Aclippy::borrowed-box", # Reasonable to fix this one
"-Aclippy::too-many-arguments", # (Turning this on would lead to)
"-Aclippy::unnecessary_cast", # Types may change
"-Aclippy::identity-op", # One case where we do 0 +
"-Aclippy::useless_conversion", # Types may change
"-Aclippy::unit_arg", # styalistic.
"-Aclippy::option-map-unit-fn", # styalistic
"-Aclippy::bind_instead_of_map", # styalistic
"-Aclippy::erasing_op", # E.g. 0 * DOLLARS
"-Aclippy::eq_op", # In tests we test equality.
"-Aclippy::while_immutable_condition", # false positives
"-Aclippy::needless_option_as_deref", # false positives
"-Aclippy::derivable_impls", # false positives
"-Aclippy::stable_sort_primitive", # prefer stable sort
"-Aclippy::extra-unused-type-parameters", # stylistic
"-Aclippy::default_constructed_unit_structs", # stylistic
]

[env]
Expand Down
56 changes: 28 additions & 28 deletions .config/lychee.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@ accept = [
200,

# Rate limited - GitHub likes to throw this.
429
429,
]

exclude_path = [ "./target" ]
exclude_path = ["./target"]

exclude = [
# Place holders (no need to fix these):
"http://visitme/",
"https://visitme/",
# TODO <https://github.com/paritytech/polkadot-sdk/issues/134>
"https://docs.substrate.io/main-docs/build/custom-rpc/#public-rpcs",
"https://docs.substrate.io/rustdocs/latest/sp_api/macro.decl_runtime_apis.html",
"https://github.com/ipfs/js-ipfs-bitswap/blob/",
"https://github.com/paritytech/polkadot-sdk/substrate/frame/timestamp",
"https://github.com/paritytech/substrate/frame/fast-unstake",
"https://github.com/zkcrypto/bls12_381/blob/e224ad4ea1babfc582ccd751c2bf128611d10936/src/test-data/mod.rs",
"https://polkadot.network/the-path-of-a-parachain-block/",
"https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results",
"https://research.web3.foundation/en/latest/polkadot/block-production/Babe.html",
"https://research.web3.foundation/en/latest/polkadot/block-production/Babe.html#-6.-practical-results",
"https://research.web3.foundation/en/latest/polkadot/networking/3-avail-valid.html#topology",
"https://research.web3.foundation/en/latest/polkadot/NPoS/3.%20Balancing.html",
"https://research.web3.foundation/en/latest/polkadot/overview/2-token-economics.html",
"https://research.web3.foundation/en/latest/polkadot/overview/2-token-economics.html#inflation-model",
"https://research.web3.foundation/en/latest/polkadot/slashing/npos.html",
"https://research.web3.foundation/en/latest/polkadot/Token%20Economics.html#inflation-model",
"https://rpc.polkadot.io/",
"https://w3f.github.io/parachain-implementers-guide/node/approval/approval-distribution.html",
"https://w3f.github.io/parachain-implementers-guide/node/index.html",
"https://w3f.github.io/parachain-implementers-guide/protocol-chain-selection.html",
"https://w3f.github.io/parachain-implementers-guide/runtime/session_info.html",
# Place holders (no need to fix these):
"http://visitme/",
"https://visitme/",

# TODO <https://github.com/paritytech/polkadot-sdk/issues/134>
"https://docs.substrate.io/main-docs/build/custom-rpc/#public-rpcs",
"https://docs.substrate.io/rustdocs/latest/sp_api/macro.decl_runtime_apis.html",
"https://github.com/ipfs/js-ipfs-bitswap/blob/",
"https://github.com/paritytech/polkadot-sdk/substrate/frame/timestamp",
"https://github.com/paritytech/substrate/frame/fast-unstake",
"https://github.com/zkcrypto/bls12_381/blob/e224ad4ea1babfc582ccd751c2bf128611d10936/src/test-data/mod.rs",
"https://polkadot.network/the-path-of-a-parachain-block/",
"https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results",
"https://research.web3.foundation/en/latest/polkadot/NPoS/3.%20Balancing.html",
"https://research.web3.foundation/en/latest/polkadot/Token%20Economics.html#inflation-model",
"https://research.web3.foundation/en/latest/polkadot/block-production/Babe.html",
"https://research.web3.foundation/en/latest/polkadot/block-production/Babe.html#-6.-practical-results",
"https://research.web3.foundation/en/latest/polkadot/networking/3-avail-valid.html#topology",
"https://research.web3.foundation/en/latest/polkadot/overview/2-token-economics.html",
"https://research.web3.foundation/en/latest/polkadot/overview/2-token-economics.html#inflation-model",
"https://research.web3.foundation/en/latest/polkadot/slashing/npos.html",
"https://rpc.polkadot.io/",
"https://w3f.github.io/parachain-implementers-guide/node/approval/approval-distribution.html",
"https://w3f.github.io/parachain-implementers-guide/node/index.html",
"https://w3f.github.io/parachain-implementers-guide/protocol-chain-selection.html",
"https://w3f.github.io/parachain-implementers-guide/runtime/session_info.html",
]
33 changes: 33 additions & 0 deletions .config/taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# all options https://taplo.tamasfe.dev/configuration/formatter-options.html

# ignore zombienet as they do some deliberate custom toml stuff
exclude = [
"cumulus/zombienet/**",
"polkadot/node/malus/integrationtests/**",
"polkadot/zombienet_tests/**",
"substrate/zombienet/**",
]

# global rules
[formatting]
reorder_arrays = true
inline_table_expand = false
array_auto_expand = false
array_auto_collapse = false
indent_string = " " # tab

# don't re-order order-dependent deb package metadata
[[rule]]
include = ["polkadot/Cargo.toml"]
keys = ["package.metadata.deb"]

[rule.formatting]
reorder_arrays = false

# don't re-order order-dependent rustflags
[[rule]]
include = [".cargo/config.toml"]
keys = ["build", "target.'cfg(feature = \"cargo-clippy\")'"]

[rule.formatting]
reorder_arrays = false
5 changes: 1 addition & 4 deletions .config/zepter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ workflows:
'--left-side-outside-workspace=ignore',
# Some features imply that they activate a specific dependency as non-optional. Otherwise the default behaviour with a `?` is used.
'--feature-enables-dep=try-runtime:frame-try-runtime,runtime-benchmarks:frame-benchmarking',
# Actually modify the files and not just report the issues:
# Auxillary flags:
'--offline',
'--locked',
'--show-path',
'--quiet',
]
# Format the features into canonical format:
- ['format', 'features', '--offline', '--locked', '--quiet']
# Same as `check`, but with the `--fix` flag.
default:
- [ $check.0, '--fix' ]
- [ $check.1, '--fix' ]

# Will be displayed when any workflow fails:
help:
Expand Down
10 changes: 10 additions & 0 deletions .gitlab/pipeline/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ check-rust-feature-propagation:
- cargo install --locked --version 0.13.3 -q -f zepter && zepter --version
- zepter run check

check-toml-format:
stage: check
extends:
- .kubernetes-env
- .common-refs
script:
- cargo install taplo-cli --locked --version 0.8.1
- taplo format --check --config .config/taplo.toml
- echo "Please run `taplo format --config .config/taplo.toml` to fix any toml formatting issues"

# More info can be found here: https://github.com/paritytech/polkadot/pull/5865
.check-runtime-migration:
stage: check
Expand Down
18 changes: 9 additions & 9 deletions .gitlab/spellcheck.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ use_builtin = true
[hunspell.quirks]
# He tagged it as 'TheGreatestOfAllTimes'
transform_regex = [
# `Type`'s
# `Type`'s
"^'([^\\s])'$",
# 5x
# 10.7%
# 5x
# 10.7%
"^[0-9_]+(?:\\.[0-9]*)?(x|%)$",
# Transforms'
# Transforms'
"^(.*)'$",
# backslashes
"^\\+$",
# backslashes
"^[0-9]*+k|MB|Mb|ms|Mbit|nd|th|rd$",
# single char `=` `>` `%` ..
"^\\+$",
# single char `=` `>` `%` ..
"^=|>|<|%$",
# 22_100
"^(?:[0-9]+_)+[0-9]+$"
# 22_100
"^(?:[0-9]+_)+[0-9]+$",
]
allow_concatenation = true
allow_dashes = true
28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ license = "GPL-3.0-only"
resolver = "2"

members = [
"developer-hub",
"bridges/bin/runtime-common",
"bridges/modules/grandpa",
"bridges/modules/messages",
Expand All @@ -23,8 +22,8 @@ members = [
"bridges/primitives/chain-bridge-hub-rococo",
"bridges/primitives/chain-bridge-hub-westend",
"bridges/primitives/chain-kusama",
"bridges/primitives/chain-polkadot-bulletin",
"bridges/primitives/chain-polkadot",
"bridges/primitives/chain-polkadot-bulletin",
"bridges/primitives/chain-rococo",
"bridges/primitives/chain-westend",
"bridges/primitives/header-chain",
Expand Down Expand Up @@ -70,6 +69,7 @@ members = [
"cumulus/parachains/integration-tests/emulated/chains/relays/westend",
"cumulus/parachains/integration-tests/emulated/common",
"cumulus/parachains/integration-tests/emulated/networks/rococo-system",
"cumulus/parachains/integration-tests/emulated/networks/rococo-westend-system",
"cumulus/parachains/integration-tests/emulated/networks/westend-system",
"cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo",
"cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend",
Expand Down Expand Up @@ -106,6 +106,7 @@ members = [
"cumulus/test/runtime",
"cumulus/test/service",
"cumulus/xcm/xcm-emulator",
"developer-hub",
"polkadot",
"polkadot/cli",
"polkadot/core-primitives",
Expand All @@ -123,8 +124,8 @@ members = [
"polkadot/node/core/parachains-inherent",
"polkadot/node/core/prospective-parachains",
"polkadot/node/core/provisioner",
"polkadot/node/core/pvf-checker",
"polkadot/node/core/pvf",
"polkadot/node/core/pvf-checker",
"polkadot/node/core/pvf/common",
"polkadot/node/core/pvf/execute-worker",
"polkadot/node/core/pvf/prepare-worker",
Expand All @@ -147,10 +148,10 @@ members = [
"polkadot/node/overseer",
"polkadot/node/primitives",
"polkadot/node/service",
"polkadot/node/subsystem",
"polkadot/node/subsystem-test-helpers",
"polkadot/node/subsystem-types",
"polkadot/node/subsystem-util",
"polkadot/node/subsystem",
"polkadot/node/test/client",
"polkadot/node/test/service",
"polkadot/node/tracking-allocator",
Expand Down Expand Up @@ -179,8 +180,8 @@ members = [
"polkadot/utils/generate-bags",
"polkadot/utils/remote-ext-tests/bags-list",
"polkadot/xcm",
"polkadot/xcm/pallet-xcm-benchmarks",
"polkadot/xcm/pallet-xcm",
"polkadot/xcm/pallet-xcm-benchmarks",
"polkadot/xcm/procedural",
"polkadot/xcm/xcm-builder",
"polkadot/xcm/xcm-executor",
Expand Down Expand Up @@ -232,8 +233,8 @@ members = [
"substrate/client/merkle-mountain-range",
"substrate/client/merkle-mountain-range/rpc",
"substrate/client/mixnet",
"substrate/client/network-gossip",
"substrate/client/network",
"substrate/client/network-gossip",
"substrate/client/network/bitswap",
"substrate/client/network/common",
"substrate/client/network/light",
Expand All @@ -243,10 +244,10 @@ members = [
"substrate/client/network/transactions",
"substrate/client/offchain",
"substrate/client/proposer-metrics",
"substrate/client/rpc",
"substrate/client/rpc-api",
"substrate/client/rpc-servers",
"substrate/client/rpc-spec-v2",
"substrate/client/rpc",
"substrate/client/service",
"substrate/client/service/test",
"substrate/client/state-db",
Expand Down Expand Up @@ -274,8 +275,8 @@ members = [
"substrate/frame/bags-list/fuzzer",
"substrate/frame/bags-list/remote-tests",
"substrate/frame/balances",
"substrate/frame/beefy-mmr",
"substrate/frame/beefy",
"substrate/frame/beefy-mmr",
"substrate/frame/benchmarking",
"substrate/frame/benchmarking/pov",
"substrate/frame/bounties",
Expand All @@ -285,9 +286,9 @@ members = [
"substrate/frame/contracts",
"substrate/frame/contracts/fixtures",
"substrate/frame/contracts/fixtures/contracts/common",
"substrate/frame/contracts/uapi",
"substrate/frame/contracts/mock-network",
"substrate/frame/contracts/proc-macro",
"substrate/frame/contracts/uapi",
"substrate/frame/conviction-voting",
"substrate/frame/core-fellowship",
"substrate/frame/democracy",
Expand Down Expand Up @@ -424,12 +425,12 @@ members = [
"substrate/primitives/offchain",
"substrate/primitives/panic-handler",
"substrate/primitives/rpc",
"substrate/primitives/runtime",
"substrate/primitives/runtime-interface",
"substrate/primitives/runtime-interface/proc-macro",
"substrate/primitives/runtime-interface/test-wasm-deprecated",
"substrate/primitives/runtime-interface/test-wasm",
"substrate/primitives/runtime-interface/test",
"substrate/primitives/runtime",
"substrate/primitives/runtime-interface/test-wasm",
"substrate/primitives/runtime-interface/test-wasm-deprecated",
"substrate/primitives/session",
"substrate/primitives/staking",
"substrate/primitives/state-machine",
Expand Down Expand Up @@ -468,9 +469,8 @@ members = [
"substrate/utils/frame/try-runtime/cli",
"substrate/utils/prometheus",
"substrate/utils/wasm-builder",
"cumulus/parachains/integration-tests/emulated/networks/rococo-westend-system",
]
default-members = [ "polkadot", "substrate/bin/node/cli" ]
default-members = ["polkadot", "substrate/bin/node/cli"]

[profile.release]
# Polkadot runtime requires unwinding.
Expand Down
4 changes: 2 additions & 2 deletions bridges/bin/runtime-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bp-test-utils = { path = "../../primitives/test-utils" }
pallet-balances = { path = "../../../substrate/frame/balances" }

[features]
default = [ "std" ]
default = ["std"]
std = [
"bp-header-chain/std",
"bp-messages/std",
Expand Down Expand Up @@ -92,4 +92,4 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
]
integrity-test = [ "static_assertions" ]
integrity-test = ["static_assertions"]
2 changes: 1 addition & 1 deletion bridges/modules/grandpa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sp-core = { path = "../../../substrate/primitives/core" }
sp-io = { path = "../../../substrate/primitives/io" }

[features]
default = [ "std" ]
default = ["std"]
std = [
"bp-header-chain/std",
"bp-runtime/std",
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/messages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pallet-balances = { path = "../../../substrate/frame/balances" }
sp-io = { path = "../../../substrate/primitives/io" }

[features]
default = [ "std" ]
default = ["std"]
std = [
"bp-messages/std",
"bp-runtime/std",
Expand Down
Loading

0 comments on commit 4a293bc

Please sign in to comment.