Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy: add more lints #20

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 91 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,99 @@ categories = ["cryptography", "cryptography::cryptocurrencies"]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[workspace.lints.clippy]
dbg-macro = "warn"
manual-string-new = "warn"
uninlined-format-args = "warn"
use-self = "warn"
[workspace.lints]
rust.missing_debug_implementations = "warn"
rust.missing_docs = "warn"
rust.rust_2018_idioms = { level = "deny", priority = -1 }
rust.unreachable_pub = "warn"
rust.unused_must_use = "deny"
rustdoc.all = "warn"
rust.unnameable-types = "warn"

[workspace.lints.rust]
rust-2018-idioms = "deny"
unreachable-pub = "warn"
unused-must-use = "deny"
missing_docs = "warn"
[workspace.lints.clippy]
# These are some of clippy's nursery (i.e., experimental) lints that we like.
# By default, nursery lints are allowed. Some of the lints below have made good
# suggestions which we fixed. The others didn't have any findings, so we can
# assume they don't have that many false positives. Let's enable them to
# prevent future problems.
borrow_as_ptr = "warn"
branches_sharing_code = "warn"
clear_with_drain = "warn"
cloned_instead_of_copied = "warn"
collection_is_never_read = "warn"
derive_partial_eq_without_eq = "warn"
doc_markdown = "warn"
empty_line_after_doc_comments = "warn"
empty_line_after_outer_attr = "warn"
enum_glob_use = "warn"
equatable_if_let = "warn"
explicit_into_iter_loop = "warn"
explicit_iter_loop = "warn"
flat_map_option = "warn"
from_iter_instead_of_collect = "warn"
if_not_else = "warn"
implicit_clone = "warn"
imprecise_flops = "warn"
iter_on_empty_collections = "warn"
iter_on_single_items = "warn"
iter_with_drain = "warn"
iter_without_into_iter = "warn"
large_stack_frames = "warn"
manual_assert = "warn"
manual_clamp = "warn"
manual_is_variant_and = "warn"
manual_string_new = "warn"
match_same_arms = "warn"
missing_const_for_fn = "warn"
mutex_integer = "warn"
naive_bytecount = "warn"
needless_bitwise_bool = "warn"
needless_continue = "warn"
needless_for_each = "warn"
needless_pass_by_ref_mut = "warn"
nonstandard_macro_braces = "warn"
option_as_ref_cloned = "warn"
or_fun_call = "warn"
path_buf_push_overwrite = "warn"
read_zero_byte_vec = "warn"
redundant_clone = "warn"
redundant_else = "warn"
single_char_pattern = "warn"
string_lit_as_bytes = "warn"
string_lit_chars_any = "warn"
suboptimal_flops = "warn"
suspicious_operation_groupings = "warn"
trailing_empty_array = "warn"
trait_duplication_in_bounds = "warn"
transmute_undefined_repr = "warn"
trivial_regex = "warn"
tuple_array_conversions = "warn"
type_repetition_in_bounds = "warn"
uninhabited_references = "warn"
unnecessary_self_imports = "warn"
unnecessary_struct_initialization = "warn"
unnested_or_patterns = "warn"
unused_peekable = "warn"
unused_rounding = "warn"
use_self = "warn"
useless_let_if_seq = "warn"
while_float = "warn"
zero_sized_map_values = "warn"

[workspace.lints.rustdoc]
all = "warn"
# These are nursery lints which have findings. Allow them for now. Some are not
# quite mature enough for use in our codebase and some we don't really want.
# Explicitly listing should make it easier to fix in the future.
as_ptr_cast_mut = "allow"
cognitive_complexity = "allow"
debug_assert_with_mut_call = "allow"
fallible_impl_from = "allow"
future_not_send = "allow"
needless_collect = "allow"
non_send_fields_in_send_ty = "allow"
redundant_pub_crate = "allow"
significant_drop_in_scrutinee = "allow"
significant_drop_tightening = "allow"
too_long_first_doc_paragraph = "allow"

[profile.release]
opt-level = 3
Expand Down
2 changes: 1 addition & 1 deletion bin/odyssey/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn main() {
.with_add_ons(OptimismAddOns::new(rollup_args.sequencer_http.clone()))
.extend_rpc_modules(move |ctx| {
// register sequencer tx forwarder
if let Some(sequencer_http) = rollup_args.sequencer_http.clone() {
if let Some(sequencer_http) = rollup_args.sequencer_http {
ctx.registry
.eth_api()
.set_sequencer_client(SequencerClient::new(sequencer_http))?;
Expand Down
6 changes: 3 additions & 3 deletions crates/node/src/evm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! # Odyssey EVM configuration
//!
//! The [OdysseyEvmConfig] type implements the [ConfigureEvm] and [ConfigureEvmEnv] traits,
//! The [`OdysseyEvmConfig`] type implements the [`ConfigureEvm`] and [`ConfigureEvmEnv`] traits,
//! configuring the custom Odyssey precompiles and instructions.
//!
//! These trait implementations allow for custom precompiles and instructions to be implemented and
Expand Down Expand Up @@ -47,8 +47,8 @@ impl OdysseyEvmConfig {

/// Sets the precompiles to the EVM handler
///
/// This will be invoked when the EVM is created via [ConfigureEvm::evm] or
/// [ConfigureEvm::evm_with_inspector]
/// This will be invoked when the EVM is created via [`ConfigureEvm::evm`] or
/// [`ConfigureEvm::evm_with_inspector`]
///
/// This will use the default mainnet precompiles and add additional precompiles.
fn set_precompiles<EXT, DB>(handler: &mut EvmHandler<'_, EXT, DB>)
Expand Down
14 changes: 7 additions & 7 deletions crates/node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//! Standalone crate for Odyssey's node configuration and builder types.
//!
//! This contains mainly two types, [OdysseyNode](node::OdysseyNode) and
//! [OdysseyEvmConfig](evm::OdysseyEvmConfig).
//! This contains mainly two types, [`OdysseyNode`](node::OdysseyNode) and
//! [`OdysseyEvmConfig`](evm::OdysseyEvmConfig).
//!
//! The [OdysseyNode](node::OdysseyNode) type implements the
//! [NodeTypes](reth_node_builder::NodeTypes) trait, and configures the engine types required for
//! The [`OdysseyNode`](node::OdysseyNode) type implements the
//! [`NodeTypes`](reth_node_builder::NodeTypes) trait, and configures the engine types required for
//! the optimism engine API.
//!
//! The [OdysseyEvmConfig](evm::OdysseyEvmConfig) type implements the
//! [ConfigureEvm](reth_node_api::ConfigureEvm) and
//! [ConfigureEvmEnv](reth_node_api::ConfigureEvmEnv) traits, configuring the custom Odyssey
//! The [`OdysseyEvmConfig`](evm::OdysseyEvmConfig) type implements the
//! [`ConfigureEvm`](reth_node_api::ConfigureEvm) and
//! [`ConfigureEvmEnv`](reth_node_api::ConfigureEvmEnv) traits, configuring the custom Odyssey
//! precompiles and instructions.

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
Expand Down
6 changes: 3 additions & 3 deletions crates/node/src/node.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! # Odyssey Node types configuration
//!
//! The [OdysseyNode] type implements the [NodeTypes] trait, and configures the engine types
//! The [`OdysseyNode`] type implements the [`NodeTypes`] trait, and configures the engine types
//! required for the optimism engine API.

use crate::evm::OdysseyEvmConfig;
Expand Down Expand Up @@ -43,7 +43,7 @@ impl OdysseyNode {
Self { args }
}

/// Returns the components for the given [RollupArgs].
/// Returns the components for the given [`RollupArgs`].
pub fn components<Node>(
args: &RollupArgs,
) -> ComponentsBuilder<
Expand Down Expand Up @@ -173,7 +173,7 @@ where
ctx: &BuilderContext<Node>,
pool: Pool,
) -> eyre::Result<PayloadBuilderHandle<OptimismEngineTypes>> {
self.inner.spawn(OdysseyEvmConfig::new(ctx.chain_spec().clone()), ctx, pool)
self.inner.spawn(OdysseyEvmConfig::new(ctx.chain_spec()), ctx, pool)
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/testing/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[test]
fn dummy() {
const fn dummy() {
// kept here to prevent the ci from failing on no tests
}
2 changes: 2 additions & 0 deletions crates/wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ impl From<OdysseyWalletError> for jsonrpsee::types::error::ErrorObject<'static>
}

/// Implementation of the Odyssey `wallet_` namespace.
#[derive(Debug)]
pub struct OdysseyWallet<Provider, Eth> {
inner: Arc<OdysseyWalletInner<Provider, Eth>>,
}
Expand Down Expand Up @@ -310,6 +311,7 @@ where
}

/// Implementation of the Odyssey `wallet_` namespace.
#[derive(Debug)]
struct OdysseyWalletInner<Provider, Eth> {
provider: Provider,
eth_api: Eth,
Expand Down