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

build: Do not rely on RUSTFLAGS for Clippy lint configuration #499

Merged
merged 5 commits into from
Jun 7, 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
12 changes: 7 additions & 5 deletions .cargo-husky/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Intended to be in sync with .github/workflows/hardhat-core-ci.yml's
# test-edr-rs
# Intended to be in sync with .github/workflows/edr-ci.yml's `test-edr-rs` job.


if [ -z "${ALCHEMY_URL}" ] || [ -z "${INFURA_URL}" ]; then
echo WARNING: skipping remote tests because the ALCHEMY_URL and INFURA_URL environment variables are not defined. Local test results may differ from those in CI.
Expand All @@ -13,9 +13,11 @@ fi
# Set -x here to avoid printing secrets
set -xe

# Setting RUSTFLAGS env for clippy makes it not include custom rules
RUSTFLAGS=-Dwarnings cargo check --workspace --all-targets ${ALL_FEATURES}
cargo clippy --all --all-targets ${ALL_FEATURES} -- -D warnings
# Do not modify or set RUSTFLAGS as this overrides any flags that may have been set
# by the user and prevents from reusing the build cache.
# See https://github.com/rust-lang/cargo/issues/8424#issuecomment-1734683743 and the thread.

cargo clippy --workspace --all-targets ${ALL_FEATURES} -- --deny warnings
cargo +nightly fmt --all -- --check
cargo test --doc --workspace ${ALL_FEATURES}
cargo test --workspace --all-targets ${ALL_FEATURES}
83 changes: 0 additions & 83 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,86 +3,3 @@ gen-execution-api = "run --bin tools -- gen-execution-api"
scenario = "run --release --bin tools -- scenario"
scenario-with-tracing = "run --release --features tracing --bin tools -- scenario"
replay-block = "run --release --bin tools -- replay-block"

[target.'cfg(all())']
rustflags = [
"-Wclippy::all",
"-Wclippy::await_holding_lock",
"-Wclippy::bool-to-int-with-if",
"-Wclippy::cast_lossless",
"-Wclippy::char_lit_as_u8",
"-Wclippy::checked_conversions",
"-Wclippy::dbg_macro",
"-Wclippy::debug_assert_with_mut_call",
"-Wclippy::default_trait_access",
"-Wclippy::doc_markdown",
"-Wclippy::empty_enum",
"-Wclippy::enum_glob_use",
"-Wclippy::exit",
"-Wclippy::expl_impl_clone_on_copy",
"-Wclippy::explicit_deref_methods",
"-Wclippy::explicit_into_iter_loop",
"-Wclippy::fallible_impl_from",
"-Wclippy::filter_map_next",
"-Wclippy::flat_map_option",
"-Wclippy::float_cmp_const",
"-Wclippy::fn_params_excessive_bools",
"-Wclippy::from_iter_instead_of_collect",
"-Wclippy::if-not-else",
"-Wclippy::implicit_clone",
"-Wclippy::imprecise_flops",
"-Wclippy::inconsistent_struct_constructor",
"-Wclippy::inefficient_to_string",
"-Wclippy::invalid_upcast_comparisons",
"-Wclippy::items-after-statements",
"-Wclippy::large_digit_groups",
"-Wclippy::large_stack_arrays",
"-Wclippy::large_types_passed_by_value",
"-Wclippy::let_unit_value",
"-Wclippy::linkedlist",
"-Wclippy::lossy_float_literal",
"-Wclippy::macro_use_imports",
"-Wclippy::manual-assert",
"-Wclippy::manual_ok_or",
"-Wclippy::map_err_ignore",
"-Wclippy::map_flatten",
"-Wclippy::map_unwrap_or",
"-Wclippy::match_on_vec_items",
"-Wclippy::match_same_arms",
"-Wclippy::match_wild_err_arm",
"-Wclippy::match_wildcard_for_single_variants",
"-Wclippy::mem_forget",
"-Wclippy::missing_enforced_import_renames",
"-Wclippy::mut_mut",
"-Wclippy::mutex_integer",
"-Wclippy::needless_borrow",
"-Wclippy::needless_continue",
"-Wclippy::needless_for_each",
"-Wclippy::option_option",
"-Wclippy::path_buf_push_overwrite",
"-Wclippy::ptr_as_ptr",
"-Wclippy::rc_mutex",
"-Wclippy::redundant_closure_for_method_calls",
"-Wclippy::ref_option_ref",
"-Wclippy::rest_pat_in_fully_bound_structs",
"-Wclippy::same_functions_in_if_condition",
"-Wclippy::semicolon_if_nothing_returned",
"-Wclippy::single_match_else",
"-Wclippy::string_add_assign",
"-Wclippy::string_add",
"-Wclippy::string_lit_as_bytes",
"-Wclippy::string_to_string",
"-Wclippy::todo",
"-Wclippy::trait_duplication_in_bounds",
"-Wclippy::unimplemented",
"-Wclippy::uninlined_format_args",
"-Wclippy::unnested_or_patterns",
"-Wclippy::unused_self",
"-Wclippy::useless_transmute",
"-Wclippy::verbose_file_reads",
"-Wclippy::wildcard-imports",
"-Wclippy::zero_sized_map_values",
"-Wfuture_incompatible",
"-Wnonstandard_style",
"-Wrust_2018_idioms",
]
10 changes: 4 additions & 6 deletions .github/workflows/edr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ on:
- "crates/**"
workflow_dispatch:

env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings

concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
Expand All @@ -29,10 +33,6 @@ jobs:
check-edr:
name: Check EDR
runs-on: ubuntu-latest
# Setting RUSTFLAGS env for clippy makes it not include custom rules
env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -170,8 +170,6 @@ jobs:

- name: Cargo doc
uses: actions-rs/cargo@v1
env:
RUSTDOCFLAGS: "-D warnings"
with:
command: doc
args: --workspace --no-deps --all-features
Expand Down
83 changes: 83 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,86 @@ rpath = true

[profile.test]
opt-level = 2

[workspace.lints.rust]
future_incompatible = "warn"
nonstandard_style = "warn"
rust_2018_idioms = "warn"

[workspace.lints.clippy]
all = "warn"
await_holding_lock = "warn"
bool-to-int-with-if = "warn"
cast_lossless = "warn"
char_lit_as_u8 = "warn"
checked_conversions = "warn"
dbg_macro = "warn"
debug_assert_with_mut_call = "warn"
default_trait_access = "warn"
doc_markdown = "warn"
empty_enum = "warn"
enum_glob_use = "warn"
exit = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
fallible_impl_from = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
float_cmp_const = "warn"
fn_params_excessive_bools = "warn"
from_iter_instead_of_collect = "warn"
if-not-else = "warn"
implicit_clone = "warn"
imprecise_flops = "warn"
inconsistent_struct_constructor = "warn"
inefficient_to_string = "warn"
invalid_upcast_comparisons = "warn"
items-after-statements = "warn"
large_digit_groups = "warn"
large_stack_arrays = "warn"
large_types_passed_by_value = "warn"
let_unit_value = "warn"
linkedlist = "warn"
lossy_float_literal = "warn"
macro_use_imports = "warn"
manual-assert = "warn"
manual_ok_or = "warn"
map_err_ignore = "warn"
map_flatten = "warn"
map_unwrap_or = "warn"
match_on_vec_items = "warn"
match_same_arms = "warn"
match_wild_err_arm = "warn"
match_wildcard_for_single_variants = "warn"
mem_forget = "warn"
missing_enforced_import_renames = "warn"
mut_mut = "warn"
mutex_integer = "warn"
needless_borrow = "warn"
needless_continue = "warn"
needless_for_each = "warn"
option_option = "warn"
path_buf_push_overwrite = "warn"
ptr_as_ptr = "warn"
rc_mutex = "warn"
redundant_closure_for_method_calls = "warn"
ref_option_ref = "warn"
rest_pat_in_fully_bound_structs = "warn"
same_functions_in_if_condition = "warn"
semicolon_if_nothing_returned = "warn"
single_match_else = "warn"
string_add_assign = "warn"
string_add = "warn"
string_lit_as_bytes = "warn"
string_to_string = "warn"
todo = "warn"
trait_duplication_in_bounds = "warn"
unimplemented = "warn"
uninlined_format_args = "warn"
unnested_or_patterns = "warn"
unused_self = "warn"
useless_transmute = "warn"
verbose_file_reads = "warn"
wildcard-imports = "warn"
zero_sized_map_values = "warn"
3 changes: 3 additions & 0 deletions crates/edr_defaults/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ version = "0.3.5"
edition = "2021"

[dependencies]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/edr_eth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ serde = ["dep:serde", "c-kzg/serde", "revm-primitives/serde"]
std = ["hash256-std-hasher/std", "hash-db/std", "hex/std", "itertools/use_std", "k256/std", "k256/precomputed-tables", "revm-primitives/std", "serde?/std", "sha2/std", "sha3/std", "triehash/std"]
test-remote = []
tracing = ["dep:tracing"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/edr_evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ tempfile = "3.7.1"
test-remote = []
test-utils = []
tracing = ["dep:tracing", "edr_eth/tracing"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/edr_napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ scenarios = ["rand"]

[profile.release]
lto = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/edr_provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ toml = { version = "0.5.9", default-features = false }
[features]
test-utils = ["anyhow"]
tracing = ["dep:tracing", "edr_eth/tracing", "edr_evm/tracing"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/edr_rpc_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ walkdir = { version = "2.3.3", default-features = false }
[features]
test-remote = []
tracing = ["dep:tracing", "dep:reqwest-tracing"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/edr_rpc_eth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ walkdir = { version = "2.3.3", default-features = false }
[features]
test-remote = []
tracing = ["dep:tracing", "edr_rpc_client/tracing"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/edr_solidity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
edr_eth = { version = "0.3.5", path = "../edr_eth" }
edr_evm = { version = "0.3.5", path = "../edr_evm" }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/edr_test_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
serde = { version = "1.0.147", default-features = false, features = ["derive"] }
serde_json = { version = "1.0.89" }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ walkdir = { version = "2.4.0", features = [] }

[features]
tracing = ["dep:tracing", "dep:tracing-flame", "dep:tracing-subscriber", "edr_eth/tracing", "edr_evm/tracing", "edr_provider/tracing"]

[lints]
workspace = true
Loading