You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of 1.5.1, running cargo clippy -- -A clippy::module_inception from offchain/ results in:
offchain$ cargo clippy -- -A clippy::module_inception
warning: assigning the result of `Clone::clone()` may be inefficient
--> rollups-events/src/broker/indexer.rs:87:13
|
87 | state.inputs_last_id = event.id.clone();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `state.inputs_last_id.clone_from(&event.id)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones
= note: `#[warn(clippy::assigning_clones)]` on by default
warning: assigning the result of `Clone::clone()` may be inefficient
--> rollups-events/src/broker/indexer.rs:99:13
|
99 | state.outputs_last_id = event.id.clone();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `state.outputs_last_id.clone_from(&event.id)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones
warning: `rollups-events` (lib) generated 2 warnings (run `cargo clippy --fix --lib -p rollups-events` to apply 2 suggestions)
warning: item has both inner and outer attributes
--> /home/marcel/development/cartesi/rollups-node/offchain/target/debug/build/contracts-e6be818570e43ef9/out/input_box.rs:2:1
|
2 | / #[allow(clippy::too_many_arguments, non_camel_case_types)]
3 | | pub mod input_box {
4 | | #![allow(clippy::enum_variant_names)]
5 | | #![allow(dead_code)]
6 | | #![allow(clippy::type_complexity)]
7 | | #![allow(unused_imports)]
| |_____________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mixed_attributes_style
= note: `#[warn(clippy::mixed_attributes_style)]` on by default
warning: item has both inner and outer attributes
--> /home/marcel/development/cartesi/rollups-node/offchain/target/debug/build/contracts-e6be818570e43ef9/out/authority.rs:2:1
|
2 | / #[allow(clippy::too_many_arguments, non_camel_case_types)]
3 | | pub mod authority {
4 | | #![allow(clippy::enum_variant_names)]
5 | | #![allow(dead_code)]
6 | | #![allow(clippy::type_complexity)]
7 | | #![allow(unused_imports)]
| |_____________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mixed_attributes_style
warning: item has both inner and outer attributes
--> /home/marcel/development/cartesi/rollups-node/offchain/target/debug/build/contracts-e6be818570e43ef9/out/history.rs:2:1
|
2 | / #[allow(clippy::too_many_arguments, non_camel_case_types)]
3 | | pub mod history {
4 | | #![allow(clippy::enum_variant_names)]
5 | | #![allow(dead_code)]
6 | | #![allow(clippy::type_complexity)]
7 | | #![allow(unused_imports)]
| |_____________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mixed_attributes_style
warning: item has both inner and outer attributes
--> /home/marcel/development/cartesi/rollups-node/offchain/target/debug/build/contracts-e6be818570e43ef9/out/cartesi_dapp.rs:2:1
|
2 | / #[allow(clippy::too_many_arguments, non_camel_case_types)]
3 | | pub mod cartesi_d_app {
4 | | #![allow(clippy::enum_variant_names)]
5 | | #![allow(dead_code)]
6 | | #![allow(clippy::type_complexity)]
7 | | #![allow(unused_imports)]
| |_____________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mixed_attributes_style
warning: `contracts` (lib) generated 4 warnings
warning: called `map(..).flatten()` on `Option`
--> types/src/blockchain_config.rs:128:18
|
128 | .map(|c| c.address)
| __________________^
129 | | .flatten());
| |__________________________^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|c| c.address)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
= note: `#[warn(clippy::map_flatten)]` on by default
warning: called `map(..).flatten()` on `Option`
--> types/src/blockchain_config.rs:133:18
|
133 | .map(|c| c.address)
| __________________^
134 | | .flatten());
| |__________________________^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|c| c.address)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
warning: called `map(..).flatten()` on `Option`
--> types/src/blockchain_config.rs:138:18
|
138 | .map(|c| c.address)
| __________________^
139 | | .flatten());
| |__________________________^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|c| c.address)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
warning: `types` (lib) generated 3 warnings (run `cargo clippy --fix --lib -p types` to apply 3 suggestions)
warning: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
--> graphql-server/src/http.rs:67:17
|
67 | move || {
| _________________^
68 | | let res =
69 | | query.execute_sync(&http_context.schema, &http_context.context);
70 | | serde_json::to_string(&res)
71 | | },
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions
= note: `#[warn(clippy::blocks_in_conditions)]` on by default
warning: `graphql-server` (lib) generated 1 warning
warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
--> dispatcher/src/drivers/context.rs:81:9
|
81 | // self.last_finished_epoch.map(|last_finished_epoch| {
82 | || // Asserting that the calculated epoch comes after the last finished epoch.
83 | || // (If last_finished_epoch == None then we don't need the assertion.)
84 | || assert!(input_epoch > last_finished_epoch)
85 | || });
| ||__________^- help: try: `if let Some(last_finished_epoch) = self.last_finished_epoch { ... }`
| |__________|
|
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn
= note: `#[warn(clippy::option_map_unit_fn)]` on by default
warning: `dispatcher` (lib) generated 1 warning
warning: called `map(..).flatten()` on `Option`
--> authority-claimer/src/checker.rs:126:14
|
126 | .map(|claims| claims.last()) // Maps to Option<Option<Claim>>
| ______________^
127 | | .flatten() // Back to only one Option
| |______________________^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|claims| claims.last())`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
= note: `#[warn(clippy::map_flatten)]` on by default
warning: called `map(..).flatten()` on `Option`
--> authority-claimer/src/config/contracts.rs:56:18
|
56 | .map(|c| c.address)
| __________________^
57 | | .flatten());
| |__________________________^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|c| c.address)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
warning: called `map(..).flatten()` on `Option`
--> authority-claimer/src/config/contracts.rs:61:18
|
61 | .map(|c| c.address)
| __________________^
62 | | .flatten());
| |__________________________^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|c| c.address)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
warning: bound is defined in more than one place
--> state-server/src/lib.rs:29:25
|
29 | pub async fn run_server<F: Foldable<UserData = Mutex<UserData>> + 'static>(
| ^
...
34 | F: serde::ser::Serialize,
| ^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
= note: `#[warn(clippy::multiple_bound_locations)]` on by default
warning: `authority-claimer` (lib) generated 3 warnings (run `cargo clippy --fix --lib -p authority-claimer` to apply 3 suggestions)
warning: `state-server` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.29s
✔️ Solution
Change code to remove warnings.
📈 Subtasks
Apply suggestions made by clippy
Address remaining warnings
Make sure everything works as expected
The text was updated successfully, but these errors were encountered:
📚 Context
As of 1.5.1, running
cargo clippy -- -A clippy::module_inception
fromoffchain/
results in:✔️ Solution
Change code to remove warnings.
📈 Subtasks
clippy
The text was updated successfully, but these errors were encountered: