Skip to content

Commit b471a53

Browse files
authored
Fix clippy warnings (#851)
* Run and build the complete workspace. Also update the toolchain such that get the newest clippy warnings * `start` feature was removed * Remove `test-no-std` from the default members instead of removing it manually from most builds * Remove the `workspace` flag as it leads to inclusion of the `test-no-std` package * Fix clippy issues * Update pipeline commands for clippy * Update test command for pipeline * Add missing comma * Fix clippy issues * Add box import only when `std` feature is not active * Ignore some clippy issues * Add fixes for keystore * Don't check examples and ignore some more warning * Remove taplo for now * Remove exclude for keystore
1 parent 4b3d52e commit b471a53

39 files changed

+104
-86
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
check: [
4747
# Test for no-std compatibility.
4848
# `--locked` to enforce an up-to-date Cargo.lock
49-
cargo build --release --workspace --locked --exclude test-no-std,
49+
cargo build --release --locked,
5050

5151
# We need to compile `test-no-std` separately, otherwise we have std leaks from the build-deps.
5252
#
@@ -58,14 +58,14 @@ jobs:
5858
cargo build --release -p test-no-std --features primitives,
5959

6060
# Check build of stand-alone features.
61-
cargo check --no-default-features -p substrate-api-client,
62-
cargo check --no-default-features -p substrate-api-client --features sync-api,
63-
cargo check --no-default-features -p substrate-api-client --features jsonrpsee-client,
64-
cargo check --no-default-features -p substrate-api-client --features tungstenite-client,
65-
cargo check --no-default-features -p substrate-api-client --features ws-client,
66-
cargo check --no-default-features -p substrate-api-client --features staking-xt,
67-
cargo check --no-default-features -p substrate-api-client --features contracts-xt,
68-
cargo check --no-default-features -p substrate-api-client --features std,
61+
cargo check --no-default-features,
62+
cargo check --no-default-features --features sync-api,
63+
cargo check --no-default-features --features jsonrpsee-client,
64+
cargo check --no-default-features --features tungstenite-client,
65+
cargo check --no-default-features --features ws-client,
66+
cargo check --no-default-features --features staking-xt,
67+
cargo check --no-default-features --features contracts-xt,
68+
cargo check --no-default-features --features std,
6969

7070
# Test for 32 bit and wasm32-unknown-unknown compatibility
7171
cargo build -p substrate-api-client --target wasm32-unknown-unknown --no-default-features --features sync-api,
@@ -81,12 +81,12 @@ jobs:
8181
cargo test --release -p ac-testing-sync,
8282

8383
# Clippy
84-
cargo clippy -p substrate-api-client -- -D warnings,
85-
cargo clippy -p substrate-api-client --no-default-features -- -D warnings,
86-
cargo clippy -p substrate-api-client --all-features --examples -- -D warnings,
84+
cargo clippy --workspace --exclude test-no-std -- -D warnings,
85+
cargo clippy --workspace --exclude test-no-std --no-default-features -- -D warnings,
86+
cargo clippy --workspace --exclude test-no-std --all-features -- -D warnings,
8787

8888
# Run unit tests
89-
cargo test --release --all-features --workspace --exclude test-no-std --exclude "ac-examples-*" --exclude "ac-testing-*",
89+
cargo test --release --all-features --workspace --exclude "ac-examples-*" --exclude "ac-testing-*" --exclude "test-no-std",
9090

9191
# Fmt
9292
cargo fmt --all -- --check
@@ -168,15 +168,16 @@ jobs:
168168
!target/release/examples/*.d
169169
!target/release/examples/*-*
170170
171-
taplo-fmt:
172-
name: "Taplo fmt"
173-
runs-on: ubuntu-latest
174-
container: "tamasfe/taplo:latest"
175-
steps:
176-
- uses: actions/checkout@v4
177-
178-
- name: Run Taplo fmt
179-
run: taplo fmt --check
171+
# Remove taplo until https://github.com/tamasfe/taplo/issues/793 is resolved.
172+
# taplo-fmt:
173+
# name: "Taplo fmt"
174+
# runs-on: ubuntu-latest
175+
# container: "tamasfe/taplo:latest"
176+
# steps:
177+
# - uses: actions/checkout@v4
178+
#
179+
# - name: Run Taplo fmt
180+
# run: taplo fmt --check
180181

181182
license-check:
182183
name: "License check"

Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ members = [
1414
"testing/sync",
1515
]
1616

17+
# Exclude the "test-no-std" package as it needs special treatment for compilation
18+
default-members = [
19+
"api-client",
20+
"keystore",
21+
"compose-macros",
22+
"primitives",
23+
"examples/async",
24+
"examples/sync",
25+
"examples/wasm",
26+
"node-api",
27+
"testing/async",
28+
"testing/sync",
29+
]
30+
1731
[workspace.dependencies]
1832
# crates.io no_std
1933
async-trait = "0.1"

api-client/src/api/api_client.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::{
2020
use ac_compose_macros::rpc_params;
2121
use ac_node_api::metadata::Metadata;
2222
use ac_primitives::{Config, ExtrinsicParams, SignExtrinsic};
23-
#[cfg(not(feature = "sync-api"))]
23+
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
2424
use alloc::boxed::Box;
2525
use alloc::sync::Arc;
2626
use codec::Decode;
@@ -149,23 +149,23 @@ where
149149
runtime_version_future,
150150
)
151151
.await?;
152-
info!("Got genesis hash: {:?}", genesis_hash);
153-
debug!("Metadata: {:?}", metadata);
154-
info!("Runtime Version: {:?}", runtime_version);
152+
info!("Got genesis hash: {genesis_hash:?}");
153+
debug!("Metadata: {metadata:?}");
154+
info!("Runtime Version: {runtime_version:?}");
155155
Ok(Self::new_offline(genesis_hash, metadata, runtime_version, client))
156156
}
157157

158158
/// Create a new Api client with call to the node to retrieve metadata.
159159
#[maybe_async::sync_impl]
160160
pub fn new(client: Client) -> Result<Self> {
161161
let genesis_hash = Self::get_genesis_hash(&client)?;
162-
info!("Got genesis hash: {:?}", genesis_hash);
162+
info!("Got genesis hash: {genesis_hash:?}");
163163

164164
let metadata = Self::get_metadata(&client)?;
165-
debug!("Metadata: {:?}", metadata);
165+
debug!("Metadata: {metadata:?}");
166166

167167
let runtime_version = Self::get_runtime_version(&client)?;
168-
info!("Runtime Version: {:?}", runtime_version);
168+
info!("Runtime Version: {runtime_version:?}");
169169

170170
Ok(Self::new_offline(genesis_hash, metadata, runtime_version, client))
171171
}
@@ -189,8 +189,8 @@ where
189189
let metadata = Self::get_metadata(&self.client)?;
190190
let runtime_version = Self::get_runtime_version(&self.client)?;
191191

192-
debug!("Metadata: {:?}", metadata);
193-
info!("Runtime Version: {:?}", runtime_version);
192+
debug!("Metadata: {metadata:?}");
193+
info!("Runtime Version: {runtime_version:?}");
194194

195195
self.metadata = metadata;
196196
self.runtime_version = runtime_version;

api-client/src/api/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ mod tests {
340340
fn encode_decode_extrinsic_report() {
341341
let hash = H256::random();
342342
let block_hash = H256::random();
343-
let status = TransactionStatus::InBlock(block_hash.clone());
343+
let status = TransactionStatus::InBlock(block_hash);
344344
// RawEventDetails Encoding / Decoding is already tested separately, so we don't need to retest here.
345345
let report = ExtrinsicReport::new(hash, Some(block_hash), status, None);
346346

api-client/src/api/rpc_api/author.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::{
2020
};
2121
use ac_compose_macros::rpc_params;
2222
use ac_primitives::{config::Config, UncheckedExtrinsic};
23-
#[cfg(not(feature = "sync-api"))]
23+
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
2424
use alloc::boxed::Box;
2525
use codec::{Decode, Encode};
2626
use log::*;
@@ -76,7 +76,7 @@ where
7676

7777
async fn submit_opaque_extrinsic(&self, encoded_extrinsic: &Bytes) -> Result<Self::Hash> {
7878
let hex_encoded_xt = rpc_params![encoded_extrinsic];
79-
debug!("sending extrinsic: {:?}", hex_encoded_xt);
79+
debug!("sending extrinsic: {hex_encoded_xt:?}");
8080
let xt_hash = self.client().request("author_submitExtrinsic", hex_encoded_xt).await?;
8181
Ok(xt_hash)
8282
}
@@ -283,7 +283,7 @@ where
283283
}
284284
self.populate_events(&mut report).await?;
285285
report.check_events_for_dispatch_error(self.metadata())?;
286-
return Ok(report);
286+
Ok(report)
287287
}
288288

289289
async fn populate_events(&self, report: &mut ExtrinsicReport<Self::Hash>) -> Result<()> {

api-client/src/api/rpc_api/chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{
1818
};
1919
use ac_compose_macros::rpc_params;
2020
use ac_primitives::config::Config;
21-
#[cfg(not(feature = "sync-api"))]
21+
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
2222
use alloc::boxed::Box;
2323
use alloc::vec::Vec;
2424
use log::*;

api-client/src/api/rpc_api/events.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
use ac_compose_macros::rpc_params;
2020
use ac_node_api::{metadata::Metadata, EventDetails, EventRecord, Events, Phase};
2121
use ac_primitives::config::Config;
22-
#[cfg(not(feature = "sync-api"))]
22+
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
2323
use alloc::boxed::Box;
2424
use alloc::{vec, vec::Vec};
2525
use codec::{Decode, Encode};
@@ -197,7 +197,7 @@ where
197197
.iter()
198198
.position(|xt| {
199199
let xt_hash = T::Hasher::hash_of(&xt);
200-
trace!("Looking for: {:?}, got xt_hash {:?}", extrinsic_hash, xt_hash);
200+
trace!("Looking for: {extrinsic_hash:?}, got xt_hash {xt_hash:?}");
201201
extrinsic_hash == xt_hash
202202
})
203203
.ok_or(Error::ExtrinsicNotFound)?;

api-client/src/api/rpc_api/frame_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
};
2020
use ac_compose_macros::rpc_params;
2121
use ac_primitives::{config::Config, AccountInfo};
22-
#[cfg(not(feature = "sync-api"))]
22+
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
2323
use alloc::boxed::Box;
2424
use alloc::{string::String, vec::Vec};
2525
use log::*;

api-client/src/api/rpc_api/pallet_balances.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
rpc::Request,
1616
};
1717
use ac_primitives::config::Config;
18-
#[cfg(not(feature = "sync-api"))]
18+
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
1919
use alloc::boxed::Box;
2020

2121
/// Interface to common calls of the substrate balances pallet.

api-client/src/api/rpc_api/pallet_transaction_payment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
};
1717
use ac_compose_macros::rpc_params;
1818
use ac_primitives::{config::Config, FeeDetails, InclusionFee, NumberOrHex, RuntimeDispatchInfo};
19-
#[cfg(not(feature = "sync-api"))]
19+
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
2020
use alloc::boxed::Box;
2121
use core::str::FromStr;
2222
use sp_core::Bytes;

0 commit comments

Comments
 (0)