Skip to content

Commit

Permalink
Merge pull request #92 from Cerebellum-Network/feature/code-quality-c…
Browse files Browse the repository at this point in the history
…lippy

Introduce clippy linter
  • Loading branch information
rakanalh authored Nov 10, 2023
2 parents e653d20 + bbb0868 commit d346c19
Show file tree
Hide file tree
Showing 55 changed files with 424 additions and 526 deletions.
31 changes: 31 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# An auto defined `clippy` feature was introduced,
# but it was found to clash with user defined features,
# so was renamed to `cargo-clippy`.
#
# If you want standard clippy run:
# RUSTFLAGS= cargo clippy
[target.'cfg(feature = "cargo-clippy")']
rustflags = [
"-Aclippy::all",
"-Dclippy::correctness",
"-Aclippy::if-same-then-else",
"-Aclippy::clone-double-ref",
"-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
]
4 changes: 4 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@v2

- name: Check with Clippy
run: |
cargo clippy --no-deps --all-targets --features runtime-benchmarks --workspace -- --deny warnings
- name: Check Build
run: |
SKIP_WASM_BUILD=1 cargo check --release
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
.DS_Store

# The cache for docker container dependency
.cargo
.cargo/**
!/.cargo/config.toml

# The cache for chain data in container
.local
Expand All @@ -19,5 +20,3 @@

# ddc-metrics-offchain-worker mock files
pallets/ddc-metrics-offchain-worker/src/tests/test_data/ddc.contract
pallets/ddc-metrics-offchain-worker/src/tests/test_data/ddc.wasm
pallets/ddc-metrics-offchain-worker/src/tests/test_data/metadata.json
73 changes: 0 additions & 73 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ build = "build.rs"
[dependencies]
cere-cli = { path = "cli", features = [ "cere-dev-native" ] }
sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
ss58-registry = { version = "1.38.0", default-features = false }

[build-dependencies]
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
Expand Down
10 changes: 5 additions & 5 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl SubstrateCli for Cli {

#[cfg(feature = "cere-native")]
{
return &cere_service::cere_runtime::VERSION
&cere_service::cere_runtime::VERSION
}

#[cfg(not(feature = "cere-native"))]
Expand Down Expand Up @@ -161,17 +161,17 @@ pub fn run() -> sc_cli::Result<()> {

#[cfg(feature = "cere-dev-native")]
if chain_spec.is_cere_dev() {
return Ok(runner.sync_run(|config| {
return runner.sync_run(|config| {
cmd.run::<cere_service::cere_dev_runtime::Block, cere_client::CereDevExecutorDispatch>(config)
})?)
})
}

// else we assume it is Cere
#[cfg(feature = "cere-native")]
{
return Ok(runner.sync_run(|config| {
runner.sync_run(|config| {
cmd.run::<cere_service::cere_runtime::Block, cere_client::CereExecutorDispatch>(config)
})?)
})
}

#[cfg(not(feature = "cere-native"))]
Expand Down
3 changes: 0 additions & 3 deletions node/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ sc-service = { version = "0.10.0-dev", git = "https://github.com/paritytech/subs
sc-executor = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
frame-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
node-primitives = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
Expand All @@ -29,8 +28,6 @@ sp-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/su
sp-storage = { version = "6.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sp-inherents = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
sp-keyring = { version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
sp-core = { version = "6.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }

# Local
cere-runtime = { path = "../../runtime/cere", optional = true }
Expand Down
Loading

0 comments on commit d346c19

Please sign in to comment.