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

fix clippy warnings and spelling

* add some missing LICENSE headers
This commit is contained in:
Jan Scheer 2021-06-04 00:49:06 +02:00
parent 130bf49e5d
commit f8e96150f8
17 changed files with 71 additions and 19 deletions

View file

@ -1,9 +1,9 @@
// This file is part of the uutils coreutils package.
//
// (c) Derek Chiang <derekchiang93@gmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// * This file is part of the uutils coreutils package.
// *
// * (c) Derek Chiang <derekchiang93@gmail.com>
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
#[macro_use]
extern crate uucore;
@ -25,6 +25,8 @@ use std::os::unix::fs::MetadataExt;
use std::os::windows::fs::MetadataExt;
#[cfg(windows)]
use std::os::windows::io::AsRawHandle;
#[cfg(windows)]
use std::path::Path;
use std::path::PathBuf;
use std::time::{Duration, UNIX_EPOCH};
use uucore::parse_size::{parse_size, ParseSizeError};
@ -161,7 +163,7 @@ fn birth_u64(meta: &Metadata) -> Option<u64> {
}
#[cfg(windows)]
fn get_size_on_disk(path: &PathBuf) -> u64 {
fn get_size_on_disk(path: &Path) -> u64 {
let mut size_on_disk = 0;
// bind file so it stays in scope until end of function
@ -193,7 +195,7 @@ fn get_size_on_disk(path: &PathBuf) -> u64 {
}
#[cfg(windows)]
fn get_file_info(path: &PathBuf) -> Option<FileInfo> {
fn get_file_info(path: &Path) -> Option<FileInfo> {
let mut result = None;
let file = match fs::File::open(path) {
@ -709,7 +711,7 @@ Try '{} --help' for more information.",
fn format_error_message(error: ParseSizeError, s: &str, option: &str) -> String {
// NOTE:
// GNU's du echos affected flag, -B or --block-size (-t or --threshold), depending user's selection
// GNU's du distinguishs between "invalid (suffix in) argument"
// GNU's du does distinguish between "invalid (suffix in) argument"
match error {
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument '{}'", option, s),
ParseSizeError::SizeTooBig(_) => format!("--{} argument '{}' too large", option, s),

View file

@ -1,3 +1,8 @@
// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore (vars) zlines
use clap::{crate_version, App, Arg};

View file

@ -1,3 +1,8 @@
// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
use std::ffi::OsString;
use uucore::parse_size::{parse_size, ParseSizeError};

View file

@ -643,7 +643,7 @@ fn open_input_peek_reader(
fn format_error_message(error: ParseSizeError, s: &str, option: &str) -> String {
// NOTE:
// GNU's od echos affected flag, -N or --read-bytes (-j or --skip-bytes, etc.), depending user's selection
// GNU's od distinguishs between "invalid (suffix in) argument"
// GNU's od does distinguish between "invalid (suffix in) argument"
match error {
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument '{}'", option, s),
ParseSizeError::SizeTooBig(_) => format!("--{} argument '{}' too large", option, s),

View file

@ -71,7 +71,7 @@ pub fn parse_number_of_bytes(s: &str) -> Result<usize, ParseSizeError> {
};
factor
.checked_mul(multiply)
.ok_or(ParseSizeError::SizeTooBig(s.to_string()))
.ok_or_else(|| ParseSizeError::SizeTooBig(s.to_string()))
}
#[test]
@ -80,12 +80,12 @@ fn test_parse_number_of_bytes() {
assert_eq!(8, parse_number_of_bytes("010").unwrap());
assert_eq!(8 * 512, parse_number_of_bytes("010b").unwrap());
assert_eq!(8 * 1024, parse_number_of_bytes("010k").unwrap());
assert_eq!(8 * 1048576, parse_number_of_bytes("010m").unwrap());
assert_eq!(8 * 1_048_576, parse_number_of_bytes("010m").unwrap());
// hex input
assert_eq!(15, parse_number_of_bytes("0xf").unwrap());
assert_eq!(15, parse_number_of_bytes("0XF").unwrap());
assert_eq!(27, parse_number_of_bytes("0x1b").unwrap());
assert_eq!(16 * 1024, parse_number_of_bytes("0x10k").unwrap());
assert_eq!(16 * 1048576, parse_number_of_bytes("0x10m").unwrap());
assert_eq!(16 * 1_048_576, parse_number_of_bytes("0x10m").unwrap());
}

View file

@ -1567,7 +1567,7 @@ fn open(path: impl AsRef<OsStr>) -> Box<dyn Read + Send> {
fn format_error_message(error: ParseSizeError, s: &str, option: &str) -> String {
// NOTE:
// GNU's sort echos affected flag, -S or --buffer-size, depending user's selection
// GNU's sort distinguishs between "invalid (suffix in) argument"
// GNU's sort does distinguish between "invalid (suffix in) argument"
match error {
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument '{}'", option, s),
ParseSizeError::SizeTooBig(_) => format!("--{} argument '{}' too large", option, s),

View file

@ -5,7 +5,6 @@
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// *
// spell-checker:ignore (ToDO) seekable seek'd tail'ing ringbuffer ringbuf

View file

@ -152,7 +152,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
crash!(
1,
"cannot stat '{}': No such file or directory",
reference.unwrap_or("".to_string())
reference.unwrap_or_else(|| "".to_string())
); // TODO: fix '--no-create' see test_reference and test_truncate_bytes_size
}
_ => crash!(1, "{}", e.to_string()),

View file

@ -22,7 +22,7 @@ pub extern crate winapi;
mod features; // feature-gated code modules
mod macros; // crate macros (macro_rules-type; exported to `crate::...`)
mod mods; // core cross-platform modules
mod parser; // string parsing moduls
mod parser; // string parsing modules
// * cross-platform modules
pub use crate::mods::backup_control;

View file

@ -3,6 +3,8 @@
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore (ToDO) hdsf ghead gtail
use std::convert::TryFrom;
use std::error::Error;
use std::fmt;
@ -77,7 +79,7 @@ pub fn parse_size(size: &str) -> Result<usize, ParseSizeError> {
};
number
.checked_mul(factor)
.ok_or(ParseSizeError::size_too_big(size))
.ok_or_else(|| ParseSizeError::size_too_big(size))
}
#[derive(Debug, PartialEq, Eq)]

View file

@ -1,3 +1,8 @@
// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore (paths) sublink subwords
use crate::common::util::*;

View file

@ -1,4 +1,9 @@
// spell-checker:ignore (words) bogusfile emptyfile
// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore (words) bogusfile emptyfile abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstu
use crate::common::util::*;

View file

@ -1,3 +1,8 @@
// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
extern crate unindent;
use self::unindent::*;

View file

@ -1,3 +1,8 @@
// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore (words) ints
use crate::common::util::*;

View file

@ -1,3 +1,8 @@
// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
extern crate rand;
extern crate regex;

View file

@ -1,3 +1,10 @@
// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore (ToDO) abcdefghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz vwxyz emptyfile
extern crate tail;
use crate::common::util::*;

View file

@ -1,3 +1,10 @@
// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore (words) RFILE
use crate::common::util::*;
use std::io::{Seek, SeekFrom, Write};