forked from extern/nushell
Run a round of clippy --fix to fix a ton of lints (#7006)
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com> Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
This commit is contained in:
@ -164,7 +164,7 @@ pub fn action(input: &Value, _args: &CellPathOnlyArgs, span: Span) -> Value {
|
||||
span,
|
||||
},
|
||||
Value::Bool { val, .. } => Value::Binary {
|
||||
val: int_to_endian(if *val { 1i64 } else { 0 }),
|
||||
val: int_to_endian(i64::from(*val)),
|
||||
span,
|
||||
},
|
||||
Value::Date { val, .. } => Value::Binary {
|
||||
|
@ -198,7 +198,7 @@ impl Command for Ls {
|
||||
} else if full_paths || absolute_path {
|
||||
Some(path.to_string_lossy().to_string())
|
||||
} else if let Some(prefix) = &prefix {
|
||||
if let Ok(remainder) = path.strip_prefix(&prefix) {
|
||||
if let Ok(remainder) = path.strip_prefix(prefix) {
|
||||
if directory {
|
||||
// When the path is the same as the cwd, path_diff should be "."
|
||||
let path_diff =
|
||||
@ -215,7 +215,7 @@ impl Command for Ls {
|
||||
|
||||
Some(path_diff)
|
||||
} else {
|
||||
let new_prefix = if let Some(pfx) = diff_paths(&prefix, &cwd) {
|
||||
let new_prefix = if let Some(pfx) = diff_paths(prefix, &cwd) {
|
||||
pfx
|
||||
} else {
|
||||
prefix.to_path_buf()
|
||||
|
@ -295,7 +295,7 @@ fn move_file(
|
||||
fn move_item(from: &Path, from_span: Span, to: &Path) -> Result<(), ShellError> {
|
||||
// We first try a rename, which is a quick operation. If that doesn't work, we'll try a copy
|
||||
// and remove the old file/folder. This is necessary if we're moving across filesystems or devices.
|
||||
std::fs::rename(&from, &to).or_else(|_| {
|
||||
std::fs::rename(from, to).or_else(|_| {
|
||||
match if from.is_file() {
|
||||
let mut options = fs_extra::file::CopyOptions::new();
|
||||
options.overwrite = true;
|
||||
|
@ -97,7 +97,7 @@ impl Command for Open {
|
||||
let path_no_whitespace = &path.item.trim_end_matches(|x| matches!(x, '\x09'..='\x0d'));
|
||||
let path = Path::new(path_no_whitespace);
|
||||
|
||||
if permission_denied(&path) {
|
||||
if permission_denied(path) {
|
||||
#[cfg(unix)]
|
||||
let error_msg = match path.metadata() {
|
||||
Ok(md) => format!(
|
||||
|
@ -284,8 +284,8 @@ fn rm(
|
||||
}
|
||||
|
||||
Ok(all_targets
|
||||
.into_iter()
|
||||
.map(move |(f, _)| {
|
||||
.into_keys()
|
||||
.map(move |f| {
|
||||
let is_empty = || match f.read_dir() {
|
||||
Ok(mut p) => p.next().is_none(),
|
||||
Err(_) => false,
|
||||
|
@ -72,7 +72,7 @@ impl Command for Watch {
|
||||
.item
|
||||
.trim_end_matches(|x| matches!(x, '\x09'..='\x0d'));
|
||||
|
||||
let path = match nu_path::canonicalize_with(path_no_whitespace, &cwd) {
|
||||
let path = match nu_path::canonicalize_with(path_no_whitespace, cwd) {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
return Err(ShellError::DirectoryNotFound(
|
||||
|
@ -210,7 +210,7 @@ pub fn data_group(
|
||||
value.as_string()
|
||||
};
|
||||
|
||||
let group = groups.entry(group_key?).or_insert(vec![]);
|
||||
let group = groups.entry(group_key?).or_default();
|
||||
group.push(value);
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ fn parse_aligned_columns<'a>(
|
||||
let parse_without_headers = |ls: Vec<&str>| {
|
||||
let mut indices = ls
|
||||
.iter()
|
||||
.flat_map(|s| find_indices(*s))
|
||||
.flat_map(|s| find_indices(s))
|
||||
.collect::<Vec<usize>>();
|
||||
|
||||
indices.sort_unstable();
|
||||
|
@ -284,9 +284,7 @@ pub fn run_seq(
|
||||
}
|
||||
}
|
||||
};
|
||||
if largest_dec > 0 {
|
||||
largest_dec -= 1;
|
||||
}
|
||||
largest_dec = largest_dec.saturating_sub(1);
|
||||
let separator = escape_sequences(&sep[..]);
|
||||
let terminator = match termy {
|
||||
Some(term) => escape_sequences(&term[..]),
|
||||
|
@ -96,7 +96,7 @@ pub fn median(values: &[Value], head: &Span) -> Result<Value, ShellError> {
|
||||
Ok(out.clone())
|
||||
}
|
||||
Pick::MedianAverage => {
|
||||
let idx_end = (values.len() / 2) as usize;
|
||||
let idx_end = values.len() / 2;
|
||||
let idx_start = idx_end - 1;
|
||||
|
||||
let left = sorted
|
||||
|
@ -376,8 +376,8 @@ fn helper(
|
||||
let headers = args.headers;
|
||||
let raw = args.raw;
|
||||
let login = match (user, password) {
|
||||
(Some(user), Some(password)) => Some(encode(&format!("{}:{}", user, password))),
|
||||
(Some(user), _) => Some(encode(&format!("{}:", user))),
|
||||
(Some(user), Some(password)) => Some(encode(format!("{}:{}", user, password))),
|
||||
(Some(user), _) => Some(encode(format!("{}:", user))),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
@ -115,7 +115,7 @@ fn action(
|
||||
} => {
|
||||
match base64_config.action_type {
|
||||
ActionType::Encode => {
|
||||
Value::string(encode_config(&val, base64_config_enum), command_span)
|
||||
Value::string(encode_config(val, base64_config_enum), command_span)
|
||||
}
|
||||
|
||||
ActionType::Decode => {
|
||||
|
@ -548,7 +548,7 @@ impl ExternalCommand {
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
|
||||
let mut process = std::process::Command::new(&head);
|
||||
let mut process = std::process::Command::new(head);
|
||||
|
||||
for (arg, arg_keep_raw) in self.args.iter().zip(self.arg_keep_raw.iter()) {
|
||||
// if arg is quoted, like "aa", 'aa', `aa`, or:
|
||||
|
@ -529,7 +529,7 @@ fn list_directory_contains_invalid_utf8() {
|
||||
let cwd = dirs.test();
|
||||
let path = cwd.join(s);
|
||||
|
||||
std::fs::create_dir_all(&path).expect("failed to create directory");
|
||||
std::fs::create_dir_all(path).expect("failed to create directory");
|
||||
|
||||
let actual = nu!(cwd: cwd, "ls");
|
||||
|
||||
|
Reference in New Issue
Block a user