From a2f99b7e0992a55c2b6ddd8b9854fb2015907da3 Mon Sep 17 00:00:00 2001 From: Tim Oram Date: Sun, 18 Feb 2024 20:07:55 -0330 Subject: Move lint configuration to Cargo.toml --- .github/workflows/pull-request.yml | 2 +- Cargo.toml | 101 +++++++++++++++++++++++++++++++++++++ build.rs | 2 +- src/main.rs | 100 +----------------------------------- 4 files changed, 104 insertions(+), 101 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index cff77ef..b8b11ac 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -35,7 +35,7 @@ jobs: - uses: baptiste0928/cargo-install@v2 with: crate: cargo-make - - run: cargo make lint-stable + - run: cargo make lint-stable -- --deny warnings docs: runs-on: ubuntu-latest timeout-minutes: 10 diff --git a/Cargo.toml b/Cargo.toml index 2af736b..30e7f12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,3 +82,104 @@ assets = [ ["CHANGELOG.md", "usr/share/doc/interactive-rebase-tool/", "644"], ["src/interactive-rebase-tool.1", "usr/share/man/man1/interactive-rebase-tool.1", "644"] ] + +[lints.rust] +future_incompatible = {level = "warn", priority = -2} +nonstandard_style = {level = "warn", priority = -2} +rust_2018_compatibility = {level = "warn", priority = -2} +rust_2018_idioms = {level = "warn", priority = -2} +rust_2021_compatibility = {level = "warn", priority = -2} +unused = {level = "warn", priority = -2} + +unknown_lints = {level = "warn", priority = -1} +renamed_and_removed_lints = {level = "warn", priority = -1} + +absolute_paths_not_starting_with_crate = "warn" +deprecated_in_future = "warn" +dead_code = "warn" +elided_lifetimes_in_paths = "warn" +explicit_outlives_requirements = "warn" +ffi_unwind_calls = "warn" +keyword_idents = "warn" +let_underscore_drop = "warn" +macro_use_extern_crate = "warn" +meta_variable_misuse = "warn" +missing_abi = "warn" +missing_copy_implementations = "warn" +missing_debug_implementations = "warn" +non_ascii_idents = "warn" +noop_method_call = "warn" +pointer_structural_match = "warn" +rust_2021_incompatible_closure_captures = "warn" +rust_2021_incompatible_or_patterns = "warn" +rust_2021_prefixes_incompatible_syntax = "warn" +rust_2021_prelude_collisions = "warn" +single_use_lifetimes = "warn" +trivial_casts = "warn" +trivial_numeric_casts = "warn" +unreachable_pub = "warn" +unsafe_code = "warn" +unsafe_op_in_unsafe_fn = "warn" +unused_crate_dependencies = "warn" +unused_extern_crates = "warn" +unused_import_braces = "warn" +unused_lifetimes = "warn" +unused_macro_rules = "warn" +unused_qualifications = "warn" +unused_results = "warn" +unused_tuple_struct_fields = "warn" +variant_size_differences = "warn" + +[lints.clippy] +all = {level = "warn", priority = -2} +cargo = {level = "warn", priority = -2} +pedantic = {level = "warn", priority = -2} +restriction = {level = "warn", priority = -2} + +blanket_clippy_restriction_lints = {level = "allow", priority = 5} +absolute_paths = "allow" +as_conversions = "allow" +arithmetic_side_effects = "allow" +bool_to_int_with_if = "allow" +default_numeric_fallback = "allow" +else_if_without_else = "allow" +expect_used = "allow" +float_arithmetic = "allow" +implicit_return = "allow" +indexing_slicing = "allow" +map_err_ignore = "allow" +min_ident_chars = "allow" +missing_docs_in_private_items = "allow" +missing_trait_methods = "allow" +module_name_repetitions = "allow" +needless_raw_string_hashes = "allow" +needless_raw_strings = "allow" +new_without_default = "allow" +non_ascii_literal = "allow" +option_if_let_else = "allow" +pattern_type_mismatch = "allow" +pub_use = "allow" +pub_with_shorthand = "allow" +question_mark_used = "allow" +redundant_closure_call = "allow" +redundant_closure_for_method_calls = "allow" +redundant_pub_crate = "allow" +ref_patterns = "allow" +self_named_module_files = "allow" +single_call_fn = "allow" +std_instead_of_alloc = "allow" +std_instead_of_core = "allow" +tabs_in_doc_comments = "allow" +tests_outside_test_module = "allow" +too_many_lines = "allow" +unwrap_used = "allow" +wildcard_enum_match_arm = "allow" + +[lints.rustdoc] +bare_urls = "warn" +broken_intra_doc_links = "warn" +invalid_codeblock_attributes = "warn" +invalid_html_tags = "warn" +missing_crate_level_docs = "allow" +private_doc_tests = "warn" +private_intra_doc_links = "warn" diff --git a/build.rs b/build.rs index f528155..3e5c581 100644 --- a/build.rs +++ b/build.rs @@ -30,7 +30,7 @@ fn git_revision_hash() -> Option { .args(["rev-parse", "--short=10", "HEAD"]) .output(); result.ok().and_then(|output| { - let v = String::from_utf8_lossy(&output.stdout).trim().to_string(); + let v = String::from(String::from_utf8_lossy(&output.stdout).trim()); if v.is_empty() { None } else { Some(v) } }) } diff --git a/src/main.rs b/src/main.rs index 9d536c1..03a6b57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,103 +1,5 @@ // nightly sometimes removes/renames lints -#![cfg_attr(allow_unknown_lints, allow(unknown_lints))] -#![cfg_attr(allow_unknown_lints, allow(renamed_and_removed_lints))] -// enable all rustc's built-in lints -#![warn( - future_incompatible, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused -)] -// rustc's additional allowed by default lints -#![deny( - absolute_paths_not_starting_with_crate, - 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, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - pointer_structural_match, - rust_2021_incompatible_closure_captures, - rust_2021_incompatible_or_patterns, - rust_2021_prefixes_incompatible_syntax, - rust_2021_prelude_collisions, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_code, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_extern_crates, - unused_import_braces, - unused_lifetimes, - unused_macro_rules, - unused_qualifications, - unused_results, - unused_tuple_struct_fields, - variant_size_differences -)] -// enable all of Clippy's lints -#![deny(clippy::all, clippy::cargo, clippy::pedantic, clippy::restriction)] -#![allow( - clippy::absolute_paths, - clippy::arithmetic_side_effects, - clippy::arithmetic_side_effects, - clippy::as_conversions, - clippy::blanket_clippy_restriction_lints, - clippy::bool_to_int_with_if, - clippy::default_numeric_fallback, - clippy::else_if_without_else, - clippy::expect_used, - clippy::float_arithmetic, - clippy::implicit_return, - clippy::indexing_slicing, - clippy::map_err_ignore, - clippy::min_ident_chars, - clippy::missing_docs_in_private_items, - clippy::missing_trait_methods, - clippy::module_name_repetitions, - clippy::needless_raw_string_hashes, - clippy::needless_raw_strings, - clippy::new_without_default, - clippy::non_ascii_literal, - clippy::option_if_let_else, - clippy::pattern_type_mismatch, - clippy::pub_use, - clippy::pub_with_shorthand, - clippy::question_mark_used, - clippy::redundant_closure_call, - clippy::redundant_closure_for_method_calls, - clippy::redundant_pub_crate, - clippy::ref_patterns, - clippy::self_named_module_files, - clippy::single_call_fn, - 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, - clippy::wildcard_enum_match_arm -)] -#![deny( - rustdoc::bare_urls, - rustdoc::broken_intra_doc_links, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_html_tags, - rustdoc::private_doc_tests, - rustdoc::private_intra_doc_links -)] +#![cfg_attr(allow_unknown_lints, allow(unknown_lints, renamed_and_removed_lints))] // allow some things in tests #![cfg_attr( test, -- cgit v1.2.3