From 5094d6ffcc03df51e31e289c404973879be25232 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Wed, 25 Dec 2019 22:49:04 -0600 Subject: [PATCH] refactor/polish ~ fix `cargo clippy` complaints (allow complexity) --- src/cut/cut.rs | 2 ++ src/du/du.rs | 1 + src/fmt/fmt.rs | 1 + src/hashsum/hashsum.rs | 3 +++ src/ls/ls.rs | 1 + src/mknod/mknod.rs | 1 + src/stat/stat.rs | 1 + src/tail/tail.rs | 1 + 8 files changed, 11 insertions(+) diff --git a/src/cut/cut.rs b/src/cut/cut.rs index 5d66c6e89..58bdf59fe 100644 --- a/src/cut/cut.rs +++ b/src/cut/cut.rs @@ -203,6 +203,7 @@ fn cut_bytes(reader: R, ranges: &[Range], opts: &Options) -> i32 { 0 } +#[allow(clippy::cognitive_complexity)] fn cut_fields_delimiter( reader: R, ranges: &[Range], @@ -288,6 +289,7 @@ fn cut_fields_delimiter( 0 } +#[allow(clippy::cognitive_complexity)] fn cut_fields(reader: R, ranges: &[Range], opts: &FieldOptions) -> i32 { let newline_char = if opts.zero_terminated { b'\0' } else { b'\n' }; if let Some(ref o_delim) = opts.out_delimeter { diff --git a/src/du/du.rs b/src/du/du.rs index 745809fd5..28e1a8c03 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -227,6 +227,7 @@ fn convert_size_other(size: u64, _multiplier: u64, block_size: u64) -> String { format!("{}", ((size as f64) / (block_size as f64)).ceil()) } +#[allow(clippy::cognitive_complexity)] pub fn uumain(args: Vec) -> i32 { let syntax = format!( "[OPTION]... [FILE]... diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index a81ad2cf5..39167b9d3 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -57,6 +57,7 @@ pub struct FmtOptions { tabwidth: usize, } +#[allow(clippy::cognitive_complexity)] pub fn uumain(args: Vec) -> i32 { let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) .optflag("c", "crown-margin", "First and second line of paragraph may have different indentations, in which case the first line's indentation is preserved, and each subsequent line's indentation matches the second line.") diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index 28a66ffcc..ea8063403 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -48,6 +48,7 @@ fn is_custom_binary(program: &str) -> bool { } } +#[allow(clippy::cognitive_complexity)] fn detect_algo( program: &str, matches: &getopts::Matches, @@ -367,6 +368,8 @@ Compute and check message digests.", print!("{}", opts.usage(&msg)); } +#[allow(clippy::cognitive_complexity)] +#[allow(clippy::too_many_arguments)] fn hashsum( algoname: &str, mut digest: Box, diff --git a/src/ls/ls.rs b/src/ls/ls.rs index 3910937f2..5b8d21678 100644 --- a/src/ls/ls.rs +++ b/src/ls/ls.rs @@ -599,6 +599,7 @@ macro_rules! has { } #[cfg(unix)] +#[allow(clippy::cognitive_complexity)] fn display_file_name( path: &Path, strip: Option<&Path>, diff --git a/src/mknod/mknod.rs b/src/mknod/mknod.rs index c113ecf4a..8429d741a 100644 --- a/src/mknod/mknod.rs +++ b/src/mknod/mknod.rs @@ -45,6 +45,7 @@ fn _makenod(path: CString, mode: mode_t, dev: dev_t) -> i32 { unsafe { libc::mknod(path.as_ptr(), mode, dev) } } +#[allow(clippy::cognitive_complexity)] pub fn uumain(args: Vec) -> i32 { let mut opts = Options::new(); diff --git a/src/stat/stat.rs b/src/stat/stat.rs index 8d87695be..cf8ea1517 100644 --- a/src/stat/stat.rs +++ b/src/stat/stat.rs @@ -209,6 +209,7 @@ pub struct Stater { default_dev_tokens: Vec, } +#[allow(clippy::cognitive_complexity)] fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32) { // If the precision is given as just '.', the precision is taken to be zero. // A negative precision is taken as if the precision were omitted. diff --git a/src/tail/tail.rs b/src/tail/tail.rs index ea2eea971..8aa7abb3e 100755 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -57,6 +57,7 @@ impl Default for Settings { } } +#[allow(clippy::cognitive_complexity)] pub fn uumain(args: Vec) -> i32 { let mut settings: Settings = Default::default();