Skip to content

Commit

Permalink
Merge branch 'tomas/lint-dbg-and-prints' (#3257)
Browse files Browse the repository at this point in the history
* origin/tomas/lint-dbg-and-prints:
  changelog: add #3257
  fix lint warnings
  add lints for dbg and prints (except for in tests)
  • Loading branch information
brentstone committed May 21, 2024
2 parents 257856a + a1c534c commit 8cb095c
Show file tree
Hide file tree
Showing 47 changed files with 301 additions and 127 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/3257-lint-dbg-and-print.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Lint for left-over debug and print statements.
([\#3257](https://github.com/anoma/namada/pull/3257))
2 changes: 2 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ disallowed-methods = [
{ path = "namada_core::time::DateTimeUtc::now", reason = "Do not use current date/time in code that must be deterministic" },
{ path = "wasmtimer::std::Instant", reason = "Do not use current date/time in code that must be deterministic" },
]
allow-dbg-in-tests = true
allow-print-in-tests = true
5 changes: 4 additions & 1 deletion crates/account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

mod storage;
Expand Down
3 changes: 2 additions & 1 deletion crates/apps/src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro
)]

#[cfg(feature = "benches")]
Expand Down
5 changes: 4 additions & 1 deletion crates/controller/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

use namada_core::arith::{self, checked};
Expand Down
5 changes: 4 additions & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

pub mod arith;
Expand Down
5 changes: 4 additions & 1 deletion crates/ethereum_bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

pub mod event;
Expand Down
5 changes: 4 additions & 1 deletion crates/events/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

pub mod extend;
Expand Down
5 changes: 4 additions & 1 deletion crates/governance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

use namada_core::address::{self, Address};
Expand Down
5 changes: 4 additions & 1 deletion crates/ibc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

mod actions;
Expand Down
11 changes: 11 additions & 0 deletions crates/light_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
//! Both the [`reading`] and [`writing`] modules are further divided into a
//! blocking and asynchronous submodules.
#![doc(html_favicon_url = "https://dev.namada.net/master/favicon.png")]
#![doc(html_logo_url = "https://dev.namada.net/master/rustdoc-logo.png")]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(rustdoc::private_intra_doc_links)]
#![warn(
rust_2018_idioms,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

pub mod reading;
pub mod transaction;
pub mod writing;
Expand Down
12 changes: 0 additions & 12 deletions crates/light_sdk/src/writing/asynchronous/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ pub async fn broadcast_tx(
)
.map_err(|e| Error::Other(e.to_string()))?;

let wrapper_tx_hash = tx.header_hash().to_string();
// We use this to determine when the decrypted inner tx makes it
// on-chain
let decrypted_tx_hash = tx.raw_header_hash().to_string();

// TODO: configure an explicit timeout value? we need to hack away at
// `tendermint-rs` for this, which is currently using a hard-coded 30s
// timeout.
Expand All @@ -40,13 +35,6 @@ pub async fn broadcast_tx(
.map_err(|e| Error::from(TxSubmitError::TxBroadcast(e)))?;

if response.code == 0.into() {
println!("Transaction added to mempool: {:?}", response);
// Print the transaction identifiers to enable the extraction of
// acceptance/application results later
{
println!("Wrapper transaction hash: {:?}", wrapper_tx_hash);
println!("Inner transaction hash: {:?}", decrypted_tx_hash);
}
Ok(response)
} else {
Err(Error::from(TxSubmitError::TxBroadcast(RpcError::server(
Expand Down
5 changes: 4 additions & 1 deletion crates/merkle_tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

pub mod eth_bridge_pool;
Expand Down
5 changes: 4 additions & 1 deletion crates/namada/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

pub use namada_core::{
Expand Down
5 changes: 4 additions & 1 deletion crates/parameters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

pub mod storage;
Expand Down
5 changes: 4 additions & 1 deletion crates/proof_of_stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

pub mod epoched;
Expand Down
5 changes: 4 additions & 1 deletion crates/replay_protection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_lossless,
clippy::arithmetic_side_effects
clippy::arithmetic_side_effects,
clippy::dbg_macro,
clippy::print_stdout,
clippy::print_stderr
)]

use namada_core::hash::Hash;
Expand Down
5 changes: 5 additions & 0 deletions crates/sdk/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,17 +757,20 @@ impl<C: NamadaTypes> TxBuilder<C> for TxBecomeValidator<C> {
}

impl<C: NamadaTypes> TxBecomeValidator<C> {
/// Set the address
pub fn address(self, address: C::Address) -> Self {
Self { address, ..self }
}

/// Set the commission rate
pub fn commission_rate(self, commission_rate: Dec) -> Self {
Self {
commission_rate,
..self
}
}

/// Set the max commission rate change
pub fn max_commission_rate_change(
self,
max_commission_rate_change: Dec,
Expand All @@ -778,6 +781,7 @@ impl<C: NamadaTypes> TxBecomeValidator<C> {
}
}

/// Set the email
pub fn email(self, email: String) -> Self {
Self { email, ..self }
}
Expand All @@ -792,6 +796,7 @@ impl<C: NamadaTypes> TxBecomeValidator<C> {
}

impl TxBecomeValidator {
/// Build the tx
pub async fn build(
&self,
context: &impl Namada,
Expand Down
2 changes: 2 additions & 0 deletions crates/sdk/src/control_flow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub fn install_shutdown_signal() -> ShutdownSignal {
}
}

/// Shutdown signal receiver
#[cfg(unix)]
pub async fn shutdown_send(tx: oneshot::Sender<()>) {
use tokio::signal::unix::{signal, SignalKind};
Expand Down Expand Up @@ -106,6 +107,7 @@ pub async fn shutdown_send(tx: oneshot::Sender<()>) {
}
}

/// Shutdown signal receiver
#[cfg(windows)]
pub async fn shutdown_send(tx: oneshot::Sender<()>) {
let mut sigbreak = tokio::signal::windows::ctrl_break().unwrap();
Expand Down
1 change: 1 addition & 0 deletions crates/sdk/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum Error {
/// Ethereum bridge related errors
#[error("{0}")]
EthereumBridge(#[from] EthereumBridgeError),
/// Arithmetic error
#[error("Arithmetic {0}")]
Arith(#[from] arith::Error),
/// Any Other errors that are uncategorized
Expand Down
3 changes: 3 additions & 0 deletions crates/sdk/src/io.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! Traits for implementing IO handlers. This is to enable
//! generic IO. The defaults are the obvious Rust native
//! functions.
#![allow(clippy::print_stdout, clippy::print_stderr)]

use crate::{MaybeSend, MaybeSync};

/// A trait that abstracts out I/O operations
Expand Down
Loading

0 comments on commit 8cb095c

Please sign in to comment.