mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
fix(clippy): redundant_else
This commit is contained in:
parent
d64fcb1826
commit
35f3975e17
12 changed files with 189 additions and 192 deletions
|
@ -1150,9 +1150,8 @@ impl Options {
|
||||||
CpError::Error("SELinux was not enabled during the compile time!".to_owned());
|
CpError::Error("SELinux was not enabled during the compile time!".to_owned());
|
||||||
if required {
|
if required {
|
||||||
return Err(selinux_disabled_error);
|
return Err(selinux_disabled_error);
|
||||||
} else {
|
|
||||||
show_error_if_needed(&selinux_disabled_error);
|
|
||||||
}
|
}
|
||||||
|
show_error_if_needed(&selinux_disabled_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the SELinux related flags and options
|
// Extract the SELinux related flags and options
|
||||||
|
@ -1925,11 +1924,10 @@ fn handle_existing_dest(
|
||||||
source.quote()
|
source.quote()
|
||||||
)
|
)
|
||||||
.into());
|
.into());
|
||||||
} else {
|
}
|
||||||
is_dest_removed = dest.is_symlink();
|
is_dest_removed = dest.is_symlink();
|
||||||
backup_dest(dest, &backup_path, is_dest_removed)?;
|
backup_dest(dest, &backup_path, is_dest_removed)?;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if !is_dest_removed {
|
if !is_dest_removed {
|
||||||
delete_dest_if_needed_and_allowed(
|
delete_dest_if_needed_and_allowed(
|
||||||
source,
|
source,
|
||||||
|
@ -2195,7 +2193,8 @@ fn handle_copy_mode(
|
||||||
let dest_time = dest_metadata.modified()?;
|
let dest_time = dest_metadata.modified()?;
|
||||||
if src_time <= dest_time {
|
if src_time <= dest_time {
|
||||||
return Ok(PerformedAction::Skipped);
|
return Ok(PerformedAction::Skipped);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
options.overwrite.verify(dest, options.debug)?;
|
options.overwrite.verify(dest, options.debug)?;
|
||||||
|
|
||||||
copy_helper(
|
copy_helper(
|
||||||
|
@ -2211,7 +2210,6 @@ fn handle_copy_mode(
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
copy_helper(
|
copy_helper(
|
||||||
source,
|
source,
|
||||||
|
|
|
@ -429,9 +429,8 @@ fn get_delimiters(matches: &ArgMatches) -> UResult<(Delimiter, Option<&[u8]>)> {
|
||||||
1,
|
1,
|
||||||
get_message("cut-error-delimiter-must-be-single-character"),
|
get_message("cut-error-delimiter-must-be-single-character"),
|
||||||
));
|
));
|
||||||
} else {
|
|
||||||
Delimiter::from(os_string)
|
|
||||||
}
|
}
|
||||||
|
Delimiter::from(os_string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
|
|
@ -34,9 +34,8 @@ impl Matcher for ExactMatcher<'_> {
|
||||||
|| haystack[match_idx + 1..].starts_with(&self.needle[1..])
|
|| haystack[match_idx + 1..].starts_with(&self.needle[1..])
|
||||||
{
|
{
|
||||||
return Some((match_idx, match_idx + self.needle.len()));
|
return Some((match_idx, match_idx + self.needle.len()));
|
||||||
} else {
|
|
||||||
pos = match_idx + 1;
|
|
||||||
}
|
}
|
||||||
|
pos = match_idx + 1;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
return None;
|
return None;
|
||||||
|
|
|
@ -204,7 +204,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
return set_system_datetime(date);
|
return set_system_datetime(date);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// Get the current time, either in the local time zone or UTC.
|
// Get the current time, either in the local time zone or UTC.
|
||||||
let now = if settings.utc {
|
let now = if settings.utc {
|
||||||
Timestamp::now().to_zoned(TimeZone::UTC)
|
Timestamp::now().to_zoned(TimeZone::UTC)
|
||||||
|
@ -280,7 +281,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
if dirnames.is_empty() {
|
if dirnames.is_empty() {
|
||||||
return Err(UUsageError::new(1, get_message("dirname-missing-operand")));
|
return Err(UUsageError::new(1, get_message("dirname-missing-operand")));
|
||||||
} else {
|
}
|
||||||
|
|
||||||
for path in &dirnames {
|
for path in &dirnames {
|
||||||
let p = Path::new(path);
|
let p = Path::new(path);
|
||||||
match p.parent() {
|
match p.parent() {
|
||||||
|
@ -54,7 +55,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
print!("{line_ending}");
|
print!("{line_ending}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
4
src/uu/env/src/env.rs
vendored
4
src/uu/env/src/env.rs
vendored
|
@ -594,9 +594,11 @@ impl EnvAppData {
|
||||||
match cmd.status() {
|
match cmd.status() {
|
||||||
Ok(exit) if !exit.success() => {
|
Ok(exit) if !exit.success() => {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
if let Some(exit_code) = exit.code() {
|
if let Some(exit_code) = exit.code() {
|
||||||
return Err(exit_code.into());
|
return Err(exit_code.into());
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// `exit.code()` returns `None` on Unix when the process is terminated by a signal.
|
// `exit.code()` returns `None` on Unix when the process is terminated by a signal.
|
||||||
// See std::os::unix::process::ExitStatusExt for more information. This prints out
|
// See std::os::unix::process::ExitStatusExt for more information. This prints out
|
||||||
// the interrupted process and the signal it received.
|
// the interrupted process and the signal it received.
|
||||||
|
|
|
@ -175,9 +175,8 @@ fn break_knuth_plass<'a, T: Clone + Iterator<Item = &'a WordInfo<'a>>>(
|
||||||
fresh = true;
|
fresh = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
write_with_spaces(word, slen, args.ostream)?;
|
|
||||||
}
|
}
|
||||||
|
write_with_spaces(word, slen, args.ostream)?;
|
||||||
}
|
}
|
||||||
Ok((prev_punct, fresh))
|
Ok((prev_punct, fresh))
|
||||||
},
|
},
|
||||||
|
|
|
@ -1086,9 +1086,8 @@ fn write_columns(
|
||||||
}
|
}
|
||||||
if not_found_break && feed_line_present {
|
if not_found_break && feed_line_present {
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
out.write_all(line_separator)?;
|
|
||||||
}
|
}
|
||||||
|
out.write_all(line_separator)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(lines_printed)
|
Ok(lines_printed)
|
||||||
|
|
|
@ -287,13 +287,13 @@ fn read_to_buffer<T: Read>(
|
||||||
let end = last_line_end.unwrap();
|
let end = last_line_end.unwrap();
|
||||||
// We want to include the separator here, because it shouldn't be carried over.
|
// We want to include the separator here, because it shouldn't be carried over.
|
||||||
return Ok((end + 1, true));
|
return Ok((end + 1, true));
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// We need to read more lines
|
// We need to read more lines
|
||||||
let len = buffer.len();
|
let len = buffer.len();
|
||||||
// resize the vector to 10 KB more
|
// resize the vector to 10 KB more
|
||||||
buffer.resize(len + 1024 * 10, 0);
|
buffer.resize(len + 1024 * 10, 0);
|
||||||
read_target = &mut buffer[len..];
|
read_target = &mut buffer[len..];
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// This file has been fully read.
|
// This file has been fully read.
|
||||||
let mut leftover_len = read_target.len();
|
let mut leftover_len = read_target.len();
|
||||||
|
|
|
@ -763,7 +763,8 @@ impl Write for ByteChunkWriter<'_> {
|
||||||
let num_bytes_written = custom_write(buf, &mut self.inner, self.settings)?;
|
let num_bytes_written = custom_write(buf, &mut self.inner, self.settings)?;
|
||||||
self.num_bytes_remaining_in_current_chunk -= num_bytes_written as u64;
|
self.num_bytes_remaining_in_current_chunk -= num_bytes_written as u64;
|
||||||
return Ok(carryover_bytes_written + num_bytes_written);
|
return Ok(carryover_bytes_written + num_bytes_written);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// Write enough bytes to fill the current chunk.
|
// Write enough bytes to fill the current chunk.
|
||||||
//
|
//
|
||||||
// Conversion to usize is safe because we checked that
|
// Conversion to usize is safe because we checked that
|
||||||
|
@ -777,7 +778,8 @@ impl Write for ByteChunkWriter<'_> {
|
||||||
// write all the bytes.
|
// write all the bytes.
|
||||||
if num_bytes_written < i {
|
if num_bytes_written < i {
|
||||||
return Ok(carryover_bytes_written + num_bytes_written);
|
return Ok(carryover_bytes_written + num_bytes_written);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// Move the window to look at only the remaining bytes.
|
// Move the window to look at only the remaining bytes.
|
||||||
buf = &buf[i..];
|
buf = &buf[i..];
|
||||||
|
|
||||||
|
@ -785,8 +787,6 @@ impl Write for ByteChunkWriter<'_> {
|
||||||
carryover_bytes_written += num_bytes_written;
|
carryover_bytes_written += num_bytes_written;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
fn flush(&mut self) -> io::Result<()> {
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
self.inner.flush()
|
self.inner.flush()
|
||||||
}
|
}
|
||||||
|
|
|
@ -582,14 +582,14 @@ impl LinesChunkBuffer {
|
||||||
if self.chunks.is_empty() {
|
if self.chunks.is_empty() {
|
||||||
// chunks is empty when a file is empty so quitting early here
|
// chunks is empty when a file is empty so quitting early here
|
||||||
return Ok(());
|
return Ok(());
|
||||||
} else {
|
}
|
||||||
|
|
||||||
let length = &self.chunks.len();
|
let length = &self.chunks.len();
|
||||||
let last = &mut self.chunks[length - 1];
|
let last = &mut self.chunks[length - 1];
|
||||||
if !last.get_buffer().ends_with(&[self.delimiter]) {
|
if !last.get_buffer().ends_with(&[self.delimiter]) {
|
||||||
last.lines += 1;
|
last.lines += 1;
|
||||||
self.lines += 1;
|
self.lines += 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// skip unnecessary chunks and save the first chunk which may hold some lines we have to
|
// skip unnecessary chunks and save the first chunk which may hold some lines we have to
|
||||||
// print
|
// print
|
||||||
|
|
|
@ -113,7 +113,8 @@ pub fn wrap_chown<P: AsRef<Path>>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Err(out);
|
return Err(out);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
let changed = dest_uid != meta.uid() || dest_gid != meta.gid();
|
let changed = dest_uid != meta.uid() || dest_gid != meta.gid();
|
||||||
if changed {
|
if changed {
|
||||||
match verbosity.level {
|
match verbosity.level {
|
||||||
|
@ -157,7 +158,7 @@ pub fn wrap_chown<P: AsRef<Path>>(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue