Skip to content

Commit

Permalink
clippy::missing_asserts_for_indexing & use fail_incorrectusage_clier…
Browse files Browse the repository at this point in the history
…ror macro

in main for all binary variants
  • Loading branch information
jqnatividad committed Nov 18, 2023
1 parent b5fae59 commit 97d2e1d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
clippy::use_self,
clippy::cognitive_complexity,
clippy::option_if_let_else,
),
warn(
clippy::missing_asserts_for_indexing,
)
)]

Expand Down Expand Up @@ -386,11 +389,12 @@ impl Command {
let argv: Vec<_> = argv.iter().map(|s| &**s).collect();
let argv = &*argv;

assert!(argv.len() > 1);
if !argv[1].chars().all(char::is_lowercase) {
return Err(CliError::Other(format!(
return fail_incorrectusage_clierror!(
"qsv expects commands in lowercase. Did you mean '{}'?",
argv[1].to_lowercase()
)));
);
}

CURRENT_COMMAND.get_or_init(|| argv[1].to_lowercase());
Expand Down
7 changes: 4 additions & 3 deletions src/maindp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,12 @@ impl Command {
let argv: Vec<_> = argv.iter().map(|s| &**s).collect();
let argv = &*argv;

assert!(argv.len() > 1);
if !argv[1].chars().all(char::is_lowercase) {
return Err(CliError::Other(format!(
"qsvdp expects commands in lowercase. Did you mean '{}'?",
return fail_incorrectusage_clierror!(
"qsv expects commands in lowercase. Did you mean '{}'?",
argv[1].to_lowercase()
)));
);
}
CURRENT_COMMAND.get_or_init(|| argv[1].to_lowercase());
match self {
Expand Down
7 changes: 4 additions & 3 deletions src/mainlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,12 @@ impl Command {
let argv: Vec<_> = argv.iter().map(|s| &**s).collect();
let argv = &*argv;

assert!(argv.len() > 1);
if !argv[1].chars().all(char::is_lowercase) {
return Err(CliError::Other(format!(
"qsvlite expects commands in lowercase. Did you mean '{}'?",
return fail_incorrectusage_clierror!(
"qsv expects commands in lowercase. Did you mean '{}'?",
argv[1].to_lowercase()
)));
);
}
CURRENT_COMMAND.get_or_init(|| argv[1].to_lowercase());
match self {
Expand Down

0 comments on commit 97d2e1d

Please sign in to comment.