diff options
author | Tim Oram <dev@mitmaro.ca> | 2023-03-06 10:07:43 -0330 |
---|---|---|
committer | Tim Oram <dev@mitmaro.ca> | 2023-07-15 11:35:02 -0230 |
commit | 6f10b2b5e1e7793f84de54c9609e203df664865c (patch) | |
tree | d3de872e1aa5161934c416c5e850c26bf42a95e8 | |
parent | bdf2f38066bc394584bc977f8ac1ad9d66aa1130 (diff) |
Updating linting and rustfmt configs to latest
71 files changed, 554 insertions, 360 deletions
diff --git a/.rustfmt.toml b/.rustfmt.toml index 429243f..79f9d57 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,23 +1,24 @@ -#array_width - allow use_small_heuristics -#attr_fn_like_width - allow use_small_heuristics +# array_width - allow use_small_heuristics +# attr_fn_like_width - allow use_small_heuristics binop_separator = "Front" blank_lines_lower_bound = 0 blank_lines_upper_bound = 1 brace_style = "SameLineWhere" -#chain_width - allow use_small_heuristics +# chain_width - allow use_small_heuristics color = "Auto" combine_control_expr = false comment_width = 120 condense_wildcard_suffixes = true control_brace_style = "ClosingNextLine" disable_all_formatting = false -# edition - allow default +# edition - allow default read from Cargo.toml empty_item_single_line = true enum_discrim_align_threshold = 0 error_on_line_overflow = true error_on_unformatted = true -fn_args_layout = "Tall" -#fn_call_width - allow use_small_heuristics +# fn_args_layout = "Tall" - Deprecated, see fn_params_layout +# fn_call_width - allow use_small_heuristics +fn_params_layout = "Tall" fn_single_line = false force_explicit_abi = true force_multiline_blocks = true @@ -26,6 +27,7 @@ doc_comment_code_block_width = 120 format_generated_files = false format_macro_matchers = true format_macro_bodies = true +skip_macro_invocations = [] format_strings = true hard_tabs = true hex_literal_case = "Upper" @@ -55,6 +57,7 @@ reorder_modules = true short_array_element_width_threshold = 8 skip_children = false # single_line_if_else_max_width - allow use_small_heuristics +# single_line_let_else_max_width - allow use_small_heuristics space_after_colon = true space_before_colon = false spaces_around_ranges = false @@ -296,6 +296,7 @@ dependencies = [ "girt-git", "girt-testutils", "lazy_static", + "proc-macro2", "rstest", "rustc_version", "serial_test", @@ -739,9 +740,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ "unicode-ident", ] diff --git a/scripts/data/ignored-lints.txt b/scripts/data/ignored-lints.txt new file mode 100644 index 0000000..8d4e4cf --- /dev/null +++ b/scripts/data/ignored-lints.txt @@ -0,0 +1,10 @@ +This file contains any lints from rustc that have not been added, and why. + +box-pointers - This project uses Box pointers, and it is safe to do so +unstable-features - This is deprecated, and this project doesn't depend on it + +Unstable lints: + fuzzy-provenance-casts + lossy-provenance-casts + multiple-supertrait-upcastable + must-not-suspend diff --git a/scripts/data/lints.rs b/scripts/data/lints.rs index af4518c..b33c70f 100644 --- a/scripts/data/lints.rs +++ b/scripts/data/lints.rs @@ -18,7 +18,9 @@ deprecated_in_future, elided_lifetimes_in_paths, explicit_outlives_requirements, + ffi_unwind_calls, keyword_idents, + let_underscore_drop, macro_use_extern_crate, meta_variable_misuse, missing_abi, @@ -38,7 +40,6 @@ unreachable_pub, unsafe_code, unsafe_op_in_unsafe_fn, - unstable_features, unused_crate_dependencies, unused_extern_crates, unused_import_braces, @@ -46,6 +47,7 @@ unused_macro_rules, unused_qualifications, unused_results, + unused_tuple_struct_fields, variant_size_differences )] // enable all of Clippy's lints @@ -53,6 +55,7 @@ #![cfg_attr(include_nightly_lints, deny(clippy::nursery))] #![allow( clippy::arithmetic_side_effects, + clippy::arithmetic_side_effects, clippy::blanket_clippy_restriction_lints, clippy::bool_to_int_with_if, clippy::default_numeric_fallback, @@ -61,7 +64,6 @@ clippy::float_arithmetic, clippy::implicit_return, clippy::indexing_slicing, - clippy::integer_arithmetic, clippy::map_err_ignore, clippy::missing_docs_in_private_items, clippy::missing_trait_methods, @@ -71,10 +73,13 @@ clippy::non_ascii_literal, clippy::option_if_let_else, clippy::pub_use, + clippy::question_mark_used, clippy::redundant_pub_crate, + clippy::ref_patterns, clippy::std_instead_of_alloc, clippy::std_instead_of_core, clippy::tabs_in_doc_comments, + clippy::tests_outside_test_module, clippy::too_many_lines, clippy::unwrap_used )] @@ -91,9 +96,10 @@ #![cfg_attr( test, allow( + let_underscore_drop, clippy::cognitive_complexity, - clippy::let_underscore_drop, clippy::let_underscore_must_use, + clippy::let_underscore_untyped, clippy::needless_pass_by_value, clippy::panic, clippy::shadow_reuse, @@ -104,4 +110,14 @@ ) )] // allowable upcoming nightly lints -#![cfg_attr(include_nightly_lints, allow(clippy::semicolon_outside_block))] +#![cfg_attr( + include_nightly_lints, + allow( + clippy::arc_with_non_send_sync, + clippy::min_ident_chars, + clippy::needless_raw_strings, + clippy::pub_with_shorthand, + clippy::redundant_closure_call, + clippy::single_call_fn + ) +)] diff --git a/src/config/Cargo.toml b/src/config/Cargo.toml index dabf43a..e0f0cf1 100644 --- a/src/config/Cargo.toml +++ b/src/config/Cargo.toml @@ -17,6 +17,7 @@ name = "config" [dependencies] thiserror = "1.0.38" girt-git = {version = "2.2.0", path = "../../src/git"} +proc-macro2 = "1.0.64" # TODO: remove override of indirect dependency [dev-dependencies] claim = { git = "https://github.com/Turbo87/rust-claim.git", rev = "23892a3" } diff --git a/src/config/src/git_config.rs b/src/config/src/git_config.rs index e1b29b3..39beb15 100644 --- a/src/config/src/git_config.rs +++ b/src/config/src/git_config.rs @@ -152,7 +152,7 @@ mod tests { #[test] fn try_from_git_config_error() { with_git_config(&["[diff]", "renames = invalid"], |git_config| { - let _ = GitConfig::try_from(&git_config).unwrap_err(); + _ = GitConfig::try_from(&git_config).unwrap_err(); }); } diff --git a/src/config/src/key_bindings.rs b/src/config/src/key_bindings.rs index ce6fd26..341082a 100644 --- a/src/config/src/key_bindings.rs +++ b/src/config/src/key_bindings.rs @@ -245,7 +245,7 @@ mod tests { #[test] fn try_from_git_config_error() { with_git_config(&["[interactive-rebase-tool]", "inputAbort = invalid"], |git_config| { - let _ = KeyBindings::try_from(&git_config).unwrap_err(); + _ = KeyBindings::try_from(&git_config).unwrap_err(); }); } diff --git a/src/config/src/lib.rs b/src/config/src/lib.rs index 128f2f7..8c02d74 100644 --- a/src/config/src/lib.rs +++ b/src/config/src/lib.rs @@ -19,7 +19,9 @@ deprecated_in_future, elided_lifetimes_in_paths, explicit_outlives_requirements, + ffi_unwind_calls, keyword_idents, + let_underscore_drop, macro_use_extern_crate, meta_variable_misuse, missing_abi, @@ -39,7 +41,6 @@ unreachable_pub, unsafe_code, unsafe_op_in_unsafe_fn, - unstable_features, unused_crate_dependencies, unused_extern_crates, unused_import_braces, @@ -47,6 +48,7 @@ unused_macro_rules, unused_qualifications, unused_results, + unused_tuple_struct_fields, variant_size_differences )] // enable all of Clippy's lints @@ -54,6 +56,7 @@ #![cfg_attr(include_nightly_lints, deny(clippy::nursery))] #![allow( clippy::arithmetic_side_effects, + clippy::arithmetic_side_effects, clippy::blanket_clippy_restriction_lints, clippy::bool_to_int_with_if, clippy::default_numeric_fallback, @@ -62,7 +65,6 @@ clippy::float_arithmetic, clippy::implicit_return, clippy::indexing_slicing, - clippy::integer_arithmetic, clippy::map_err_ignore, clippy::missing_docs_in_private_items, clippy::missing_trait_methods, @@ -72,10 +74,13 @@ clippy::non_ascii_literal, clippy::option_if_let_else, clippy::pub_use, + clippy::question_mark_used, clippy::redundant_pub_crate, + clippy::ref_patterns, clippy::std_instead_of_alloc, clippy::std_instead_of_core, clippy::tabs_in_doc_comments, + clippy::tests_outside_test_module, clippy::too_many_lines, clippy::unwrap_used )] @@ -92,9 +97,10 @@ #![cfg_attr( test, allow( + let_underscore_drop, clippy::cognitive_complexity, - clippy::let_underscore_drop, clippy::let_underscore_must_use, + clippy::let_underscore_untyped, clippy::needless_pass_by_value, clippy::panic, clippy::shadow_reuse, @@ -105,7 +111,17 @@ ) )] // allowable upcoming nightly lints -#![cfg_attr(include_nightly_lints, allow(clippy::semicolon_outside_block))] +#![cfg_attr( + include_nightly_lints, + allow( + clippy::arc_with_non_send_sync, + clippy::min_ident_chars, + clippy::needless_raw_strings, + clippy::pub_with_shorthand, + clippy::redundant_closure_call, + clippy::single_call_fn + ) +)] // LINT-REPLACE-END //! Git Interactive Rebase Tool - Configuration Module @@ -136,6 +152,8 @@ mod utils; mod testutils; use git::Repository; +// TODO: remove override of indirect dependency +use proc_macro2 as _; use self::utils::{get_bool, get_diff_ignore_whitespace, get_diff_show_whitespace, get_string, get_unsigned_integer}; pub use self::{ @@ -274,7 +292,7 @@ mod tests { with_git_config( &["[interactive-rebase-tool]", "autoSelectNext = invalid"], |git_config| { - let _ = Config::try_from(&git_config).unwrap_err(); + _ = Config::try_from(&git_config).unwrap_err(); }, ); } diff --git a/src/config/src/utils/get_string.rs b/src/config/src/utils/get_string.rs index 712d00f..454b484 100644 --- a/src/config/src/utils/get_string.rs +++ b/src/config/src/utils/get_string.rs @@ -3,7 +3,8 @@ use git::{Config, ErrorCode}; use crate::{ConfigError, ConfigErrorCause}; pub(crate) fn _get_string(config: Option<&Config>, name: &str) -> Result<Option<String>, ConfigError> { - let Some(cfg) = config else { + let Some(cfg) = config + else { return Ok(None); }; match cfg.get_string(name) { diff --git a/src/core/src/application.rs b/src/core/src/application.rs index 7c66b29..921675a 100644 --- a/src/core/src/application.rs +++ b/src/core/src/application.rs @@ -99,8 +99,12 @@ where ModuleProvider: module::ModuleProvider + Send + 'static } pub(crate) fn run_until_finished(&mut self) -> Result<(), Exit> { - let Some(mut threads) = self.threads.take() else { - return Err(Exit::new(ExitStatus::StateError, "Attempt made to run application a second time")); + let Some(mut threads) = self.threads.take() + else { + return Err(Exit::new( + ExitStatus::StateError, + "Attempt made to run application a second time", + )); }; let runtime = Runtime::new(); @@ -230,7 +234,7 @@ mod tests { #[test] #[serial_test::serial] fn load_repository_failure() { - let _ = set_git_directory("fixtures/not-a-repository"); + _ = set_git_directory("fixtures/not-a-repository"); let event_provider = create_event_reader(|| Ok(None)); let application: Result<Application<TestModuleProvider<DefaultTestModule>>, Exit> = Application::new(&args(&["todofile"]), event_provider, create_mocked_crossterm()); @@ -247,7 +251,7 @@ mod tests { #[test] #[serial_test::serial] fn load_config_failure() { - let _ = set_git_directory("fixtures/invalid-config"); + _ = set_git_directory("fixtures/invalid-config"); let event_provider = create_event_reader(|| Ok(None)); let application: Result<Application<TestModuleProvider<DefaultTestModule>>, Exit> = Application::new(&args(&["rebase-todo"]), event_provider, create_mocked_crossterm()); @@ -258,7 +262,7 @@ mod tests { #[test] #[serial_test::serial] fn load_todo_file_load_error() { - let _ = set_git_directory("fixtures/simple"); + _ = set_git_directory("fixtures/simple"); let event_provider = create_event_reader(|| Ok(None)); let application: Result<Application<TestModuleProvider<DefaultTestModule>>, Exit> = Application::new(&args(&["does-not-exist"]), event_provider, create_mocked_crossterm()); diff --git a/src/core/src/arguments.rs b/src/core/src/arguments.rs index 8cfb433..b7ec92f 100644 --- a/src/core/src/arguments.rs +++ b/src/core/src/arguments.rs @@ -105,6 +105,6 @@ mod tests { #[allow(unsafe_code)] fn todo_file_invalid() { let args = unsafe { vec![OsString::from(String::from_utf8_unchecked(vec![0xC3, 0x28]))] }; - let _ = Args::try_from(args).unwrap_err(); + _ = Args::try_from(args).unwrap_err(); } } diff --git a/src/core/src/components/choice/tests.rs b/src/core/src/components/choice/tests.rs index 20c036e..aae68f7 100644 --- a/src/core/src/components/choice/tests.rs +++ b/src/core/src/components/choice/tests.rs @@ -102,7 +102,7 @@ fn invalid_selection_character() { fn event_standard(#[case] event: Event) { with_view_state(|context| { let mut module = Choice::new(create_choices()); - let _ = module.handle_event(event, &context.state); + _ = module.handle_event(event, &context.state); assert!(!module.invalid_selection); }); } |