mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:36:10 +02:00
Use nightly clippy to kill dead code/fix style (#12334)
- **Remove duplicated imports** - **Remove unused field in `CompletionOptions`** - **Remove unused struct in `nu-table`** - **Clarify generic bounds** - **Simplify a subtrait bound for `ExactSizeIterator`** - **Use `unwrap_or_default`** - **Use `Option` directly instead of empty string** - **Elide unneeded clone in `to html`**
This commit is contained in:
committed by
GitHub
parent
ff2aba7ae3
commit
e889679d42
@ -1,5 +1,5 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
use nu_protocol::ast::{CellPath, PathMember};
|
||||
use nu_protocol::ast::PathMember;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct IntoCellPath;
|
||||
|
@ -1,9 +1,6 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
use nu_parser::{parse_unit_value, DURATION_UNIT_GROUPS};
|
||||
use nu_protocol::{
|
||||
ast::{CellPath, Expr},
|
||||
Unit,
|
||||
};
|
||||
use nu_protocol::{ast::Expr, Unit};
|
||||
|
||||
const NS_PER_SEC: i64 = 1_000_000_000;
|
||||
#[derive(Clone)]
|
||||
|
@ -1,7 +1,4 @@
|
||||
use crate::{
|
||||
help::{HelpAliases, HelpCommands, HelpEscapes, HelpExterns, HelpModules, HelpOperators},
|
||||
*,
|
||||
};
|
||||
use crate::*;
|
||||
use nu_protocol::engine::{EngineState, StateWorkingSet};
|
||||
|
||||
pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
|
||||
|
@ -6,9 +6,6 @@ use std::{io::BufReader, path::Path};
|
||||
#[cfg(feature = "sqlite")]
|
||||
use crate::database::SQLiteDatabase;
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
use nu_protocol::IntoPipelineData;
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
|
@ -368,10 +368,9 @@ fn find_with_rest_and_highlight(
|
||||
let highlight_style =
|
||||
style_computer.compute("search_result", &Value::string("search result", span));
|
||||
|
||||
let cols_to_search_in_map = match call.get_flag(&engine_state, stack, "columns")? {
|
||||
Some(cols) => cols,
|
||||
None => vec![],
|
||||
};
|
||||
let cols_to_search_in_map: Vec<_> = call
|
||||
.get_flag(&engine_state, stack, "columns")?
|
||||
.unwrap_or_default();
|
||||
|
||||
let cols_to_search_in_filter = cols_to_search_in_map.clone();
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Skip;
|
||||
|
||||
|
@ -85,24 +85,22 @@ impl Command for StorDelete {
|
||||
let db = Box::new(SQLiteDatabase::new(std::path::Path::new(MEMORY_DB), None));
|
||||
|
||||
if let Some(new_table_name) = table_name_opt {
|
||||
let where_clause = match where_clause_opt {
|
||||
Some(where_stmt) => where_stmt,
|
||||
None => String::new(),
|
||||
};
|
||||
|
||||
if let Ok(conn) = db.open_connection() {
|
||||
let sql_stmt = if where_clause.is_empty() {
|
||||
// We're deleting an entire table
|
||||
format!("DROP TABLE {}", new_table_name)
|
||||
} else {
|
||||
// We're just deleting some rows
|
||||
let mut delete_stmt = format!("DELETE FROM {} ", new_table_name);
|
||||
let sql_stmt = match where_clause_opt {
|
||||
None => {
|
||||
// We're deleting an entire table
|
||||
format!("DROP TABLE {}", new_table_name)
|
||||
}
|
||||
Some(where_clause) => {
|
||||
// We're just deleting some rows
|
||||
let mut delete_stmt = format!("DELETE FROM {} ", new_table_name);
|
||||
|
||||
// Yup, this is a bit janky, but I'm not sure a better way to do this without having
|
||||
// --and and --or flags as well as supporting ==, !=, <>, is null, is not null, etc.
|
||||
// and other sql syntax. So, for now, just type a sql where clause as a string.
|
||||
delete_stmt.push_str(&format!("WHERE {}", where_clause));
|
||||
delete_stmt
|
||||
// Yup, this is a bit janky, but I'm not sure a better way to do this without having
|
||||
// --and and --or flags as well as supporting ==, !=, <>, is null, is not null, etc.
|
||||
// and other sql syntax. So, for now, just type a sql where clause as a string.
|
||||
delete_stmt.push_str(&format!("WHERE {}", where_clause));
|
||||
delete_stmt
|
||||
}
|
||||
};
|
||||
|
||||
// dbg!(&sql_stmt);
|
||||
|
@ -919,7 +919,7 @@ fn get_abbriviated_dummy(head: &[Value], tail: &VecDeque<Value>) -> Value {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_record_list<'a>(mut batch: impl Iterator<Item = &'a Value> + ExactSizeIterator) -> bool {
|
||||
fn is_record_list<'a>(mut batch: impl ExactSizeIterator<Item = &'a Value>) -> bool {
|
||||
batch.len() > 0 && batch.all(|value| matches!(value, Value::Record { .. }))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user