mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 21:37:54 +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
@ -17,7 +17,7 @@ fn from_delimited_string_to_value(
|
||||
|
||||
let headers = if noheaders {
|
||||
(1..=reader.headers()?.len())
|
||||
.map(|i| format!("column{}", i))
|
||||
.map(|i| format!("column{i}"))
|
||||
.collect::<Vec<String>>()
|
||||
} else {
|
||||
reader.headers()?.iter().map(String::from).collect()
|
||||
|
@ -113,7 +113,7 @@ fn from_ics(input: PipelineData, head: Span) -> Result<PipelineData, ShellError>
|
||||
Ok(c) => output.push(calendar_to_value(c, head)),
|
||||
Err(e) => output.push(Value::Error {
|
||||
error: ShellError::UnsupportedInput(
|
||||
format!("input cannot be parsed as .ics ({})", e),
|
||||
format!("input cannot be parsed as .ics ({e})"),
|
||||
"value originates from here".into(),
|
||||
head,
|
||||
span,
|
||||
|
@ -77,7 +77,7 @@ pub fn from_ini_string_to_value(
|
||||
Ok(Value::Record { cols, vals, span })
|
||||
}
|
||||
Err(err) => Err(ShellError::UnsupportedInput(
|
||||
format!("Could not load ini: {}", err),
|
||||
format!("Could not load ini: {err}"),
|
||||
"value originates from here".into(),
|
||||
span,
|
||||
val_span,
|
||||
|
@ -183,7 +183,7 @@ fn convert_string_to_value(string_input: String, span: Span) -> Result<Value, Sh
|
||||
))
|
||||
}
|
||||
x => Err(ShellError::CantConvert(
|
||||
format!("structured json data ({})", x),
|
||||
format!("structured json data ({x})"),
|
||||
"string".into(),
|
||||
span,
|
||||
None,
|
||||
|
@ -149,7 +149,7 @@ fn from_ods(
|
||||
_ => Value::nothing(head),
|
||||
};
|
||||
|
||||
row_output.insert(format!("column{}", i), value);
|
||||
row_output.insert(format!("column{i}"), value);
|
||||
}
|
||||
|
||||
let (cols, vals) =
|
||||
|
@ -197,7 +197,7 @@ fn parse_separated_columns<'a>(
|
||||
let num_columns = ls.iter().map(|r| r.len()).max().unwrap_or(0);
|
||||
|
||||
let headers = (1..=num_columns)
|
||||
.map(|i| format!("column{}", i))
|
||||
.map(|i| format!("column{i}"))
|
||||
.collect::<Vec<String>>();
|
||||
collect(headers, ls.into_iter(), separator)
|
||||
};
|
||||
|
@ -123,7 +123,7 @@ fn from_vcf(input: PipelineData, head: Span) -> Result<PipelineData, ShellError>
|
||||
Ok(c) => contact_to_value(c, head),
|
||||
Err(e) => Value::Error {
|
||||
error: ShellError::UnsupportedInput(
|
||||
format!("input cannot be parsed as .vcf ({})", e),
|
||||
format!("input cannot be parsed as .vcf ({e})"),
|
||||
"value originates from here".into(),
|
||||
head,
|
||||
span,
|
||||
|
@ -148,7 +148,7 @@ fn from_xlsx(
|
||||
_ => Value::nothing(head),
|
||||
};
|
||||
|
||||
row_output.insert(format!("column{}", i), value);
|
||||
row_output.insert(format!("column{i}"), value);
|
||||
}
|
||||
|
||||
let (cols, vals) =
|
||||
|
@ -120,7 +120,7 @@ fn convert_yaml_value_to_nu_value(
|
||||
for (k, v) in t {
|
||||
// A ShellError that we re-use multiple times in the Mapping scenario
|
||||
let err_unexpected_map = ShellError::UnsupportedInput(
|
||||
format!("Unexpected YAML:\nKey: {:?}\nValue: {:?}", k, v),
|
||||
format!("Unexpected YAML:\nKey: {k:?}\nValue: {v:?}"),
|
||||
"value originates from here".into(),
|
||||
span,
|
||||
val_span,
|
||||
@ -189,7 +189,7 @@ pub fn from_yaml_string_to_value(
|
||||
for document in serde_yaml::Deserializer::from_str(&s) {
|
||||
let v: serde_yaml::Value = serde_yaml::Value::deserialize(document).map_err(|x| {
|
||||
ShellError::UnsupportedInput(
|
||||
format!("Could not load YAML: {}", x),
|
||||
format!("Could not load YAML: {x}"),
|
||||
"value originates from here".into(),
|
||||
span,
|
||||
val_span,
|
||||
|
Reference in New Issue
Block a user