1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 11:07:44 +00:00

Merge pull request #6102 from Krysztal112233/main

lint: fix lints of new Rust version
This commit is contained in:
Sylvestre Ledru 2024-03-23 12:21:03 +01:00 committed by GitHub
commit 88ff42e840
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 29 additions and 20 deletions

View file

@ -1,2 +1,2 @@
msrv = "1.70.0"
cognitive-complexity-threshold = 10
cognitive-complexity-threshold = 24

View file

@ -13,6 +13,7 @@ use crate::parseargs::Parser;
use crate::StatusLevel;
#[cfg(not(any(target_os = "linux", target_os = "android")))]
#[allow(clippy::useless_vec)]
#[test]
fn unimplemented_flags_should_error_non_linux() {
let mut succeeded = Vec::new();
@ -55,6 +56,7 @@ fn unimplemented_flags_should_error_non_linux() {
}
#[test]
#[allow(clippy::useless_vec)]
fn unimplemented_flags_should_error() {
let mut succeeded = Vec::new();

View file

@ -251,6 +251,7 @@ impl Output {
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)

View file

@ -660,10 +660,11 @@ mod tests {
assert_eq!(path.to_str(), Some(""));
// The main point to test here is that we don't crash.
// The result should be 'false', to avoid unnecessary and confusing warnings.
assert_eq!(false, is_root(&path, false));
assert_eq!(false, is_root(&path, true));
assert!(!is_root(&path, false));
assert!(!is_root(&path, true));
}
#[allow(clippy::needless_borrow)]
#[cfg(unix)]
#[test]
fn test_literal_root() {
@ -675,8 +676,8 @@ mod tests {
"cfg(unix) but using non-unix path delimiters?!"
);
// Must return true, this is the main scenario that --preserve-root shall prevent.
assert_eq!(true, is_root(&path, false));
assert_eq!(true, is_root(&path, true));
assert!(is_root(&path, false));
assert!(is_root(&path, true));
}
#[cfg(unix)]
@ -684,7 +685,7 @@ mod tests {
fn test_symlink_slash() {
let temp_dir = tempdir().unwrap();
let symlink_path = temp_dir.path().join("symlink");
unix::fs::symlink(&PathBuf::from("/"), &symlink_path).unwrap();
unix::fs::symlink(PathBuf::from("/"), symlink_path).unwrap();
let symlink_path_slash = temp_dir.path().join("symlink/");
// Must return true, we're about to "accidentally" recurse on "/",
// since "symlink/" always counts as an already-entered directory
@ -697,8 +698,8 @@ mod tests {
// chown: it is dangerous to operate recursively on 'slink-to-root/' (same as '/')
// chown: use --no-preserve-root to override this failsafe
// [$? = 1]
assert_eq!(true, is_root(&symlink_path_slash, false));
assert_eq!(true, is_root(&symlink_path_slash, true));
assert!(is_root(&symlink_path_slash, false));
assert!(is_root(&symlink_path_slash, true));
}
#[cfg(unix)]
@ -707,9 +708,9 @@ mod tests {
// This covers both the commandline-argument case and the recursion case.
let temp_dir = tempdir().unwrap();
let symlink_path = temp_dir.path().join("symlink");
unix::fs::symlink(&PathBuf::from("/"), &symlink_path).unwrap();
unix::fs::symlink(PathBuf::from("/"), &symlink_path).unwrap();
// Only return true we're about to "accidentally" recurse on "/".
assert_eq!(false, is_root(&symlink_path, false));
assert_eq!(true, is_root(&symlink_path, true));
assert!(!is_root(&symlink_path, false));
assert!(is_root(&symlink_path, true));
}
}

View file

@ -97,7 +97,7 @@ mod tests {
// test that we don't look for closing square brackets unnecessarily
// Verifies issue #5584
let chars = std::iter::repeat("^[").take(174571).collect::<String>();
let chars = "^[".repeat(174571);
assert_eq!(fix_negation(chars.as_str()), chars);
}

View file

@ -397,7 +397,7 @@ fn test_base64_multiple_files() {
.arg("alice_in_wonderland.txt")
.succeeds()
.no_stderr()
.stdout_is_fixture_bytes(format!("base64/md5_multiple_files.expected"));
.stdout_is_fixture_bytes("base64/md5_multiple_files.expected");
}
#[test]

View file

@ -3306,7 +3306,7 @@ fn test_symbolic_link_file() {
#[test]
fn test_src_base_dot() {
let ts = TestScenario::new(util_name!());
let at = ts.fixtures.clone();
let at = &ts.fixtures;
at.mkdir("x");
at.mkdir("y");
ts.ucmd()

View file

@ -1641,7 +1641,7 @@ fn test_seek_past_dev() {
fn test_reading_partial_blocks_from_fifo() {
// Create the FIFO.
let ts = TestScenario::new(util_name!());
let at = ts.fixtures.clone();
let at = &ts.fixtures;
at.mkfifo("fifo");
let fifoname = at.plus_as_string("fifo");
@ -1682,7 +1682,7 @@ fn test_reading_partial_blocks_from_fifo() {
fn test_reading_partial_blocks_from_fifo_unbuffered() {
// Create the FIFO.
let ts = TestScenario::new(util_name!());
let at = ts.fixtures.clone();
let at = ts.fixtures;
at.mkfifo("fifo");
let fifoname = at.plus_as_string("fifo");

View file

@ -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!());

View file

@ -5,7 +5,9 @@
// spell-checker:ignore (formats) cymdhm cymdhms mdhm mdhms ymdhm ymdhms datetime mktime
use crate::common::util::{AtPath, TestScenario};
use filetime::{set_symlink_file_times, FileTime};
#[cfg(not(target_os = "freebsd"))]
use filetime::set_symlink_file_times;
use filetime::FileTime;
use std::fs::remove_file;
use std::path::PathBuf;

View file

@ -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());

View file

@ -33,7 +33,7 @@ use std::os::unix::process::ExitStatusExt;
#[cfg(windows)]
use std::os::windows::fs::{symlink_dir, symlink_file};
#[cfg(windows)]
use std::path::MAIN_SEPARATOR;
use std::path::MAIN_SEPARATOR_STR;
use std::path::{Path, PathBuf};
use std::process::{Child, Command, ExitStatus, Output, Stdio};
use std::rc::Rc;
@ -1016,7 +1016,7 @@ impl AtPath {
pub fn relative_symlink_file(&self, original: &str, link: &str) {
#[cfg(windows)]
let original = original.replace('/', &MAIN_SEPARATOR.to_string());
let original = original.replace('/', MAIN_SEPARATOR_STR);
log_info(
"symlink",
format!("{},{}", &original, &self.plus_as_string(link)),
@ -1038,7 +1038,7 @@ impl AtPath {
pub fn relative_symlink_dir(&self, original: &str, link: &str) {
#[cfg(windows)]
let original = original.replace('/', &MAIN_SEPARATOR.to_string());
let original = original.replace('/', MAIN_SEPARATOR_STR);
log_info(
"symlink",
format!("{},{}", &original, &self.plus_as_string(link)),