mirror of
https://github.com/nushell/nushell.git
synced 2025-08-26 09:52:37 +02:00
chore: Clippy and dead code elimination pass (#16469)
- **Fix `clippy::non_canonical_partial_ord_impl`** - **Clippy from stable `needless_return`** - **Dead code found by `cargo +stable clippy`** - **Remove dead function used by pre-uu `mv --update`** - **clippy::manual_is_multiple_of** ## Release notes summary - What our users need to know N/A
This commit is contained in:
committed by
GitHub
parent
43a308f629
commit
5a7d9062a1
@@ -1,7 +0,0 @@
|
|||||||
use super::db_table::DbTable;
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
|
||||||
pub struct DbSchema {
|
|
||||||
pub name: String,
|
|
||||||
pub tables: Vec<DbTable>,
|
|
||||||
}
|
|
@@ -3,5 +3,4 @@ pub mod db_constraint;
|
|||||||
pub mod db_foreignkey;
|
pub mod db_foreignkey;
|
||||||
pub mod db_index;
|
pub mod db_index;
|
||||||
pub mod db_row;
|
pub mod db_row;
|
||||||
pub mod db_schema;
|
|
||||||
pub mod db_table;
|
pub mod db_table;
|
||||||
|
@@ -619,7 +619,7 @@ fn prepared_statement_to_nu_list(
|
|||||||
// got heavily in the way
|
// got heavily in the way
|
||||||
let row_values = match params {
|
let row_values = match params {
|
||||||
NuSqlParams::List(params) => {
|
NuSqlParams::List(params) => {
|
||||||
let refs: Vec<&dyn ToSql> = params.iter().map(|value| (&**value)).collect();
|
let refs: Vec<&dyn ToSql> = params.iter().map(|value| &**value).collect();
|
||||||
|
|
||||||
let row_results = stmt.query_map(refs.as_slice(), |row| {
|
let row_results = stmt.query_map(refs.as_slice(), |row| {
|
||||||
Ok(convert_sqlite_row_to_nu_value(row, call_span, &columns))
|
Ok(convert_sqlite_row_to_nu_value(row, call_span, &columns))
|
||||||
|
@@ -1,16 +1,5 @@
|
|||||||
use dialoguer::Input;
|
use dialoguer::Input;
|
||||||
use std::{
|
use std::error::Error;
|
||||||
error::Error,
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
|
|
||||||
pub struct Resource {
|
|
||||||
pub at: usize,
|
|
||||||
pub location: PathBuf,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Resource {}
|
|
||||||
|
|
||||||
pub fn try_interaction(
|
pub fn try_interaction(
|
||||||
interactive: bool,
|
interactive: bool,
|
||||||
@@ -56,34 +45,3 @@ fn get_interactive_confirmation(prompt: String) -> Result<bool, Box<dyn Error>>
|
|||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return `Some(true)` if the last change time of the `src` old than the `dst`,
|
|
||||||
/// otherwisie return `Some(false)`. Return `None` if the `src` or `dst` doesn't exist.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn is_older(src: &Path, dst: &Path) -> Option<bool> {
|
|
||||||
if !dst.exists() || !src.exists() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
#[cfg(unix)]
|
|
||||||
{
|
|
||||||
use std::os::unix::fs::MetadataExt;
|
|
||||||
let src_ctime = std::fs::metadata(src)
|
|
||||||
.map(|m| m.ctime())
|
|
||||||
.unwrap_or(i64::MIN);
|
|
||||||
let dst_ctime = std::fs::metadata(dst)
|
|
||||||
.map(|m| m.ctime())
|
|
||||||
.unwrap_or(i64::MAX);
|
|
||||||
Some(src_ctime <= dst_ctime)
|
|
||||||
}
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
use std::os::windows::fs::MetadataExt;
|
|
||||||
let src_ctime = std::fs::metadata(src)
|
|
||||||
.map(|m| m.last_write_time())
|
|
||||||
.unwrap_or(u64::MIN);
|
|
||||||
let dst_ctime = std::fs::metadata(dst)
|
|
||||||
.map(|m| m.last_write_time())
|
|
||||||
.unwrap_or(u64::MAX);
|
|
||||||
Some(src_ctime <= dst_ctime)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -85,7 +85,7 @@ enum Pick {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn median(values: &[Value], span: Span, head: Span) -> Result<Value, ShellError> {
|
pub fn median(values: &[Value], span: Span, head: Span) -> Result<Value, ShellError> {
|
||||||
let take = if values.len() % 2 == 0 {
|
let take = if values.len().is_multiple_of(2) {
|
||||||
Pick::MedianAverage
|
Pick::MedianAverage
|
||||||
} else {
|
} else {
|
||||||
Pick::Median
|
Pick::Median
|
||||||
|
@@ -474,11 +474,11 @@ fn parse_limit(
|
|||||||
} else if val == "hard" {
|
} else if val == "hard" {
|
||||||
Ok(hard_limit)
|
Ok(hard_limit)
|
||||||
} else {
|
} else {
|
||||||
return Err(ShellError::IncorrectValue {
|
Err(ShellError::IncorrectValue {
|
||||||
msg: "Only unlimited, soft and hard are supported for strings".into(),
|
msg: "Only unlimited, soft and hard are supported for strings".into(),
|
||||||
val_span,
|
val_span,
|
||||||
call_span,
|
call_span,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Err(ShellError::TypeMismatch {
|
_ => Err(ShellError::TypeMismatch {
|
||||||
|
@@ -2197,7 +2197,8 @@ pub fn parse_string_interpolation(working_set: &mut StateWorkingSet, span: Span)
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
if current_byte == b'(' && (!double_quote || preceding_consecutive_backslashes % 2 == 0)
|
if current_byte == b'('
|
||||||
|
&& (!double_quote || preceding_consecutive_backslashes.is_multiple_of(2))
|
||||||
{
|
{
|
||||||
mode = InterpolationMode::Expression;
|
mode = InterpolationMode::Expression;
|
||||||
if token_start < b {
|
if token_start < b {
|
||||||
|
@@ -2861,7 +2861,7 @@ impl<Form: PathForm> Eq for Path<Form> {}
|
|||||||
|
|
||||||
impl<Form: PathForm> PartialOrd for Path<Form> {
|
impl<Form: PathForm> PartialOrd for Path<Form> {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
Some(self.inner.cmp(&other.inner))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2887,7 +2887,7 @@ impl<Form: PathForm> Eq for PathBuf<Form> {}
|
|||||||
|
|
||||||
impl<Form: PathForm> PartialOrd for PathBuf<Form> {
|
impl<Form: PathForm> PartialOrd for PathBuf<Form> {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
Some(self.inner.cmp(&other.inner))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -88,8 +88,8 @@ impl HexConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn delimiter(&self, i: usize) -> &'static str {
|
fn delimiter(&self, i: usize) -> &'static str {
|
||||||
if i > 0 && self.chunk > 0 && i % self.chunk == 0 {
|
if i > 0 && self.chunk > 0 && i.is_multiple_of(self.chunk) {
|
||||||
if self.group > 0 && i % (self.group * self.chunk) == 0 {
|
if self.group > 0 && i.is_multiple_of(self.group * self.chunk) {
|
||||||
" "
|
" "
|
||||||
} else {
|
} else {
|
||||||
" "
|
" "
|
||||||
|
@@ -282,7 +282,7 @@ impl Grid {
|
|||||||
|
|
||||||
fn columns_dimensions(&self, num_columns: usize) -> Dimensions {
|
fn columns_dimensions(&self, num_columns: usize) -> Dimensions {
|
||||||
let mut num_lines = self.cells.len() / num_columns;
|
let mut num_lines = self.cells.len() / num_columns;
|
||||||
if self.cells.len() % num_columns != 0 {
|
if !self.cells.len().is_multiple_of(num_columns) {
|
||||||
num_lines += 1;
|
num_lines += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ impl Grid {
|
|||||||
col_total_width_so_far += cell.width;
|
col_total_width_so_far += cell.width;
|
||||||
} else {
|
} else {
|
||||||
let mut theoretical_max_num_lines = self.cell_count / theoretical_min_num_cols;
|
let mut theoretical_max_num_lines = self.cell_count / theoretical_min_num_cols;
|
||||||
if self.cell_count % theoretical_min_num_cols != 0 {
|
if !self.cell_count.is_multiple_of(theoretical_min_num_cols) {
|
||||||
theoretical_max_num_lines += 1;
|
theoretical_max_num_lines += 1;
|
||||||
}
|
}
|
||||||
return theoretical_max_num_lines;
|
return theoretical_max_num_lines;
|
||||||
@@ -374,7 +374,7 @@ impl Grid {
|
|||||||
// The number of columns is the number of cells divided by the number
|
// The number of columns is the number of cells divided by the number
|
||||||
// of lines, *rounded up*.
|
// of lines, *rounded up*.
|
||||||
let mut num_columns = self.cell_count / num_lines;
|
let mut num_columns = self.cell_count / num_lines;
|
||||||
if self.cell_count % num_lines != 0 {
|
if !self.cell_count.is_multiple_of(num_lines) {
|
||||||
num_columns += 1;
|
num_columns += 1;
|
||||||
}
|
}
|
||||||
// Early abort: if there are so many columns that the width of the
|
// Early abort: if there are so many columns that the width of the
|
||||||
|
Reference in New Issue
Block a user