Skip to content

Commit fcd07e4

Browse files
committed
Fix clippy errors. Minor cleanup in run_extra_checks.sh
1 parent d3eb912 commit fcd07e4

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

clippy.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Clippy will complain if objects smaller that this are boxed.
2+
# The default is 200 and we sometimes box slightly smaller objects.
3+
too-large-for-stack = 150

crates/app-core/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ fn handle_command(cmd: &Command, ctx: &mut AppContext) -> Result<Response, Statu
344344
Some(DataContext::SignMessageContext(ctx)) => ctx,
345345
_ => return Err(StatusWord::WrongContext),
346346
};
347-
let response = handle_sign_message(data, msg_ctx).map(Response::MessageSignature);
348-
response
347+
handle_sign_message(data, msg_ctx).map(Response::MessageSignature)
349348
}
350349
},
351350
Command::Ping => Ok(Response::Pong),

crates/messages/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl<'a> Apdu<'a> {
340340
param1_byte: u8,
341341
command_data: &'a [u8],
342342
) -> Option<Self> {
343-
(command_data.len() <= MAX_ADPU_DATA_LEN).then(|| Self {
343+
(command_data.len() <= MAX_ADPU_DATA_LEN).then_some(Self {
344344
instruction_byte,
345345
param1_byte,
346346
command_data,

run_extra_checks.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@ set -o nounset
55

66
# Run some extra checks (for now its mostly clippy).
77

8+
# Notes about clippy:
9+
# 1. Ledger's guideline enforcer also runs it. But at the moment of writing this it doesn't check
10+
# tests, see https://github.com/LedgerHQ/ledger-app-workflows/blob/master/scripts/check_all.sh.
11+
# Besides, we want to enable some additional checks, similar to what we do in Mintlayer Core,
12+
# so we do a separate clippy run here.
13+
# 2. The guideline enforcer runs it for all existing device models, but in this additional run this
14+
# is redundant, so we use one arbitrarily chosen model.
15+
# 3. Unlike in Mintlayer Core, we can't disable certain annoying and mostly useless checks (such as
16+
# let-and-return), because the guideline enforcer will run them anyway.
17+
818
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
919

1020
cd "$SCRIPT_DIR"
1121

1222
echo "Running cargo fmt"
1323
cargo fmt --check -- --config newline_style=Unix
1424

15-
# It doesn't matter which one we use, but we need to specify one.
1625
CLIPPY_TARGET_ARG=--target=apex_p
1726

1827
echo "Running clippy (any code)"
@@ -23,10 +32,7 @@ cargo clippy "$CLIPPY_TARGET_ARG" --all-features --workspace --bins --lib --test
2332
-D clippy::map_unwrap_or \
2433
-D clippy::unnested_or_patterns \
2534
-D clippy::mut_mut \
26-
-D clippy::todo \
27-
-A clippy::let-and-return \
28-
-A clippy::unnecessary-lazy-evaluations \
29-
-A clippy::boxed-local
35+
-D clippy::todo
3036

3137
echo "Running clippy (production code)"
3238
# TODO: consider also enabling `unwrap_used` and `items_after_statements`.

0 commit comments

Comments
 (0)