mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
Cut down unnecessary lint allows (#14335)
Trying to reduce lint allows either by checking if they are former false positives or by fixing the underlying warning. - **Remove dead `allow(dead_code)`** - **Remove recursive dead code** - **Remove dead code** - **Move test only functions to test module** The unit tests that use them, themselves are somewhat sus in that they mock the usage and not test specificly used methods of the implementation, so there is a risk for divergence - **Remove `clippy::uninit_vec` allow.** May have been a false positive, or the impl has changed somewhat. We certainly want to look at the unsafe code here to vet for correctness.
This commit is contained in:
parent
7bd801a167
commit
455d32d9e5
@ -30,30 +30,21 @@ pub(crate) const TRANSIENT_PROMPT_MULTILINE_INDICATOR: &str =
|
|||||||
pub(crate) const PRE_PROMPT_MARKER: &str = "\x1b]133;A\x1b\\";
|
pub(crate) const PRE_PROMPT_MARKER: &str = "\x1b]133;A\x1b\\";
|
||||||
pub(crate) const POST_PROMPT_MARKER: &str = "\x1b]133;B\x1b\\";
|
pub(crate) const POST_PROMPT_MARKER: &str = "\x1b]133;B\x1b\\";
|
||||||
pub(crate) const PRE_EXECUTION_MARKER: &str = "\x1b]133;C\x1b\\";
|
pub(crate) const PRE_EXECUTION_MARKER: &str = "\x1b]133;C\x1b\\";
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) const POST_EXECUTION_MARKER_PREFIX: &str = "\x1b]133;D;";
|
pub(crate) const POST_EXECUTION_MARKER_PREFIX: &str = "\x1b]133;D;";
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) const POST_EXECUTION_MARKER_SUFFIX: &str = "\x1b\\";
|
pub(crate) const POST_EXECUTION_MARKER_SUFFIX: &str = "\x1b\\";
|
||||||
|
|
||||||
// OSC633 is the same as OSC133 but specifically for VSCode
|
// OSC633 is the same as OSC133 but specifically for VSCode
|
||||||
pub(crate) const VSCODE_PRE_PROMPT_MARKER: &str = "\x1b]633;A\x1b\\";
|
pub(crate) const VSCODE_PRE_PROMPT_MARKER: &str = "\x1b]633;A\x1b\\";
|
||||||
pub(crate) const VSCODE_POST_PROMPT_MARKER: &str = "\x1b]633;B\x1b\\";
|
pub(crate) const VSCODE_POST_PROMPT_MARKER: &str = "\x1b]633;B\x1b\\";
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) const VSCODE_PRE_EXECUTION_MARKER: &str = "\x1b]633;C\x1b\\";
|
pub(crate) const VSCODE_PRE_EXECUTION_MARKER: &str = "\x1b]633;C\x1b\\";
|
||||||
#[allow(dead_code)]
|
|
||||||
//"\x1b]633;D;{}\x1b\\"
|
//"\x1b]633;D;{}\x1b\\"
|
||||||
pub(crate) const VSCODE_POST_EXECUTION_MARKER_PREFIX: &str = "\x1b]633;D;";
|
pub(crate) const VSCODE_POST_EXECUTION_MARKER_PREFIX: &str = "\x1b]633;D;";
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) const VSCODE_POST_EXECUTION_MARKER_SUFFIX: &str = "\x1b\\";
|
pub(crate) const VSCODE_POST_EXECUTION_MARKER_SUFFIX: &str = "\x1b\\";
|
||||||
#[allow(dead_code)]
|
|
||||||
//"\x1b]633;E;{}\x1b\\"
|
//"\x1b]633;E;{}\x1b\\"
|
||||||
pub(crate) const VSCODE_COMMANDLINE_MARKER_PREFIX: &str = "\x1b]633;E;";
|
pub(crate) const VSCODE_COMMANDLINE_MARKER_PREFIX: &str = "\x1b]633;E;";
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) const VSCODE_COMMANDLINE_MARKER_SUFFIX: &str = "\x1b\\";
|
pub(crate) const VSCODE_COMMANDLINE_MARKER_SUFFIX: &str = "\x1b\\";
|
||||||
#[allow(dead_code)]
|
|
||||||
// "\x1b]633;P;Cwd={}\x1b\\"
|
// "\x1b]633;P;Cwd={}\x1b\\"
|
||||||
pub(crate) const VSCODE_CWD_PROPERTY_MARKER_PREFIX: &str = "\x1b]633;P;Cwd=";
|
pub(crate) const VSCODE_CWD_PROPERTY_MARKER_PREFIX: &str = "\x1b]633;P;Cwd=";
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) const VSCODE_CWD_PROPERTY_MARKER_SUFFIX: &str = "\x1b\\";
|
pub(crate) const VSCODE_CWD_PROPERTY_MARKER_SUFFIX: &str = "\x1b\\";
|
||||||
|
|
||||||
pub(crate) const RESET_APPLICATION_MODE: &str = "\x1b[?1l";
|
pub(crate) const RESET_APPLICATION_MODE: &str = "\x1b[?1l";
|
||||||
|
@ -711,7 +711,6 @@ pub(crate) fn create_keybindings(config: &Config) -> Result<KeybindingsMode, She
|
|||||||
}
|
}
|
||||||
for keybinding in parsed_keybindings {
|
for keybinding in parsed_keybindings {
|
||||||
add_keybinding(
|
add_keybinding(
|
||||||
&keybinding.name,
|
|
||||||
&keybinding.mode,
|
&keybinding.mode,
|
||||||
keybinding,
|
keybinding,
|
||||||
config,
|
config,
|
||||||
@ -730,9 +729,7 @@ pub(crate) fn create_keybindings(config: &Config) -> Result<KeybindingsMode, She
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::only_used_in_recursion)]
|
|
||||||
fn add_keybinding(
|
fn add_keybinding(
|
||||||
name: &Option<Value>,
|
|
||||||
mode: &Value,
|
mode: &Value,
|
||||||
keybinding: &ParsedKeybinding,
|
keybinding: &ParsedKeybinding,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
@ -755,7 +752,6 @@ fn add_keybinding(
|
|||||||
Value::List { vals, .. } => {
|
Value::List { vals, .. } => {
|
||||||
for inner_mode in vals {
|
for inner_mode in vals {
|
||||||
add_keybinding(
|
add_keybinding(
|
||||||
name,
|
|
||||||
inner_mode,
|
inner_mode,
|
||||||
keybinding,
|
keybinding,
|
||||||
config,
|
config,
|
||||||
|
@ -45,11 +45,6 @@ impl NuProgressBar {
|
|||||||
self.pb.set_position(bytes_processed);
|
self.pb.set_position(bytes_processed);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn finished_msg(&self, msg: String) {
|
|
||||||
self.pb.finish_with_message(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn abandoned_msg(&self, msg: String) {
|
pub fn abandoned_msg(&self, msg: String) {
|
||||||
self.pb.abandon_with_message(msg);
|
self.pb.abandon_with_message(msg);
|
||||||
}
|
}
|
||||||
|
@ -291,42 +291,39 @@ fn positions_helper(blanks: &[usize], min_lines: usize) -> Vec<usize> {
|
|||||||
pos
|
pos
|
||||||
}
|
}
|
||||||
|
|
||||||
// to_rows returns rows separated by columns.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn to_rows(lines: Vec<String>, pos: Vec<usize>, trim_space: bool) -> Vec<Vec<String>> {
|
|
||||||
let mut rows: Vec<Vec<String>> = Vec::with_capacity(lines.len());
|
|
||||||
for line in lines {
|
|
||||||
let columns = split(&line, &pos, trim_space);
|
|
||||||
rows.push(columns);
|
|
||||||
}
|
|
||||||
rows
|
|
||||||
}
|
|
||||||
|
|
||||||
// to_table parses a slice of lines and returns a table.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn to_table(lines: Vec<String>, header: usize, trim_space: bool) -> Vec<Vec<String>> {
|
|
||||||
let pos = positions(&lines, header, 2);
|
|
||||||
to_rows(lines, pos, trim_space)
|
|
||||||
}
|
|
||||||
|
|
||||||
// to_table_n parses a slice of lines and returns a table, but limits the number of splits.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn to_table_n(
|
|
||||||
lines: Vec<String>,
|
|
||||||
header: usize,
|
|
||||||
num_split: usize,
|
|
||||||
trim_space: bool,
|
|
||||||
) -> Vec<Vec<String>> {
|
|
||||||
let mut pos = positions(&lines, header, 2);
|
|
||||||
if pos.len() > num_split {
|
|
||||||
pos.truncate(num_split);
|
|
||||||
}
|
|
||||||
to_rows(lines, pos, trim_space)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{to_table, to_table_n, GuessWidth};
|
use super::*;
|
||||||
|
|
||||||
|
/// to_rows returns rows separated by columns.
|
||||||
|
fn to_rows(lines: Vec<String>, pos: Vec<usize>, trim_space: bool) -> Vec<Vec<String>> {
|
||||||
|
let mut rows: Vec<Vec<String>> = Vec::with_capacity(lines.len());
|
||||||
|
for line in lines {
|
||||||
|
let columns = split(&line, &pos, trim_space);
|
||||||
|
rows.push(columns);
|
||||||
|
}
|
||||||
|
rows
|
||||||
|
}
|
||||||
|
|
||||||
|
/// to_table parses a slice of lines and returns a table.
|
||||||
|
pub fn to_table(lines: Vec<String>, header: usize, trim_space: bool) -> Vec<Vec<String>> {
|
||||||
|
let pos = positions(&lines, header, 2);
|
||||||
|
to_rows(lines, pos, trim_space)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// to_table_n parses a slice of lines and returns a table, but limits the number of splits.
|
||||||
|
pub fn to_table_n(
|
||||||
|
lines: Vec<String>,
|
||||||
|
header: usize,
|
||||||
|
num_split: usize,
|
||||||
|
trim_space: bool,
|
||||||
|
) -> Vec<Vec<String>> {
|
||||||
|
let mut pos = positions(&lines, header, 2);
|
||||||
|
if pos.len() > num_split {
|
||||||
|
pos.truncate(num_split);
|
||||||
|
}
|
||||||
|
to_rows(lines, pos, trim_space)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_guess_width_ps_trim() {
|
fn test_guess_width_ps_trim() {
|
||||||
|
@ -471,7 +471,6 @@ unsafe fn null_terminated_wchar_to_string(slice: &[u16]) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::uninit_vec)]
|
|
||||||
unsafe fn get_process_data(
|
unsafe fn get_process_data(
|
||||||
handle: HANDLE,
|
handle: HANDLE,
|
||||||
ptr: *const c_void,
|
ptr: *const c_void,
|
||||||
@ -518,7 +517,6 @@ unsafe fn get_region_size(handle: HANDLE, ptr: *const c_void) -> Result<usize, &
|
|||||||
Ok((meminfo.RegionSize as isize - ptr.offset_from(meminfo.BaseAddress)) as usize)
|
Ok((meminfo.RegionSize as isize - ptr.offset_from(meminfo.BaseAddress)) as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::uninit_vec)]
|
|
||||||
unsafe fn ph_query_process_variable_size(
|
unsafe fn ph_query_process_variable_size(
|
||||||
process_handle: HANDLE,
|
process_handle: HANDLE,
|
||||||
process_information_class: PROCESSINFOCLASS,
|
process_information_class: PROCESSINFOCLASS,
|
||||||
|
Loading…
Reference in New Issue
Block a user