From d21dc125d0eeb224f426acac2e6f7102e99460f6 Mon Sep 17 00:00:00 2001 From: Krysztal112233 Date: Sat, 23 Mar 2024 16:49:35 +0800 Subject: [PATCH] lint: fix `clippy::suspicious_open_options` of project. --- .clippy.toml | 2 +- src/uu/sort/src/sort.rs | 2 +- tests/by-util/test_env.rs | 1 + tests/common/random.rs | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.clippy.toml b/.clippy.toml index 814e40b69..b1552463e 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1,2 +1,2 @@ msrv = "1.70.0" -cognitive-complexity-threshold = 10 +cognitive-complexity-threshold = 24 diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 75c0bed87..07420d9c1 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -247,11 +247,11 @@ pub struct Output { } impl Output { - #[allow(clippy::suspicious_open_options)] fn new(name: Option<&str>) -> UResult { let file = if let Some(name) = name { // This is different from `File::create()` because we don't truncate the output yet. // This allows using the output file as an input file. + #[allow(clippy::suspicious_open_options)] let file = OpenOptions::new() .write(true) .create(true) diff --git a/tests/by-util/test_env.rs b/tests/by-util/test_env.rs index 28ba97ad6..13535e416 100644 --- a/tests/by-util/test_env.rs +++ b/tests/by-util/test_env.rs @@ -445,6 +445,7 @@ macro_rules! compare_with_gnu { } #[test] +#[allow(clippy::cognitive_complexity)] // Ignore clippy lint of too long function sign fn test_env_with_gnu_reference_parsing_errors() { let ts = TestScenario::new(util_name!()); diff --git a/tests/common/random.rs b/tests/common/random.rs index 42b6eaa77..82a58578e 100644 --- a/tests/common/random.rs +++ b/tests/common/random.rs @@ -208,6 +208,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] // Ignore clippy lint of too long function sign fn test_random_string_generate_with_delimiter_should_end_with_delimiter() { let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 1, true, 1); assert_eq!(1, random_string.len()); @@ -251,6 +252,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] // Ignore clippy lint of too long function sign fn test_random_string_generate_with_delimiter_should_not_end_with_delimiter() { let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 0, false, 1); assert_eq!(1, random_string.len());