From 31fff4b10ee6d17d9236cefac46fcf725001b2b9 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 26 Mar 2023 19:20:20 -0400 Subject: [PATCH] Disallow some restriction lints (#3754) --- .cargo/config.toml | 7 +++++++ crates/ruff/src/checkers/ast/mod.rs | 3 +-- crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs | 2 +- .../src/rules/flake8_simplify/rules/yoda_conditions.rs | 2 +- .../ruff/src/rules/pylint/rules/bad_string_format_type.rs | 2 +- crates/ruff_macros/src/config.rs | 2 -- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 27bc03c090..3a7caaff78 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -26,4 +26,11 @@ rustflags = [ "-Wclippy::print_stdout", "-Wclippy::print_stderr", "-Wclippy::dbg_macro", + "-Wclippy::empty_drop", + "-Wclippy::empty_structs_with_brackets", + "-Wclippy::exit", + "-Wclippy::get_unwrap", + "-Wclippy::rc_buffer", + "-Wclippy::rc_mutex", + "-Wclippy::rest_pat_in_fully_bound_structs", ] diff --git a/crates/ruff/src/checkers/ast/mod.rs b/crates/ruff/src/checkers/ast/mod.rs index 25530eb40c..ab089d11b1 100644 --- a/crates/ruff/src/checkers/ast/mod.rs +++ b/crates/ruff/src/checkers/ast/mod.rs @@ -56,7 +56,6 @@ mod deferred; type AnnotationContext = (bool, bool); -#[allow(clippy::struct_excessive_bools)] pub struct Checker<'a> { // Settings, static metadata, etc. pub path: &'a Path, @@ -3582,7 +3581,7 @@ where } else { // Ex) DefaultNamedArg(type="bool", name="some_prop_name") for keyword in keywords { - let KeywordData { value, arg, .. } = &keyword.node; + let KeywordData { value, arg } = &keyword.node; if arg.as_ref().map_or(false, |arg| arg == "type") { visit_type_definition!(self, value); } else { diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs index 087b16aa97..8389d6be68 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs @@ -73,7 +73,7 @@ impl AlwaysAutofixableViolation for CompareWithTuple { } fn autofix_title(&self) -> String { - let CompareWithTuple { replacement, .. } = self; + let CompareWithTuple { replacement } = self; format!("Replace with `{replacement}`") } } diff --git a/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs b/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs index dabaf64cff..01ec44e246 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs @@ -31,7 +31,7 @@ impl Violation for YodaConditions { } fn autofix_title_formatter(&self) -> Option String> { - let YodaConditions { suggestion, .. } = self; + let YodaConditions { suggestion } = self; if suggestion.is_some() { Some(|YodaConditions { suggestion }| { let suggestion = suggestion.as_ref().unwrap(); diff --git a/crates/ruff/src/rules/pylint/rules/bad_string_format_type.rs b/crates/ruff/src/rules/pylint/rules/bad_string_format_type.rs index 17b4d64539..20ef7bd0fb 100644 --- a/crates/ruff/src/rules/pylint/rules/bad_string_format_type.rs +++ b/crates/ruff/src/rules/pylint/rules/bad_string_format_type.rs @@ -172,7 +172,7 @@ fn is_valid_constant(formats: &[CFormatStrOrBytes], value: &Expr) -> boo if formats.len() != 1 { return true; } - let format = formats.get(0).unwrap(); + let format = formats[0]; equivalent(format, value) } diff --git a/crates/ruff_macros/src/config.rs b/crates/ruff_macros/src/config.rs index 1fb8da74d7..0a6e4f932c 100644 --- a/crates/ruff_macros/src/config.rs +++ b/crates/ruff_macros/src/config.rs @@ -82,7 +82,6 @@ fn handle_option_group(field: &Field) -> syn::Result { ident: type_ident, arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments { args, .. }), - .. }) if type_ident == "Option" => { let path = &args[0]; let kebab_name = LitStr::new(&ident.to_string().replace('_', "-"), ident.span()); @@ -142,7 +141,6 @@ fn handle_option( default, value_type, example, - .. } = attr.parse_args::()?; let kebab_name = LitStr::new(&ident.to_string().replace('_', "-"), ident.span());