mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 10:38:07 +02:00
Use variable names directly in the format strings (#7906)
# Description Lint: `clippy::uninlined_format_args` More readable in most situations. (May be slightly confusing for modifier format strings https://doc.rust-lang.org/std/fmt/index.html#formatting-parameters) Alternative to #7865 # User-Facing Changes None intended # Tests + Formatting (Ran `cargo +stable clippy --fix --workspace -- -A clippy::all -D clippy::uninlined_format_args` to achieve this. Depends on Rust `1.67`)
This commit is contained in:
committed by
GitHub
parent
6ae497eedc
commit
ab480856a5
@ -93,14 +93,14 @@ impl Command for Cd {
|
||||
Err(e) => {
|
||||
return Err(ShellError::DirectoryNotFound(
|
||||
v.span,
|
||||
Some(format!("IO Error: {:?}", e)),
|
||||
Some(format!("IO Error: {e:?}")),
|
||||
))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Err(ShellError::DirectoryNotFound(
|
||||
v.span,
|
||||
Some(format!("IO Error: {:?}", e1)),
|
||||
Some(format!("IO Error: {e1:?}")),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ impl Command for Cd {
|
||||
Err(e) => {
|
||||
return Err(ShellError::DirectoryNotFound(
|
||||
v.span,
|
||||
Some(format!("IO Error: {:?}", e)),
|
||||
Some(format!("IO Error: {e:?}")),
|
||||
))
|
||||
}
|
||||
};
|
||||
@ -142,14 +142,14 @@ impl Command for Cd {
|
||||
Err(e) => {
|
||||
return Err(ShellError::DirectoryNotFound(
|
||||
v.span,
|
||||
Some(format!("IO Error: {:?}", e)),
|
||||
Some(format!("IO Error: {e:?}")),
|
||||
))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Err(ShellError::DirectoryNotFound(
|
||||
v.span,
|
||||
Some(format!("IO Error: {:?}", e1)),
|
||||
Some(format!("IO Error: {e1:?}")),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -197,8 +197,7 @@ impl Command for Cd {
|
||||
Ok(PipelineData::empty())
|
||||
}
|
||||
PermissionResult::PermissionDenied(reason) => Err(ShellError::IOError(format!(
|
||||
"Cannot change directory to {}: {}",
|
||||
path, reason
|
||||
"Cannot change directory to {path}: {reason}"
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
@ -168,8 +168,7 @@ impl Command for Cp {
|
||||
canonicalize_with(dst.as_path(), ¤t_dir_path).unwrap_or(dst);
|
||||
let res = if src == dst {
|
||||
let message = format!(
|
||||
"src {:?} and dst {:?} are identical(not copied)",
|
||||
source, destination
|
||||
"src {source:?} and dst {destination:?} are identical(not copied)"
|
||||
);
|
||||
|
||||
return Err(ShellError::GenericError(
|
||||
|
@ -145,7 +145,7 @@ impl Command for Glob {
|
||||
Err(e) => {
|
||||
return Err(ShellError::GenericError(
|
||||
"error with glob pattern".to_string(),
|
||||
format!("{}", e),
|
||||
format!("{e}"),
|
||||
Some(glob_pattern.span),
|
||||
None,
|
||||
Vec::new(),
|
||||
|
@ -70,7 +70,7 @@ impl Command for Mkdir {
|
||||
|
||||
if let Err(reason) = dir_res {
|
||||
return Err(ShellError::CreateNotPossible(
|
||||
format!("failed to create directory: {}", reason),
|
||||
format!("failed to create directory: {reason}"),
|
||||
call.positional_nth(i)
|
||||
.expect("already checked through directories")
|
||||
.span,
|
||||
|
@ -290,7 +290,7 @@ fn move_file(
|
||||
);
|
||||
if let Err(e) = interaction {
|
||||
return Err(ShellError::GenericError(
|
||||
format!("Error during interaction: {:}", e),
|
||||
format!("Error during interaction: {e:}"),
|
||||
"could not move".into(),
|
||||
None,
|
||||
None,
|
||||
@ -325,10 +325,10 @@ fn move_item(from: &Path, from_span: Span, to: &Path) -> Result<(), ShellError>
|
||||
Err(e) => {
|
||||
let error_kind = match e.kind {
|
||||
fs_extra::error::ErrorKind::Io(io) => {
|
||||
format!("I/O error: {}", io)
|
||||
format!("I/O error: {io}")
|
||||
}
|
||||
fs_extra::error::ErrorKind::StripPrefix(sp) => {
|
||||
format!("Strip prefix error: {}", sp)
|
||||
format!("Strip prefix error: {sp}")
|
||||
}
|
||||
fs_extra::error::ErrorKind::OsString(os) => {
|
||||
format!("OsString error: {:?}", os.to_str())
|
||||
@ -336,10 +336,7 @@ fn move_item(from: &Path, from_span: Span, to: &Path) -> Result<(), ShellError>
|
||||
_ => e.to_string(),
|
||||
};
|
||||
Err(ShellError::GenericError(
|
||||
format!(
|
||||
"Could not move {:?} to {:?}. Error Kind: {}",
|
||||
from, to, error_kind
|
||||
),
|
||||
format!("Could not move {from:?} to {to:?}. Error Kind: {error_kind}"),
|
||||
"could not move".into(),
|
||||
Some(from_span),
|
||||
None,
|
||||
|
@ -156,7 +156,7 @@ impl Command for Open {
|
||||
};
|
||||
|
||||
if let Some(ext) = ext {
|
||||
match engine_state.find_decl(format!("from {}", ext).as_bytes(), &[]) {
|
||||
match engine_state.find_decl(format!("from {ext}").as_bytes(), &[]) {
|
||||
Some(converter_id) => {
|
||||
let decl = engine_state.get_decl(converter_id);
|
||||
if let Some(block_id) = decl.get_block_id() {
|
||||
@ -167,7 +167,7 @@ impl Command for Open {
|
||||
}
|
||||
.map_err(|inner| {
|
||||
ShellError::GenericError(
|
||||
format!("Error while parsing as {}", ext),
|
||||
format!("Error while parsing as {ext}"),
|
||||
format!("Could not parse '{}' with `from {}`", path.display(), ext),
|
||||
Some(arg_span),
|
||||
Some(format!("Check out `help from {}` or `help from` for more options or open raw data with `open --raw '{}'`", ext, path.display())),
|
||||
|
@ -318,7 +318,7 @@ fn rm(
|
||||
);
|
||||
if let Err(e) = interaction {
|
||||
return Err(ShellError::GenericError(
|
||||
format!("Error during interaction: {:}", e),
|
||||
format!("Error during interaction: {e:}"),
|
||||
"could not move".into(),
|
||||
None,
|
||||
None,
|
||||
@ -375,7 +375,7 @@ fn rm(
|
||||
Ok(())
|
||||
} else if trash || (rm_always_trash && !permanent) {
|
||||
trash::delete(&f).map_err(|e: trash::Error| {
|
||||
Error::new(ErrorKind::Other, format!("{:?}\nTry '--trash' flag", e))
|
||||
Error::new(ErrorKind::Other, format!("{e:?}\nTry '--trash' flag"))
|
||||
})
|
||||
} else if metadata.is_file() || is_socket || is_fifo {
|
||||
std::fs::remove_file(&f)
|
||||
@ -403,7 +403,7 @@ fn rm(
|
||||
}
|
||||
|
||||
if let Err(e) = result {
|
||||
let msg = format!("Could not delete because: {:}", e);
|
||||
let msg = format!("Could not delete because: {e:}");
|
||||
Value::Error {
|
||||
error: ShellError::GenericError(
|
||||
msg,
|
||||
|
@ -215,7 +215,7 @@ fn convert_to_extension(
|
||||
input: PipelineData,
|
||||
span: Span,
|
||||
) -> Result<Vec<u8>, ShellError> {
|
||||
let converter = engine_state.find_decl(format!("to {}", extension).as_bytes(), &[]);
|
||||
let converter = engine_state.find_decl(format!("to {extension}").as_bytes(), &[]);
|
||||
|
||||
let output = match converter {
|
||||
Some(converter_id) => {
|
||||
|
@ -137,7 +137,7 @@ impl Command for Touch {
|
||||
|
||||
if let Err(err) = OpenOptions::new().write(true).create(true).open(&item) {
|
||||
return Err(ShellError::CreateNotPossible(
|
||||
format!("Failed to create file: {}", err),
|
||||
format!("Failed to create file: {err}"),
|
||||
call.positional_nth(index)
|
||||
.expect("already checked positional")
|
||||
.span,
|
||||
@ -151,7 +151,7 @@ impl Command for Touch {
|
||||
FileTime::from_system_time(date.expect("should be a valid date").into()),
|
||||
) {
|
||||
return Err(ShellError::ChangeModifiedTimeNotPossible(
|
||||
format!("Failed to change the modified time: {}", err),
|
||||
format!("Failed to change the modified time: {err}"),
|
||||
call.positional_nth(index)
|
||||
.expect("already checked positional")
|
||||
.span,
|
||||
@ -170,7 +170,7 @@ impl Command for Touch {
|
||||
),
|
||||
) {
|
||||
return Err(ShellError::ChangeAccessTimeNotPossible(
|
||||
format!("Failed to change the access time: {}", err),
|
||||
format!("Failed to change the access time: {err}"),
|
||||
call.positional_nth(index)
|
||||
.expect("already checked positional")
|
||||
.span,
|
||||
@ -183,7 +183,7 @@ impl Command for Touch {
|
||||
FileTime::from_system_time(date.expect("should be a valid date").into()),
|
||||
) {
|
||||
return Err(ShellError::ChangeAccessTimeNotPossible(
|
||||
format!("Failed to change the access time: {}", err),
|
||||
format!("Failed to change the access time: {err}"),
|
||||
call.positional_nth(index)
|
||||
.expect("already checked positional")
|
||||
.span,
|
||||
|
@ -79,7 +79,7 @@ impl Command for Watch {
|
||||
Err(e) => {
|
||||
return Err(ShellError::DirectoryNotFound(
|
||||
path_arg.span,
|
||||
Some(format!("IO Error: {:?}", e)),
|
||||
Some(format!("IO Error: {e:?}")),
|
||||
))
|
||||
}
|
||||
};
|
||||
@ -227,7 +227,7 @@ impl Command for Watch {
|
||||
match rx.recv_timeout(CHECK_CTRL_C_FREQUENCY) {
|
||||
Ok(event) => {
|
||||
if verbose {
|
||||
eprintln!("{:?}", event);
|
||||
eprintln!("{event:?}");
|
||||
}
|
||||
let handler_result = match event {
|
||||
DebouncedEvent::Create(path) => event_handler("Create", path, None),
|
||||
|
Reference in New Issue
Block a user