From 413c64fa128dc1e2324d5e3b599610c7dbee0b2b Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 28 Dec 2019 12:45:11 -0600 Subject: [PATCH] refactor/polish ~ fix `cargo clippy` complaints ('better' as `println!()`) --- src/expr/expr.rs | 5 ++--- src/kill/kill.rs | 4 ++-- src/ln/ln.rs | 2 +- src/mkdir/mkdir.rs | 2 +- src/more/more.rs | 2 +- src/mv/mv.rs | 2 +- src/nl/nl.rs | 2 +- src/numfmt/numfmt.rs | 4 ++-- src/pinky/pinky.rs | 6 +++--- src/readlink/readlink.rs | 2 +- src/realpath/realpath.rs | 4 ++-- src/relpath/relpath.rs | 4 ++-- src/rm/rm.rs | 10 +++++----- src/shred/shred.rs | 16 ++++++++-------- src/stdbuf/stdbuf.rs | 4 ++-- src/sync/sync.rs | 2 +- src/touch/touch.rs | 4 ++-- src/tr/tr.rs | 4 ++-- src/truncate/truncate.rs | 4 ++-- src/tsort/tsort.rs | 4 ++-- src/tty/tty.rs | 4 ++-- src/uniq/uniq.rs | 6 +++--- src/unlink/unlink.rs | 4 ++-- src/uptime/uptime.rs | 4 ++-- src/users/users.rs | 4 ++-- src/uutils/uutils.rs | 2 +- src/wc/wc.rs | 6 +++--- 27 files changed, 58 insertions(+), 59 deletions(-) diff --git a/src/expr/expr.rs b/src/expr/expr.rs index f0e124d42..1298137fb 100644 --- a/src/expr/expr.rs +++ b/src/expr/expr.rs @@ -80,7 +80,7 @@ fn maybe_handle_help_or_version(args: &[String]) -> bool { fn print_help() { //! The following is taken from GNU coreutils' "expr --help" output. - print!( + println!( r#"Usage: expr EXPRESSION or: expr OPTION @@ -131,8 +131,7 @@ Environment variables: * EXPR_DEBUG_TOKENS=1 dump expression's tokens * EXPR_DEBUG_RPN=1 dump expression represented in reverse polish notation * EXPR_DEBUG_SYA_STEP=1 dump each parser step - * EXPR_DEBUG_AST=1 dump expression represented abstract syntax tree -"# + * EXPR_DEBUG_AST=1 dump expression represented abstract syntax tree"# ); } diff --git a/src/kill/kill.rs b/src/kill/kill.rs index 739efb8df..5250836c6 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -107,7 +107,7 @@ fn table() { //TODO: obtain max signal width here if (idx + 1) % 7 == 0 { - println!(""); + println!(); } } } @@ -133,7 +133,7 @@ fn print_signals() { pos += signal.name.len(); print!("{}", signal.name); if idx > 0 && pos > 73 { - println!(""); + println!(); pos = 0; } else { pos += 1; diff --git a/src/ln/ln.rs b/src/ln/ln.rs index 263c4de10..c43be8aa3 100644 --- a/src/ln/ln.rs +++ b/src/ln/ln.rs @@ -295,7 +295,7 @@ fn link(src: &PathBuf, dst: &PathBuf, settings: &Settings) -> Result<()> { print!("'{}' -> '{}'", dst.display(), src.display()); match backup_path { Some(path) => println!(" (backup: '{}')", path.display()), - None => println!(""), + None => println!(), } } Ok(()) diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index c3bc0107e..ff431f2e4 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -76,7 +76,7 @@ pub fn uumain(args: Vec) -> i32 { fn print_help(opts: &getopts::Options) { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); print!( "{}", diff --git a/src/more/more.rs b/src/more/more.rs index eaf272bb8..334be558b 100644 --- a/src/more/more.rs +++ b/src/more/more.rs @@ -164,5 +164,5 @@ fn more(matches: getopts::Matches) { } reset_term(&mut term); - println!(""); + println!(); } diff --git a/src/mv/mv.rs b/src/mv/mv.rs index b6e6b6870..62a506f56 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -387,7 +387,7 @@ fn rename(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<()> { print!("‘{}’ -> ‘{}’", from.display(), to.display()); match backup_path { Some(path) => println!(" (backup: ‘{}’)", path.display()), - None => println!(""), + None => println!(), } } Ok(()) diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 6359b4b93..8fc732852 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -272,7 +272,7 @@ fn nl(reader: &mut BufReader, settings: &Settings) { if matched_groups > 0 { // The current line is a section delimiter, so we output // a blank line. - println!(""); + println!(); // However the line does not count as a blank line, so we // reset the counter used for --join-blank-lines. empty_line_count = 0; diff --git a/src/numfmt/numfmt.rs b/src/numfmt/numfmt.rs index 604f35b2b..e454f7882 100644 --- a/src/numfmt/numfmt.rs +++ b/src/numfmt/numfmt.rs @@ -315,10 +315,10 @@ pub fn uumain(args: Vec) -> i32 { let matches = opts.parse(&args[1..]).unwrap(); if matches.opt_present("help") { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {0} [STRING]... [OPTION]...", NAME); - println!(""); + println!(); print!( "{}", opts.usage("Convert numbers from/to human-readable strings") diff --git a/src/pinky/pinky.rs b/src/pinky/pinky.rs index 0edf3e0f2..73c97fbbb 100644 --- a/src/pinky/pinky.rs +++ b/src/pinky/pinky.rs @@ -263,7 +263,7 @@ impl Pinky { } } - println!(""); + println!(); } fn print_heading(&self) { @@ -279,7 +279,7 @@ impl Pinky { if self.include_where { print!(" Where"); } - println!(""); + println!(); } fn short_pinky(&self) -> IOResult<()> { @@ -325,7 +325,7 @@ impl Pinky { read_to_console(f); } } - println!(""); + println!(); } else { println!(" ???"); } diff --git a/src/readlink/readlink.rs b/src/readlink/readlink.rs index b4971e27f..460ea9643 100644 --- a/src/readlink/readlink.rs +++ b/src/readlink/readlink.rs @@ -139,7 +139,7 @@ fn show(path: &PathBuf, no_newline: bool, use_zero: bool) { fn show_usage(opts: &getopts::Options) { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage: {0} [OPTION]... [FILE]...", NAME); print!("Print value of a symbolic link or canonical file name"); print!("{}", opts.usage("")); diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index 80e6052da..523804022 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -136,12 +136,12 @@ fn version() { fn show_usage(opts: &getopts::Options) { version(); - println!(""); + println!(); println!("Usage:"); println!(" {} [-s|--strip] [-z|--zero] FILENAME...", NAME); println!(" {} -V|--version", NAME); println!(" {} -h|--help", NAME); - println!(""); + println!(); print!("{}", opts.usage( "Convert each FILENAME to the absolute path.\n\ All the symbolic links will be resolved, resulting path will contain no special components like '.' or '..'.\n\ diff --git a/src/relpath/relpath.rs b/src/relpath/relpath.rs index 8e0bb4012..b2ed8c251 100644 --- a/src/relpath/relpath.rs +++ b/src/relpath/relpath.rs @@ -108,12 +108,12 @@ fn version() { fn show_usage(opts: &getopts::Options) { version(); - println!(""); + println!(); println!("Usage:"); println!(" {} [-d DIR] TO [FROM]", NAME); println!(" {} -V|--version", NAME); println!(" {} -h|--help", NAME); - println!(""); + println!(); print!( "{}", opts.usage( diff --git a/src/rm/rm.rs b/src/rm/rm.rs index 8c2fc08ba..1d10e446b 100644 --- a/src/rm/rm.rs +++ b/src/rm/rm.rs @@ -84,20 +84,20 @@ pub fn uumain(args: Vec) -> i32 { if matches.opt_present("help") { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {0} [OPTION]... [FILE]...", NAME); - println!(""); + println!(); println!("{}", opts.usage("Remove (unlink) the FILE(s).")); println!("By default, rm does not remove directories. Use the --recursive (-r)"); println!("option to remove each listed directory, too, along with all of its contents"); - println!(""); + println!(); println!("To remove a file whose name starts with a '-', for example '-foo',"); println!("use one of these commands:"); println!("rm -- -foo"); - println!(""); + println!(); println!("rm ./-foo"); - println!(""); + println!(); println!("Note that if you use rm to remove a file, it might be possible to recover"); println!("some of its contents, given sufficient expertise and/or time. For greater"); println!("assurance that the contents are truly unrecoverable, consider using shred."); diff --git a/src/shred/shred.rs b/src/shred/shred.rs index c62b0e179..b12885045 100644 --- a/src/shred/shred.rs +++ b/src/shred/shred.rs @@ -290,7 +290,7 @@ fn show_help(opts: &getopts::Options) { println!("Delete FILE(s) if --remove (-u) is specified. The default is not to remove"); println!("the files because it is common to operate on device files like /dev/hda,"); println!("and those files usually should not be removed."); - println!(""); + println!(); println!( "CAUTION: Note that {} relies on a very important assumption:", NAME @@ -302,20 +302,20 @@ fn show_help(opts: &getopts::Options) { NAME ); println!("not effective, or is not guaranteed to be effective in all file system modes:"); - println!(""); + println!(); println!("* log-structured or journaled file systems, such as those supplied with"); println!("AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)"); - println!(""); + println!(); println!("* file systems that write redundant data and carry on even if some writes"); println!("fail, such as RAID-based file systems"); - println!(""); + println!(); println!("* file systems that make snapshots, such as Network Appliance's NFS server"); - println!(""); + println!(); println!("* file systems that cache in temporary locations, such as NFS"); println!("version 3 clients"); - println!(""); + println!(); println!("* compressed file systems"); - println!(""); + println!(); println!("In the case of ext3 file systems, the above disclaimer applies"); println!( "(and {} is thus of limited effectiveness) only in data=journal mode,", @@ -329,7 +329,7 @@ fn show_help(opts: &getopts::Options) { println!("Ext3 journaling modes can be changed by adding the data=something option"); println!("to the mount options for a particular file system in the /etc/fstab file,"); println!("as documented in the mount man page (man mount)."); - println!(""); + println!(); println!("In addition, file system backups and remote mirrors may contain copies"); println!("of the file that cannot be removed, and that will allow a shredded file"); println!("to be recovered later."); diff --git a/src/stdbuf/stdbuf.rs b/src/stdbuf/stdbuf.rs index 516672d83..7932fdd45 100644 --- a/src/stdbuf/stdbuf.rs +++ b/src/stdbuf/stdbuf.rs @@ -86,9 +86,9 @@ fn print_usage(opts: &Options) { Also some filters (like 'dd' and 'cat' etc.) don't use streams for I/O, \ and are thus unaffected by 'stdbuf' settings.\n"; println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage: stdbuf OPTION... COMMAND"); - println!(""); + println!(); println!("{}\n{}", opts.usage(brief), explanation); } diff --git a/src/sync/sync.rs b/src/sync/sync.rs index c9608e519..9b66940aa 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -147,7 +147,7 @@ pub fn uumain(args: Vec) -> i32 { fn version() { println!("{} (uutils) {}", NAME, VERSION); println!("The MIT License"); - println!(""); + println!(); println!("Author -- Alexander Fomin."); } diff --git a/src/touch/touch.rs b/src/touch/touch.rs index ed75a7676..5d67f5237 100644 --- a/src/touch/touch.rs +++ b/src/touch/touch.rs @@ -95,9 +95,9 @@ pub fn uumain(args: Vec) -> i32 { if matches.opt_present("help") || matches.free.is_empty() { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage: {} [OPTION]... FILE...", NAME); - println!(""); + println!(); println!( "{}", opts.usage( diff --git a/src/tr/tr.rs b/src/tr/tr.rs index c8e28c774..b2f81db99 100644 --- a/src/tr/tr.rs +++ b/src/tr/tr.rs @@ -178,10 +178,10 @@ fn translate_input( fn usage(opts: &Options) { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {} [OPTIONS] SET1 [SET2]", NAME); - println!(""); + println!(); println!("{}", opts.usage("Translate or delete characters.")); } diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index 203124760..40562d9b0 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -58,10 +58,10 @@ pub fn uumain(args: Vec) -> i32 { if matches.opt_present("help") { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {} [OPTION]... FILE...", NAME); - println!(""); + println!(); print!( "{}", opts.usage("Shrink or extend the size of each file to the specified size.") diff --git a/src/tsort/tsort.rs b/src/tsort/tsort.rs index 72a96229d..b04c2d0c0 100644 --- a/src/tsort/tsort.rs +++ b/src/tsort/tsort.rs @@ -36,10 +36,10 @@ pub fn uumain(args: Vec) -> i32 { if matches.opt_present("h") { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {} [OPTIONS] FILE", NAME); - println!(""); + println!(); println!("{}", opts.usage("Topological sort the strings in FILE. Strings are defined as any sequence of tokens separated by whitespace (tab, space, or newline). If FILE is not passed in, stdin is used instead.")); return 0; } diff --git a/src/tty/tty.rs b/src/tty/tty.rs index eaff78c96..033f4fbcc 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -41,10 +41,10 @@ pub fn uumain(args: Vec) -> i32 { if matches.opt_present("help") { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {} [OPTION]...", NAME); - println!(""); + println!(); print!( "{}", opts.usage("Print the file name of the terminal connected to standard input.") diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index 8554d4571..fd61917b4 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -252,10 +252,10 @@ pub fn uumain(args: Vec) -> i32 { if matches.opt_present("help") { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {0} [OPTION]... [FILE]...", NAME); - println!(""); + println!(); print!( "{}", opts.usage( @@ -263,7 +263,7 @@ pub fn uumain(args: Vec) -> i32 { writing to OUTPUT (or standard output)." ) ); - println!(""); + println!(); println!( "Note: '{0}' does not detect repeated lines unless they are adjacent.\n\ You may want to sort the input first, or use 'sort -u' without '{0}'.\n", diff --git a/src/unlink/unlink.rs b/src/unlink/unlink.rs index 9bca5e585..f5fc9f4f5 100644 --- a/src/unlink/unlink.rs +++ b/src/unlink/unlink.rs @@ -40,10 +40,10 @@ pub fn uumain(args: Vec) -> i32 { if matches.opt_present("help") { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {} [FILE]... [OPTION]...", NAME); - println!(""); + println!(); println!("{}", opts.usage("Unlink the file at [FILE].")); return 0; } diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index f83b3a3cd..e972aa584 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -50,10 +50,10 @@ pub fn uumain(args: Vec) -> i32 { } if matches.opt_present("help") || !matches.free.is_empty() { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {0} [OPTION]", NAME); - println!(""); + println!(); println!( "{}", opts.usage( diff --git a/src/users/users.rs b/src/users/users.rs index 10fb5eca5..dae2f3a20 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -37,10 +37,10 @@ pub fn uumain(args: Vec) -> i32 { if matches.opt_present("help") { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {} [OPTION]... [FILE]", NAME); - println!(""); + println!(); println!( "{}", opts.usage("Output who is currently logged in according to FILE.") diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index a2481bcf7..e8205b11b 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -24,7 +24,7 @@ include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); fn usage(cmap: &UtilityMap) { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {} [util [arguments...]]\n", NAME); println!("Currently defined functions:"); diff --git a/src/wc/wc.rs b/src/wc/wc.rs index dbe74c6e4..782859412 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -90,10 +90,10 @@ pub fn uumain(args: Vec) -> i32 { if matches.opt_present("help") { println!("{} {}", NAME, VERSION); - println!(""); + println!(); println!("Usage:"); println!(" {0} [OPTION]... [FILE]...", NAME); - println!(""); + println!(); println!( "{}", opts.usage("Print newline, word and byte counts for each FILE") @@ -254,7 +254,7 @@ fn print_stats(settings: &Settings, result: &Result, max_width: usize) { if result.title != "-" { println!(" {}", result.title); } else { - println!(""); + println!(); } }