Skip to content

Commit 2c51598

Browse files
authored
Merge pull request #2122 from opentensor/fix/ban-expect
Add linter rule to flag expect. Remove expects/allow exceptions.
2 parents 96dd8b4 + 593ad2e commit 2c51598

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+202
-69
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ edition = "2024"
4040

4141
[workspace.lints.clippy]
4242
arithmetic-side-effects = "deny"
43+
expect-used = "deny"
4344
indexing-slicing = "deny"
4445
manual_inspect = "allow"
4546
result_large_err = "allow"

node/src/benchmarking.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
105105
// Create a transaction using the given `call`.
106106
//
107107
// Note: Should only be used for benchmarking.
108+
#[allow(clippy::expect_used)]
108109
pub fn create_benchmark_extrinsic(
109110
client: &FullClient,
110111
sender: sp_core::sr25519::Pair,

node/src/chain_spec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Allowed since it's actually better to panic during chain setup when there is an error
2-
#![allow(clippy::unwrap_used)]
2+
#![allow(clippy::expect_used, clippy::unwrap_used)]
33

44
pub mod devnet;
55
pub mod finney;

node/src/command.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ pub fn run() -> sc_cli::Result<()> {
245245
}
246246
}
247247

248+
#[allow(clippy::expect_used)]
248249
fn start_babe_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
249250
let cli = Cli::from_arg_matches(arg_matches).expect("Bad arg_matches");
250251
let runner = cli.create_runner(&cli.run)?;
@@ -281,6 +282,7 @@ fn start_babe_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
281282
}
282283
}
283284

285+
#[allow(clippy::expect_used)]
284286
fn start_aura_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
285287
let cli = Cli::from_arg_matches(arg_matches).expect("Bad arg_matches");
286288
let runner = cli.create_runner(&cli.run)?;
@@ -313,6 +315,7 @@ fn start_aura_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
313315
}
314316
}
315317

318+
#[allow(clippy::expect_used)]
316319
fn customise_config(arg_matches: &ArgMatches, config: Configuration) -> Configuration {
317320
let cli = Cli::from_arg_matches(arg_matches).expect("Bad arg_matches");
318321

node/src/consensus/babe_consensus.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ impl ConsensusMechanism for BabeConsensus {
4444
sp_timestamp::InherentDataProvider,
4545
);
4646

47+
#[allow(clippy::expect_used)]
4748
fn start_authoring<C, SC, I, PF, SO, L, CIDP, BS, Error>(
4849
self,
4950
task_manager: &mut TaskManager,

node/src/consensus/hybrid_import_queue.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ impl HybridBlockImport {
7777
FrontierBlockImport::new(grandpa_block_import.clone(), client.clone()),
7878
);
7979

80+
#[allow(clippy::expect_used)]
8081
let (babe_import, babe_link) = sc_consensus_babe::block_import(
8182
babe_config,
8283
grandpa_block_import.clone(),

node/src/service.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub type BIQ<'a> = Box<
6060
+ 'a,
6161
>;
6262

63+
#[allow(clippy::expect_used)]
6364
pub fn new_partial(
6465
config: &Configuration,
6566
eth_config: &EthConfiguration,
@@ -250,6 +251,7 @@ pub fn build_manual_seal_import_queue(
250251
}
251252

252253
/// Builds a new service for a full client.
254+
#[allow(clippy::expect_used)]
253255
pub async fn new_full<NB, CM>(
254256
mut config: Configuration,
255257
eth_config: EthConfiguration,

pallets/admin-utils/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod tests;
1818

1919
#[deny(missing_docs)]
2020
#[frame_support::pallet]
21+
#[allow(clippy::expect_used)]
2122
pub mod pallet {
2223
use super::*;
2324
use frame_support::pallet_prelude::*;
@@ -162,6 +163,8 @@ pub mod pallet {
162163
/// Dispatchable functions allows users to interact with the pallet and invoke state changes.
163164
#[pallet::call]
164165
impl<T: Config> Pallet<T> {
166+
#![deny(clippy::expect_used)]
167+
165168
/// The extrinsic sets the new authorities for Aura consensus.
166169
/// It is only callable by the root account.
167170
/// The extrinsic will call the Aura pallet to change the authorities.

pallets/collective/src/benchmarking.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
// limitations under the License.
1717

1818
//! Staking pallet benchmarking.
19-
#![allow(clippy::arithmetic_side_effects, clippy::indexing_slicing)]
19+
#![allow(
20+
clippy::arithmetic_side_effects,
21+
clippy::expect_used,
22+
clippy::indexing_slicing
23+
)]
2024

2125
use super::*;
2226
use crate::Pallet as Collective;

pallets/collective/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ pub struct Votes<AccountId, BlockNumber> {
179179

180180
#[deny(missing_docs)]
181181
#[frame_support::pallet]
182+
#[allow(clippy::expect_used)]
182183
pub mod pallet {
183184
use super::*;
184185
use frame_system::pallet_prelude::*;
@@ -397,6 +398,8 @@ pub mod pallet {
397398
// Note that councillor operations are assigned to the operational class.
398399
#[pallet::call]
399400
impl<T: Config<I>, I: 'static> Pallet<T, I> {
401+
#![deny(clippy::expect_used)]
402+
400403
/// Set the collective's membership.
401404
///
402405
/// - `new_members`: The new member list. Be nice to the chain and provide it sorted.
@@ -1128,6 +1131,7 @@ impl<
11281131
}
11291132

11301133
#[cfg(feature = "runtime-benchmarks")]
1134+
#[allow(clippy::expect_used)]
11311135
fn try_successful_origin() -> Result<O, ()> {
11321136
let zero_account_id =
11331137
AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes())

0 commit comments

Comments
 (0)