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:
commit
88ff42e840
12 changed files with 29 additions and 20 deletions
|
@ -1,2 +1,2 @@
|
||||||
msrv = "1.70.0"
|
msrv = "1.70.0"
|
||||||
cognitive-complexity-threshold = 10
|
cognitive-complexity-threshold = 24
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::parseargs::Parser;
|
||||||
use crate::StatusLevel;
|
use crate::StatusLevel;
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||||
|
#[allow(clippy::useless_vec)]
|
||||||
#[test]
|
#[test]
|
||||||
fn unimplemented_flags_should_error_non_linux() {
|
fn unimplemented_flags_should_error_non_linux() {
|
||||||
let mut succeeded = Vec::new();
|
let mut succeeded = Vec::new();
|
||||||
|
@ -55,6 +56,7 @@ fn unimplemented_flags_should_error_non_linux() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::useless_vec)]
|
||||||
fn unimplemented_flags_should_error() {
|
fn unimplemented_flags_should_error() {
|
||||||
let mut succeeded = Vec::new();
|
let mut succeeded = Vec::new();
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,7 @@ impl Output {
|
||||||
let file = if let Some(name) = name {
|
let file = if let Some(name) = name {
|
||||||
// This is different from `File::create()` because we don't truncate the output yet.
|
// This is different from `File::create()` because we don't truncate the output yet.
|
||||||
// This allows using the output file as an input file.
|
// This allows using the output file as an input file.
|
||||||
|
#[allow(clippy::suspicious_open_options)]
|
||||||
let file = OpenOptions::new()
|
let file = OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.create(true)
|
.create(true)
|
||||||
|
|
|
@ -660,10 +660,11 @@ mod tests {
|
||||||
assert_eq!(path.to_str(), Some(""));
|
assert_eq!(path.to_str(), Some(""));
|
||||||
// The main point to test here is that we don't crash.
|
// The main point to test here is that we don't crash.
|
||||||
// The result should be 'false', to avoid unnecessary and confusing warnings.
|
// The result should be 'false', to avoid unnecessary and confusing warnings.
|
||||||
assert_eq!(false, is_root(&path, false));
|
assert!(!is_root(&path, false));
|
||||||
assert_eq!(false, is_root(&path, true));
|
assert!(!is_root(&path, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::needless_borrow)]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_literal_root() {
|
fn test_literal_root() {
|
||||||
|
@ -675,8 +676,8 @@ mod tests {
|
||||||
"cfg(unix) but using non-unix path delimiters?!"
|
"cfg(unix) but using non-unix path delimiters?!"
|
||||||
);
|
);
|
||||||
// Must return true, this is the main scenario that --preserve-root shall prevent.
|
// Must return true, this is the main scenario that --preserve-root shall prevent.
|
||||||
assert_eq!(true, is_root(&path, false));
|
assert!(is_root(&path, false));
|
||||||
assert_eq!(true, is_root(&path, true));
|
assert!(is_root(&path, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
@ -684,7 +685,7 @@ mod tests {
|
||||||
fn test_symlink_slash() {
|
fn test_symlink_slash() {
|
||||||
let temp_dir = tempdir().unwrap();
|
let temp_dir = tempdir().unwrap();
|
||||||
let symlink_path = temp_dir.path().join("symlink");
|
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/");
|
let symlink_path_slash = temp_dir.path().join("symlink/");
|
||||||
// Must return true, we're about to "accidentally" recurse on "/",
|
// Must return true, we're about to "accidentally" recurse on "/",
|
||||||
// since "symlink/" always counts as an already-entered directory
|
// 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: it is dangerous to operate recursively on 'slink-to-root/' (same as '/')
|
||||||
// chown: use --no-preserve-root to override this failsafe
|
// chown: use --no-preserve-root to override this failsafe
|
||||||
// [$? = 1]
|
// [$? = 1]
|
||||||
assert_eq!(true, is_root(&symlink_path_slash, false));
|
assert!(is_root(&symlink_path_slash, false));
|
||||||
assert_eq!(true, is_root(&symlink_path_slash, true));
|
assert!(is_root(&symlink_path_slash, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
@ -707,9 +708,9 @@ mod tests {
|
||||||
// This covers both the commandline-argument case and the recursion case.
|
// This covers both the commandline-argument case and the recursion case.
|
||||||
let temp_dir = tempdir().unwrap();
|
let temp_dir = tempdir().unwrap();
|
||||||
let symlink_path = temp_dir.path().join("symlink");
|
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 "/".
|
// Only return true we're about to "accidentally" recurse on "/".
|
||||||
assert_eq!(false, is_root(&symlink_path, false));
|
assert!(!is_root(&symlink_path, false));
|
||||||
assert_eq!(true, is_root(&symlink_path, true));
|
assert!(is_root(&symlink_path, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ mod tests {
|
||||||
|
|
||||||
// test that we don't look for closing square brackets unnecessarily
|
// test that we don't look for closing square brackets unnecessarily
|
||||||
// Verifies issue #5584
|
// Verifies issue #5584
|
||||||
let chars = std::iter::repeat("^[").take(174571).collect::<String>();
|
let chars = "^[".repeat(174571);
|
||||||
assert_eq!(fix_negation(chars.as_str()), chars);
|
assert_eq!(fix_negation(chars.as_str()), chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,7 +397,7 @@ fn test_base64_multiple_files() {
|
||||||
.arg("alice_in_wonderland.txt")
|
.arg("alice_in_wonderland.txt")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.no_stderr()
|
.no_stderr()
|
||||||
.stdout_is_fixture_bytes(format!("base64/md5_multiple_files.expected"));
|
.stdout_is_fixture_bytes("base64/md5_multiple_files.expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -3306,7 +3306,7 @@ fn test_symbolic_link_file() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_src_base_dot() {
|
fn test_src_base_dot() {
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
let at = ts.fixtures.clone();
|
let at = &ts.fixtures;
|
||||||
at.mkdir("x");
|
at.mkdir("x");
|
||||||
at.mkdir("y");
|
at.mkdir("y");
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
|
|
|
@ -1641,7 +1641,7 @@ fn test_seek_past_dev() {
|
||||||
fn test_reading_partial_blocks_from_fifo() {
|
fn test_reading_partial_blocks_from_fifo() {
|
||||||
// Create the FIFO.
|
// Create the FIFO.
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
let at = ts.fixtures.clone();
|
let at = &ts.fixtures;
|
||||||
at.mkfifo("fifo");
|
at.mkfifo("fifo");
|
||||||
let fifoname = at.plus_as_string("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() {
|
fn test_reading_partial_blocks_from_fifo_unbuffered() {
|
||||||
// Create the FIFO.
|
// Create the FIFO.
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
let at = ts.fixtures.clone();
|
let at = ts.fixtures;
|
||||||
at.mkfifo("fifo");
|
at.mkfifo("fifo");
|
||||||
let fifoname = at.plus_as_string("fifo");
|
let fifoname = at.plus_as_string("fifo");
|
||||||
|
|
||||||
|
|
|
@ -445,6 +445,7 @@ macro_rules! compare_with_gnu {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::cognitive_complexity)] // Ignore clippy lint of too long function sign
|
||||||
fn test_env_with_gnu_reference_parsing_errors() {
|
fn test_env_with_gnu_reference_parsing_errors() {
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
// spell-checker:ignore (formats) cymdhm cymdhms mdhm mdhms ymdhm ymdhms datetime mktime
|
// spell-checker:ignore (formats) cymdhm cymdhms mdhm mdhms ymdhm ymdhms datetime mktime
|
||||||
|
|
||||||
use crate::common::util::{AtPath, TestScenario};
|
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::fs::remove_file;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::cognitive_complexity)] // Ignore clippy lint of too long function sign
|
||||||
fn test_random_string_generate_with_delimiter_should_end_with_delimiter() {
|
fn test_random_string_generate_with_delimiter_should_end_with_delimiter() {
|
||||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 1, true, 1);
|
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 1, true, 1);
|
||||||
assert_eq!(1, random_string.len());
|
assert_eq!(1, random_string.len());
|
||||||
|
@ -251,6 +252,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[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() {
|
fn test_random_string_generate_with_delimiter_should_not_end_with_delimiter() {
|
||||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 0, false, 1);
|
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 0, false, 1);
|
||||||
assert_eq!(1, random_string.len());
|
assert_eq!(1, random_string.len());
|
||||||
|
|
|
@ -33,7 +33,7 @@ use std::os::unix::process::ExitStatusExt;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::os::windows::fs::{symlink_dir, symlink_file};
|
use std::os::windows::fs::{symlink_dir, symlink_file};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::path::MAIN_SEPARATOR;
|
use std::path::MAIN_SEPARATOR_STR;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{Child, Command, ExitStatus, Output, Stdio};
|
use std::process::{Child, Command, ExitStatus, Output, Stdio};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -1016,7 +1016,7 @@ impl AtPath {
|
||||||
|
|
||||||
pub fn relative_symlink_file(&self, original: &str, link: &str) {
|
pub fn relative_symlink_file(&self, original: &str, link: &str) {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let original = original.replace('/', &MAIN_SEPARATOR.to_string());
|
let original = original.replace('/', MAIN_SEPARATOR_STR);
|
||||||
log_info(
|
log_info(
|
||||||
"symlink",
|
"symlink",
|
||||||
format!("{},{}", &original, &self.plus_as_string(link)),
|
format!("{},{}", &original, &self.plus_as_string(link)),
|
||||||
|
@ -1038,7 +1038,7 @@ impl AtPath {
|
||||||
|
|
||||||
pub fn relative_symlink_dir(&self, original: &str, link: &str) {
|
pub fn relative_symlink_dir(&self, original: &str, link: &str) {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let original = original.replace('/', &MAIN_SEPARATOR.to_string());
|
let original = original.replace('/', MAIN_SEPARATOR_STR);
|
||||||
log_info(
|
log_info(
|
||||||
"symlink",
|
"symlink",
|
||||||
format!("{},{}", &original, &self.plus_as_string(link)),
|
format!("{},{}", &original, &self.plus_as_string(link)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue