Skip to content

Commit

Permalink
Move denied Clippy lints to .cargo/config.toml
Browse files Browse the repository at this point in the history
This is also picked up by a regular `cargo clippy` call and inside the
IDE.
  • Loading branch information
Xanewok committed Oct 31, 2023
1 parent 85d3f49 commit bf1bba4
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 56 deletions.
82 changes: 81 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,84 @@ incremental = true
lto = true

[build]
rustflags = ["--warn", "unused_crate_dependencies"]
rustflags = [
"--warn",
"unused_crate_dependencies",
# This is a list of allowed Clippy rules for the purposes of gradual migration.
# See https://github.com/NomicFoundation/slang/pull/626
"-A",
"clippy::bool_assert_comparison",
"-A",
"clippy::borrow_interior_mutable_const",
"-A",
"clippy::cmp_owned",
"-A",
"clippy::collapsible_if",
"-A",
"clippy::comparison_chain",
"-A",
"clippy::declare_interior_mutable_const",
"-A",
"clippy::enum_variant_names",
"-A",
"clippy::expect_fun_call",
"-A",
"clippy::explicit_auto_deref",
"-A",
"clippy::from_over_into",
"-A",
"clippy::inherent_to_string",
"-A",
"clippy::into_iter_on_ref",
"-A",
"clippy::len_without_is_empty",
"-A",
"clippy::len_zero",
"-A",
"clippy::manual_range_contains",
"-A",
"clippy::match_like_matches_macro",
"-A",
"clippy::needless_borrow",
"-A",
"clippy::needless_range_loop",
"-A",
"clippy::needless_return",
"-A",
"clippy::new_without_default",
"-A",
"clippy::println_empty_string",
"-A",
"clippy::ptr_arg",
"-A",
"clippy::redundant_closure",
"-A",
"clippy::redundant_pattern",
"-A",
"clippy::redundant_pattern_matching",
"-A",
"clippy::redundant_static_lifetimes",
"-A",
"clippy::should_implement_trait",
"-A",
"clippy::single_char_add_str",
"-A",
"clippy::single_char_pattern",
"-A",
"clippy::to_string_in_format_args",
"-A",
"clippy::upper_case_acronyms",
"-A",
"clippy::useless_asref",
"-A",
"clippy::useless_conversion",
"-A",
"clippy::useless_format",
"-A",
"clippy::write_literal",
"-A",
"clippy::writeln_empty_string",
"-A",
"clippy::wrong_self_convention",

]
39 changes: 0 additions & 39 deletions .clippy_allowed_lints

This file was deleted.

19 changes: 3 additions & 16 deletions crates/infra/cli/src/commands/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use infra_utils::{
github::GitHub,
paths::{FileWalker, PathExtensions},
};
use itertools::Itertools;

use crate::utils::{ClapExtensions, OrderedCommand, Terminal};

Expand Down Expand Up @@ -66,23 +65,11 @@ impl OrderedCommand for LintCommand {
}

fn run_clippy() -> Result<()> {
let makeshift_config = std::fs::read_to_string(Path::repo_path(".clippy_allowed_lints"))?;
let allowed_lints = makeshift_config
.lines()
.map(str::trim)
.filter(|line| !line.starts_with('#') && !line.is_empty())
.unique();

let mut clippy = Command::new("cargo")
Command::new("cargo")
.flag("clippy")
.flag("--")
.flag("--verbose");

for lint in allowed_lints {
clippy = clippy.property("-A", format!("clippy::{}", lint));
}

clippy.run()
.flag("--verbose")
.run()
}

fn run_cargo_fmt() -> Result<()> {
Expand Down

0 comments on commit bf1bba4

Please sign in to comment.