Skip to content

Commit 79a38d2

Browse files
committed
fix: more linting
1 parent 69b594e commit 79a38d2

File tree

17 files changed

+39
-27
lines changed

17 files changed

+39
-27
lines changed

src/catalyst-toolbox/catalyst-toolbox/src/rewards/proposers/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[allow(hidden_glob_reexports)]
12
use self::{io::vecs_to_maps, types::NotFundedReason};
23
use crate::types::{challenge::Challenge, proposal::Proposal};
34
use chain_impl_mockchain::value::Value;

src/chain-libs/chain-impl-mockchain/src/testing/arbitrary/address.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,23 @@ impl ArbitraryAddressDataValueVec {
106106
pub fn utxos(&self) -> Vec<AddressDataValue> {
107107
self.0
108108
.iter()
109-
.filter(|&x| matches!(x.address_data.kind(), Kind::Single { .. })).cloned()
109+
.filter(|&x| matches!(x.address_data.kind(), Kind::Single { .. }))
110+
.cloned()
110111
.collect()
111112
}
112113
pub fn accounts(&self) -> Vec<AddressDataValue> {
113114
self.0
114115
.iter()
115-
.filter(|&x| matches!(x.address_data.kind(), Kind::Account { .. })).cloned()
116+
.filter(|&x| matches!(x.address_data.kind(), Kind::Account { .. }))
117+
.cloned()
116118
.collect()
117119
}
118120

119121
pub fn delegations(&self) -> Vec<AddressDataValue> {
120122
self.0
121123
.iter()
122124
.filter(|&x| matches!(x.address_data.kind(), Kind::Group { .. }))
123-
.cloned().collect()
125+
.cloned()
126+
.collect()
124127
}
125128
}

src/chain-libs/chain-impl-mockchain/src/testing/arbitrary/transaction.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ impl AccountStatesVerifier {
190190
.0
191191
.addresses
192192
.iter()
193-
.filter(|&x| filter_accounts(x)).cloned()
193+
.filter(|&x| filter_accounts(x))
194+
.cloned()
194195
.map(|x| find_equal_and_sub(x, inputs))
195196
.collect();
196197

@@ -231,7 +232,8 @@ impl AccountStatesVerifier {
231232
fn find_equal_and_sub(x: AddressDataValue, collection: &[AddressDataValue]) -> AddressDataValue {
232233
match collection
233234
.iter()
234-
.find(|&y| y.address_data == x.address_data).cloned()
235+
.find(|&y| y.address_data == x.address_data)
236+
.cloned()
235237
{
236238
Some(y) => AddressDataValue::new(x.address_data, (x.value - y.value).unwrap()),
237239
None => x,
@@ -241,7 +243,8 @@ fn find_equal_and_sub(x: AddressDataValue, collection: &[AddressDataValue]) -> A
241243
fn find_equal_and_add(x: AddressDataValue, collection: &[AddressDataValue]) -> AddressDataValue {
242244
match collection
243245
.iter()
244-
.find(|&y| y.address_data == x.address_data).cloned()
246+
.find(|&y| y.address_data == x.address_data)
247+
.cloned()
245248
{
246249
Some(y) => AddressDataValue::new(x.address_data, (x.value + y.value).unwrap()),
247250
None => x,
@@ -265,20 +268,23 @@ impl UtxoVerifier {
265268
pub fn new(transaction_data: ArbitraryValidTransactionData) -> Self {
266269
UtxoVerifier(transaction_data)
267270
}
268-
271+
#[allow(clippy::iter_overeager_cloned)]
269272
pub fn calculate_current_utxo(&self) -> Vec<AddressDataValue> {
270273
let inputs = &self.0.input_addresses;
271274
let all = &self.0.addresses;
272275
let outputs = &self.0.output_addresses;
273276

274277
let utxo_not_changed: Vec<AddressDataValue> = all
275278
.iter()
279+
.filter(|&x| filter_utxo(x))
276280
.cloned()
277-
.filter(filter_utxo)
278281
.filter(|x| !inputs.contains(x))
279282
.collect();
280-
let utxo_added: Vec<AddressDataValue> =
281-
outputs.iter().cloned().filter(filter_utxo).collect();
283+
let utxo_added: Vec<AddressDataValue> = outputs
284+
.iter()
285+
.filter(|&x| filter_utxo(x))
286+
.cloned()
287+
.collect();
282288

283289
let mut snapshot = Vec::new();
284290
snapshot.extend(utxo_not_changed);

src/chain-libs/chain-impl-mockchain/src/testing/arbitrary/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ impl Verify {
139139
pub fn get_result(&self) -> TestResult {
140140
self.0
141141
.iter()
142+
.find(|&x| TestResult::is_failure(x))
142143
.cloned()
143-
.find(TestResult::is_failure)
144144
.unwrap_or_else(TestResult::passed)
145145
}
146146
}

src/chain-libs/chain-impl-mockchain/src/testing/builders/tx_builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl TestTxBuilder {
8585
);
8686
let mut faucet = test_ledger
8787
.faucets
88-
.get(0)
88+
.first()
8989
.cloned()
9090
.as_mut()
9191
.expect("test ledger with no faucet configured")
@@ -126,7 +126,7 @@ impl TestTxBuilder {
126126
);
127127
let mut faucet = test_ledger
128128
.faucets
129-
.get(0)
129+
.first()
130130
.as_mut()
131131
.expect("test ledger with no faucet configured")
132132
.clone();

src/chain-libs/chain-impl-mockchain/src/testing/gen/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl TestGen {
211211
rng.fill_bytes(&mut policy_hash);
212212

213213
TokenIdentifier {
214-
policy_hash: TryFrom::try_from(policy_hash).unwrap(),
214+
policy_hash: From::from(policy_hash),
215215
token_name: Self::token_name(),
216216
}
217217
}

src/chain-libs/chain-impl-mockchain/src/testing/scenario/controller.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ impl Controller {
7171
pub fn wallet(&self, alias: &str) -> Result<Wallet, ControllerError> {
7272
self.declared_wallets
7373
.iter()
74+
.find(|&x| x.alias() == alias)
7475
.cloned()
75-
.find(|x| x.alias() == alias)
7676
.ok_or(ControllerError::UnknownWallet {
7777
alias: alias.to_owned(),
7878
})
@@ -81,8 +81,8 @@ impl Controller {
8181
pub fn vote_plan(&self, alias: &str) -> Result<VotePlanDef, ControllerError> {
8282
self.declared_vote_plans
8383
.iter()
84+
.find(|&x| x.alias() == alias)
8485
.cloned()
85-
.find(|x| x.alias() == alias)
8686
.ok_or(ControllerError::UnknownVotePlan {
8787
alias: alias.to_owned(),
8888
})
@@ -95,8 +95,8 @@ impl Controller {
9595
pub fn stake_pool(&self, alias: &str) -> Result<StakePool, ControllerError> {
9696
self.declared_stake_pools
9797
.iter()
98+
.find(|&x| x.alias() == alias)
9899
.cloned()
99-
.find(|x| x.alias() == alias)
100100
.ok_or(ControllerError::UnknownStakePool {
101101
alias: alias.to_owned(),
102102
})

src/chain-libs/chain-impl-mockchain/src/testing/scenario/scenario_builder.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ impl ScenarioBuilder {
113113
let vote_plan_def = x.build();
114114
let owner = wallets
115115
.iter()
116+
.find(|&w| w.alias() == vote_plan_def.owner())
116117
.cloned()
117-
.find(|w| w.alias() == vote_plan_def.owner())
118118
.expect("cannot find wallet for vote plan");
119119
let vote_plan: VotePlan = vote_plan_def.into();
120120
create_initial_vote_plan(&vote_plan, &[owner])
@@ -162,8 +162,8 @@ impl ScenarioBuilder {
162162
.map(|pk| {
163163
wallets
164164
.iter()
165+
.find(|&x| x.public_key() == pk)
165166
.cloned()
166-
.find(|x| x.public_key() == pk)
167167
.expect("unknown key")
168168
})
169169
.collect();
@@ -180,8 +180,8 @@ impl ScenarioBuilder {
180180
) -> Vec<Fragment> {
181181
initials
182182
.iter()
183+
.filter(|&x| x.delegates_stake_pool().is_some())
183184
.cloned()
184-
.filter(|x| x.delegates_stake_pool().is_some())
185185
.map(|wallet_template| {
186186
let stake_pool_alias = wallet_template.delegates_stake_pool().unwrap();
187187
let stake_pool = stake_pools

src/chain-libs/chain-impl-mockchain/src/value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct SplitValueIn {
2121
pub parts: Value,
2222
pub remaining: Value,
2323
}
24-
24+
#[allow(clippy::manual_try_fold)]
2525
impl Value {
2626
pub fn zero() -> Self {
2727
Value(0)
@@ -31,7 +31,7 @@ impl Value {
3131
where
3232
I: Iterator<Item = Self>,
3333
{
34-
values.try_fold(Value::zero(), |acc, v| acc? + v)
34+
values.fold(Ok(Value::zero()), |acc, v| acc? + v)
3535
}
3636

3737
#[inline]

src/event-db/src/queries/event/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(deprecated)]
12
use crate::{
23
error::Error,
34
types::event::{

src/event-db/src/queries/registration.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(deprecated)]
12
use crate::{
23
types::{
34
event::EventId,

src/event-db/src/queries/search.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(deprecated)]
12
use crate::{
23
types::{
34
search::{

src/event-db/src/queries/vit_ss/fund.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(deprecated)]
12
use crate::{
23
types::vit_ss::{
34
challenge::{Challenge, ChallengeHighlights},
@@ -60,7 +61,7 @@ impl EventDB {
6061
next_fund.voting_start AS next_voting_start,
6162
next_fund.voting_end AS next_voting_end,
6263
next_fund.tallying_end AS next_tallying_end
63-
64+
6465
FROM event this_fund
6566
LEFT JOIN event next_fund ON next_fund.row_id = this_fund.row_id + 1
6667
WHERE this_fund.end_time > CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND this_fund.start_time < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'

src/vit-testing/iapyx/src/load/config/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ mod servicing_station;
55
pub use artificial_user::{
66
Config as ArtificialUserLoadConfig, RequestType as ArtificialUserRequestType,
77
};
8-
pub use node::{Config as NodeLoadConfig, Error as NodeLoadConfigError};
98
pub use servicing_station::{
109
Config as ServicingStationLoadConfig, Error as ServicingStationConfigError,
1110
RequestType as ServicingStationRequestType,

src/vit-testing/iapyx/src/load/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ mod request_generators;
44
mod scenario;
55
mod status_provider;
66

7-
pub use config::{ArtificialUserLoadConfig, NodeLoadConfig};
87
pub use multi_controller::{MultiController, MultiControllerError};
98
pub use request_generators::{ServicingStationRequestGen, WalletRequestGen};
109
pub use scenario::*;

src/vit-testing/mainnet-lib/src/network/wallet_state/template/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ pub enum Error {
104104
#[cfg(test)]
105105
mod tests {
106106
use crate::network::wallet_state::template::{
107-
build_default, delegator, registration, representative,
107+
actor::delegator, actor::registration, actor::representative, build_default,
108108
};
109109
use crate::{Block0, BlockBuilder, Ledger, Settings};
110110
use cardano_serialization_lib::Transaction;

src/vit-testing/mainnet-tools/src/cardano_cli/wrapper/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ mod error;
44
pub mod utils;
55

66
pub use cli::Api;
7-
pub use data::CardanoKeyTemplate;
7+
88
pub use error::Error;

0 commit comments

Comments
 (0)