mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 05:55:59 +02:00
Fix easy clippy lints from latest stable (#16053)
1.88.0 was released today, clippy now lints (machine-applicable) against: - format strings with empty braces that could be inlined - easy win - `manual_abs_diff` - returning of a stored result of the last expression. - this can be somewhat contentious but touched only a few places
This commit is contained in:
committed by
GitHub
parent
372d576846
commit
9da0f41ebb
@@ -118,7 +118,7 @@ fn get_suggestions_by_value(
|
||||
|| s.chars()
|
||||
.any(|c: char| !(c.is_ascii_alphabetic() || ['_', '-'].contains(&c)))
|
||||
{
|
||||
format!("{:?}", s)
|
||||
format!("{s:?}")
|
||||
} else {
|
||||
s
|
||||
};
|
||||
|
@@ -52,7 +52,7 @@ impl CommandCompletion {
|
||||
continue;
|
||||
};
|
||||
let value = if matched_internal(&name) {
|
||||
format!("^{}", name)
|
||||
format!("^{name}")
|
||||
} else {
|
||||
name.clone()
|
||||
};
|
||||
|
@@ -176,7 +176,7 @@ impl NuCompleter {
|
||||
&mut working_set,
|
||||
Some("completer"),
|
||||
// Add a placeholder `a` to the end
|
||||
format!("{}a", line).as_bytes(),
|
||||
format!("{line}a").as_bytes(),
|
||||
false,
|
||||
);
|
||||
self.fetch_completions_by_block(block, &working_set, pos, offset, line, true)
|
||||
@@ -850,7 +850,7 @@ mod completer_tests {
|
||||
for (line, has_result, begins_with, expected_values) in dataset {
|
||||
let result = completer.fetch_completions_at(line, line.len());
|
||||
// Test whether the result is empty or not
|
||||
assert_eq!(!result.is_empty(), has_result, "line: {}", line);
|
||||
assert_eq!(!result.is_empty(), has_result, "line: {line}");
|
||||
|
||||
// Test whether the result begins with the expected value
|
||||
result
|
||||
@@ -865,8 +865,7 @@ mod completer_tests {
|
||||
.filter(|x| *x)
|
||||
.count(),
|
||||
expected_values.len(),
|
||||
"line: {}",
|
||||
line
|
||||
"line: {line}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -314,7 +314,7 @@ pub fn escape_path(path: String) -> String {
|
||||
if path.contains('\'') {
|
||||
// decide to use double quotes
|
||||
// Path as Debug will do the escaping for `"`, `\`
|
||||
format!("{:?}", path)
|
||||
format!("{path:?}")
|
||||
} else {
|
||||
format!("'{path}'")
|
||||
}
|
||||
|
@@ -129,7 +129,7 @@ impl Completer for DotNuCompletion {
|
||||
.take_while(|c| "`'\"".contains(*c))
|
||||
.collect::<String>();
|
||||
for path in ["std", "std-rfc"] {
|
||||
let path = format!("{}{}", surround_prefix, path);
|
||||
let path = format!("{surround_prefix}{path}");
|
||||
matcher.add(
|
||||
path.clone(),
|
||||
FileSuggestion {
|
||||
@@ -146,7 +146,7 @@ impl Completer for DotNuCompletion {
|
||||
for sub_vp_id in sub_paths {
|
||||
let (path, sub_vp) = working_set.get_virtual_path(*sub_vp_id);
|
||||
let path = path
|
||||
.strip_prefix(&format!("{}/", base_dir))
|
||||
.strip_prefix(&format!("{base_dir}/"))
|
||||
.unwrap_or(path)
|
||||
.to_string();
|
||||
matcher.add(
|
||||
|
@@ -239,7 +239,7 @@ fn escape_special_vscode_bytes(input: &str) -> Result<String, ShellError> {
|
||||
|
||||
match byte {
|
||||
// Escape bytes below 0x20
|
||||
b if b < 0x20 => format!("\\x{:02X}", byte).into_bytes(),
|
||||
b if b < 0x20 => format!("\\x{byte:02X}").into_bytes(),
|
||||
// Escape semicolon as \x3B
|
||||
b';' => "\\x3B".to_string().into_bytes(),
|
||||
// Escape backslash as \\
|
||||
@@ -1097,8 +1097,7 @@ fn run_shell_integration_osc633(
|
||||
// If we're in vscode, run their specific ansi escape sequence.
|
||||
// This is helpful for ctrl+g to change directories in the terminal.
|
||||
run_ansi_sequence(&format!(
|
||||
"{}{}{}",
|
||||
VSCODE_CWD_PROPERTY_MARKER_PREFIX, path, VSCODE_CWD_PROPERTY_MARKER_SUFFIX
|
||||
"{VSCODE_CWD_PROPERTY_MARKER_PREFIX}{path}{VSCODE_CWD_PROPERTY_MARKER_SUFFIX}"
|
||||
));
|
||||
|
||||
perf!(
|
||||
@@ -1114,10 +1113,7 @@ fn run_shell_integration_osc633(
|
||||
|
||||
//OSC 633 ; E ; <commandline> [; <nonce] ST - Explicitly set the command line with an optional nonce.
|
||||
run_ansi_sequence(&format!(
|
||||
"{}{}{}",
|
||||
VSCODE_COMMANDLINE_MARKER_PREFIX,
|
||||
replaced_cmd_text,
|
||||
VSCODE_COMMANDLINE_MARKER_SUFFIX
|
||||
"{VSCODE_COMMANDLINE_MARKER_PREFIX}{replaced_cmd_text}{VSCODE_COMMANDLINE_MARKER_SUFFIX}"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1493,7 +1489,7 @@ mod test_auto_cd {
|
||||
// Parse the input. It must be an auto-cd operation.
|
||||
let op = parse_operation(input.to_string(), &engine_state, &stack).unwrap();
|
||||
let ReplOperation::AutoCd { cwd, target, span } = op else {
|
||||
panic!("'{}' was not parsed into an auto-cd operation", input)
|
||||
panic!("'{input}' was not parsed into an auto-cd operation")
|
||||
};
|
||||
|
||||
// Perform the auto-cd operation.
|
||||
|
Reference in New Issue
Block a user