From 729571c60910eacdeefe087efff1b046b3dc238a Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Tue, 23 Jul 2024 16:41:11 -0400 Subject: [PATCH] Clippy --- .cargo/config | 52 --------------------------------------------------- Cargo.toml | 45 +++++++++++++++++++++++++++++++++++++++++++- src/config.rs | 15 ++++++--------- 3 files changed, 50 insertions(+), 62 deletions(-) delete mode 100644 .cargo/config diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index cc55bd0..0000000 --- a/.cargo/config +++ /dev/null @@ -1,52 +0,0 @@ -[target.'cfg(all())'] -rustflags = [ - #### DOES NOT CHANGE #### - - # Forbids - "-Fclippy::dbg_macro", - "-Fclippy::string_to_string", - - # Denies - "-Dclippy::pedantic", - "-Dclippy::all", - "-Drust_2018_idioms", - "-Dtrivial_casts", - "-Dtrivial_numeric_casts", - "-Dunused_import_braces", - "-Dexplicit_outlives_requirements", - - # Allows - "-Aunknown_lints", - "-Aclippy::too_many_lines", - "-Aclippy::cast_precision_loss", - "-Aclippy::cast_sign_loss", - "-Aclippy::cast_possible_wrap", - "-Aclippy::cast_possible_truncation", - "-Aclippy::module_name_repetitions", - "-Aclippy::must_use_candidate", - "-Alet_underscore_drop", - "-Aclippy::match_wildcard_for_single_variants", - "-Aclippy::semicolon_if_nothing_returned", - "-Aclippy::new_without_default", - "-Aclippy::from_over_into", - "-Aclippy::upper_case_acronyms", - "-Aclippy::single_match_else", - "-Aclippy::similar_names", - "-Aclippy::len_without_is_empty", - "-Aclippy::needless_late_init", - "-Aclippy::type_complexity", - "-Aclippy::type_repetition_in_bounds", - "-Aunused_qualifications", - "-Aclippy::return_self_not_must_use", - "-Aclippy::bool_to_int_with_if", - "-Aclippy::uninlined_format_args", - "-Aclippy::manual_let_else", - - # For Library docs - # "-Dmissing_docs", - # "-Drustdoc::broken_intra_doc_links", - # "-Aclippy::doc_markdown", - # "-Aclippy::tabs_in_doc_comments", - - #### EXTRAS BELOW #### -] \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 63ad59e..c08326d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,4 +23,47 @@ reqwest = { version = "0.12.5", features = ["blocking"] } serde = { version = "1.0.145", features = ["derive"] } thiserror = "1.0.37" toml = "0.8.15" -dirs = "5.0.1" \ No newline at end of file +dirs = "5.0.1" + +[lints.rust] +rust_2018_idioms = { level = "deny", priority = -1 } +trivial_casts = "deny" +trivial_numeric_casts = "deny" +unused_import_braces = "deny" +explicit_outlives_requirements = "deny" +unknown_lints = "allow" + +[lints.clippy] +pedantic = { level = "deny", priority = -1 } +all = { level = "deny", priority = -1 } +too_many_lines = "allow" +cast_precision_loss = "allow" +cast_sign_loss = "allow" +cast_possible_wrap = "allow" +cast_possible_truncation = "allow" +module_name_repetitions = "allow" +must_use_candidate = "allow" +doc_markdown = "allow" +match_wildcard_for_single_variants = "allow" +semicolon_if_nothing_returned = "allow" +from_over_into = "allow" +upper_case_acronyms = "allow" +single_match_else = "allow" +similar_names = "allow" +tabs_in_doc_comments = "allow" +len_without_is_empty = "allow" +needless_late_init = "allow" +type_complexity = "allow" +return_self_not_must_use = "allow" +bool_to_int_with_if = "allow" +uninlined_format_args = "allow" # This should be changed for any normal "{}", but I'm not a fan of it for any debug or width specific formatting +let_underscore_untyped = "allow" +field_reassign_with_default = "allow" +manual_range_patterns = "allow" # This is not at all clearer as it suggests +no_effect_underscore_binding = "allow" +used_underscore_binding = "allow" +ignored_unit_patterns = "allow" # Not a fan of this lint, doesn't make anything clearer as it claims +needless_return = "allow" # Explicit returns are needed from time to time for clarity +redundant_guards = "allow" # Currently broken for some cases, might enable later +into_iter_without_iter = "allow" # This is only going to fire on some internal types, doesn't matter much +struct_excessive_bools = "allow" # I have yet to find one case of this being useful \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index 10987ba..f9da0ce 100644 --- a/src/config.rs +++ b/src/config.rs @@ -22,15 +22,12 @@ impl Default for Config { impl Config { pub fn read() -> Result { - let config_dir = match dirs::config_dir() { - Some(dir) => dir, - None => { - log::warn!( - "Failed to find config dir, using default config. Consider setting \ - `XDG_CONFIG_HOME`." - ); - return Ok(Self::default()); - }, + let Some(config_dir) = dirs::config_dir() else { + log::warn!( + "Failed to find config dir, using default config. Consider setting \ + `XDG_CONFIG_HOME`." + ); + return Ok(Self::default()); }; let config_dir = config_dir.join("lyr");