Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit f97a3dc

Browse files
authored
clippy: Deny integer arithmetic, add allows where needed (#3606)
1 parent 2acc42f commit f97a3dc

File tree

92 files changed

+230
-161
lines changed

Some content is hidden

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

92 files changed

+230
-161
lines changed

.github/workflows/pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
uses: actions-rs/cargo@v1
7878
with:
7979
command: clippy
80-
args: -Zunstable-options --workspace --all-targets -- --deny=warnings
80+
args: -Zunstable-options --workspace --all-targets --features test-sbf -- --deny=warnings --deny=clippy::integer_arithmetic
8181

8282
audit:
8383
runs-on: ubuntu-latest

binary-option/program/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::integer_arithmetic)]
12
pub mod entrypoint;
23
pub mod error;
34
pub mod instruction;

binary-oracle-pair/program/tests/tests.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub async fn make_decision(
128128
Ok(())
129129
}
130130

131+
#[allow(clippy::too_many_arguments)]
131132
pub async fn make_withdraw(
132133
program_context: &mut ProgramTestContext,
133134
pool_account: &Pubkey,
@@ -446,6 +447,11 @@ impl TestPool {
446447
banks_client.process_transaction(transaction).await.unwrap();
447448
}
448449
}
450+
impl Default for TestPool {
451+
fn default() -> Self {
452+
Self::new()
453+
}
454+
}
449455

450456
pub async fn create_mint(
451457
banks_client: &mut BanksClient,
@@ -467,7 +473,7 @@ pub async fn create_mint(
467473
spl_token::instruction::initialize_mint(
468474
&spl_token::id(),
469475
&mint_account.pubkey(),
470-
&owner,
476+
owner,
471477
None,
472478
0,
473479
)

examples/rust/cross-program-invocation/tests/functional.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use {
1616

1717
#[tokio::test]
1818
async fn test_cross_program_invocation() {
19-
let program_id = Pubkey::from_str(&"invoker111111111111111111111111111111111111").unwrap();
19+
let program_id = Pubkey::from_str("invoker111111111111111111111111111111111111").unwrap();
2020
let (allocated_pubkey, bump_seed) =
2121
Pubkey::find_program_address(&[b"You pass butter"], &program_id);
2222
let mut program_test = ProgramTest::new(

examples/rust/transfer-lamports/src/processor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::integer_arithmetic)]
12
//! Program instruction processor
23
34
use solana_program::{

feature-proposal/cli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::integer_arithmetic)]
12
use {
23
chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc},
34
clap::{

governance/chat/program/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::integer_arithmetic)]
12
#![deny(missing_docs)]
23
//! Governance Chat program
34

governance/chat/program/tests/program_test/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl GovernanceChatProgramTest {
296296
token_owner_record_address,
297297
token_owner,
298298
governing_token_mint: governing_token_mint_keypair.pubkey(),
299-
governing_token_mint_authority: governing_token_mint_authority,
299+
governing_token_mint_authority,
300300
voter_weight_record,
301301
}
302302
}

governance/program/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::integer_arithmetic)]
12
#![deny(missing_docs)]
23
//! A Governance program for the Solana blockchain.
34

governance/program/tests/process_cast_vote.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,9 +1506,12 @@ async fn test_cast_vote_with_strict_tipping_and_inflated_max_vote_weight() {
15061506
let mut governance_test = GovernanceProgramTest::start_new().await;
15071507

15081508
// Reduce max voter weight to 50% for the cast vote to be above max_voter_weight
1509-
let mut realm_config_args = RealmSetupArgs::default();
1510-
realm_config_args.community_mint_max_vote_weight_source =
1511-
MintMaxVoteWeightSource::SupplyFraction(MintMaxVoteWeightSource::SUPPLY_FRACTION_BASE / 2);
1509+
let realm_config_args = RealmSetupArgs {
1510+
community_mint_max_vote_weight_source: MintMaxVoteWeightSource::SupplyFraction(
1511+
MintMaxVoteWeightSource::SUPPLY_FRACTION_BASE / 2,
1512+
),
1513+
..Default::default()
1514+
};
15121515

15131516
let realm_cookie = governance_test
15141517
.with_realm_using_args(&realm_config_args)

0 commit comments

Comments
 (0)