mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Fix clippy lints (#4262)
* Fix clippy lints * Fix clippy lints * Fix clippy lints
This commit is contained in:
parent
e6c09f2dfc
commit
f562a4526c
11 changed files with 16 additions and 17 deletions
|
@ -231,7 +231,6 @@
|
||||||
|
|
||||||
#![crate_name = "nu_ansi_term"]
|
#![crate_name = "nu_ansi_term"]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![crate_type = "dylib"]
|
|
||||||
#![warn(missing_copy_implementations)]
|
#![warn(missing_copy_implementations)]
|
||||||
// #![warn(missing_docs)]
|
// #![warn(missing_docs)]
|
||||||
#![warn(trivial_casts, trivial_numeric_casts)]
|
#![warn(trivial_casts, trivial_numeric_casts)]
|
||||||
|
|
|
@ -91,10 +91,10 @@ pub fn run_script_file(
|
||||||
fn default_prompt_string(cwd: &str) -> String {
|
fn default_prompt_string(cwd: &str) -> String {
|
||||||
format!(
|
format!(
|
||||||
"{}{}{}{}{}{}> ",
|
"{}{}{}{}{}{}> ",
|
||||||
Color::Green.bold().prefix().to_string(),
|
Color::Green.bold().prefix(),
|
||||||
cwd,
|
cwd,
|
||||||
nu_ansi_term::ansi::RESET,
|
nu_ansi_term::ansi::RESET,
|
||||||
Color::Cyan.bold().prefix().to_string(),
|
Color::Cyan.bold().prefix(),
|
||||||
current_branch(),
|
current_branch(),
|
||||||
nu_ansi_term::ansi::RESET
|
nu_ansi_term::ansi::RESET
|
||||||
)
|
)
|
||||||
|
|
|
@ -93,7 +93,7 @@ pub fn source(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
|
||||||
let path = canonicalize(source_file).map_err(|e| {
|
let path = canonicalize(source_file).map_err(|e| {
|
||||||
ShellError::labeled_error(
|
ShellError::labeled_error(
|
||||||
format!("Can't load source file. Reason: {}", e.to_string()),
|
format!("Can't load source file. Reason: {}", e),
|
||||||
"Can't load this file",
|
"Can't load this file",
|
||||||
filename.span(),
|
filename.span(),
|
||||||
)
|
)
|
||||||
|
@ -112,7 +112,7 @@ pub fn source(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
ctx.error(ShellError::labeled_error(
|
ctx.error(ShellError::labeled_error(
|
||||||
format!("Can't load source file. Reason: {}", e.to_string()),
|
format!("Can't load source file. Reason: {}", e),
|
||||||
"Can't load this file",
|
"Can't load this file",
|
||||||
filename.span(),
|
filename.span(),
|
||||||
));
|
));
|
||||||
|
|
|
@ -197,7 +197,7 @@ fn process_row(
|
||||||
} else {
|
} else {
|
||||||
let mut obj = input.clone();
|
let mut obj = input.clone();
|
||||||
|
|
||||||
for column in column_paths.clone() {
|
for column in column_paths {
|
||||||
let path = UntaggedValue::Primitive(Primitive::ColumnPath(column.clone()))
|
let path = UntaggedValue::Primitive(Primitive::ColumnPath(column.clone()))
|
||||||
.into_value(tag);
|
.into_value(tag);
|
||||||
let data = r.get_data(&as_string(&path)?).borrow().clone();
|
let data = r.get_data(&as_string(&path)?).borrow().clone();
|
||||||
|
|
|
@ -104,7 +104,7 @@ fn kill(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
}
|
}
|
||||||
cmd.arg("-9");
|
cmd.arg("-9");
|
||||||
} else if let Some(signal_value) = signal {
|
} else if let Some(signal_value) = signal {
|
||||||
cmd.arg(format!("-{}", signal_value.item().to_string()));
|
cmd.arg(format!("-{}", signal_value.item()));
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.arg(pid.item().to_string());
|
cmd.arg(pid.item().to_string());
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_protocol::{Signature, TaggedDictBuilder, UntaggedValue};
|
use nu_protocol::{Signature, TaggedDictBuilder, UntaggedValue};
|
||||||
use sysinfo::{ProcessExt, System, SystemExt};
|
use sysinfo::{PidExt, ProcessExt, System, SystemExt};
|
||||||
|
|
||||||
pub struct Command;
|
pub struct Command;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ fn run_ps(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
for pid in result {
|
for pid in result {
|
||||||
if let Some(result) = sys.process(pid) {
|
if let Some(result) = sys.process(pid) {
|
||||||
let mut dict = TaggedDictBuilder::new(args.name_tag());
|
let mut dict = TaggedDictBuilder::new(args.name_tag());
|
||||||
dict.insert_untagged("pid", UntaggedValue::int(pid as i64));
|
dict.insert_untagged("pid", UntaggedValue::int(pid.as_u32() as i64));
|
||||||
dict.insert_untagged("name", UntaggedValue::string(result.name()));
|
dict.insert_untagged("name", UntaggedValue::string(result.name()));
|
||||||
dict.insert_untagged(
|
dict.insert_untagged(
|
||||||
"status",
|
"status",
|
||||||
|
@ -68,7 +68,7 @@ fn run_ps(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
|
||||||
if long {
|
if long {
|
||||||
if let Some(parent) = result.parent() {
|
if let Some(parent) = result.parent() {
|
||||||
dict.insert_untagged("parent", UntaggedValue::int(parent as i64));
|
dict.insert_untagged("parent", UntaggedValue::int(parent.as_u32() as i64));
|
||||||
} else {
|
} else {
|
||||||
dict.insert_untagged("parent", UntaggedValue::nothing());
|
dict.insert_untagged("parent", UntaggedValue::nothing());
|
||||||
}
|
}
|
||||||
|
|
|
@ -970,7 +970,7 @@ fn move_item(from: &Path, from_tag: &Tag, to: &Path) -> Result<(), ShellError> {
|
||||||
} {
|
} {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(e) => Err(ShellError::labeled_error(
|
Err(e) => Err(ShellError::labeled_error(
|
||||||
format!("Could not move {:?} to {:?}. {:}", from, to, e.to_string()),
|
format!("Could not move {:?} to {:?}. {:}", from, to, e),
|
||||||
"could not move",
|
"could not move",
|
||||||
from_tag,
|
from_tag,
|
||||||
)),
|
)),
|
||||||
|
|
|
@ -147,7 +147,7 @@ pub fn process_script(
|
||||||
{
|
{
|
||||||
val.to_string()
|
val.to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("{}\\", name.to_string())
|
format!("{}\\", name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
name.to_string()
|
name.to_string()
|
||||||
|
|
|
@ -75,7 +75,7 @@ fn find_source_file(
|
||||||
|
|
||||||
let path = canonicalize(&file).map_err(|e| {
|
let path = canonicalize(&file).map_err(|e| {
|
||||||
ParseError::general_error(
|
ParseError::general_error(
|
||||||
format!("Can't load source file. Reason: {}", e.to_string()),
|
format!("Can't load source file. Reason: {}", e),
|
||||||
"Can't load this file".spanned(file_span),
|
"Can't load this file".spanned(file_span),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
@ -85,7 +85,7 @@ fn find_source_file(
|
||||||
match contents {
|
match contents {
|
||||||
Ok(contents) => parse(&contents, 0, scope),
|
Ok(contents) => parse(&contents, 0, scope),
|
||||||
Err(e) => Err(ParseError::general_error(
|
Err(e) => Err(ParseError::general_error(
|
||||||
format!("Can't load source file. Reason: {}", e.to_string()),
|
format!("Can't load source file. Reason: {}", e),
|
||||||
"Can't load this file".spanned(file_span),
|
"Can't load this file".spanned(file_span),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ impl Executable for Director {
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
Ok(child) => child,
|
Ok(child) => child,
|
||||||
Err(why) => panic!("Can't run test {}", why.to_string()),
|
Err(why) => panic!("Can't run test {}", why),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(pipelines) = &self.pipeline {
|
if let Some(pipelines) = &self.pipeline {
|
||||||
|
|
|
@ -12,9 +12,9 @@ pub mod support {
|
||||||
pub fn in_path(dirs: &Dirs, block: impl FnOnce() -> Outcome) -> Outcome {
|
pub fn in_path(dirs: &Dirs, block: impl FnOnce() -> Outcome) -> Outcome {
|
||||||
let for_env_manifest = dirs.test().to_string_lossy();
|
let for_env_manifest = dirs.test().to_string_lossy();
|
||||||
|
|
||||||
nu!(cwd: dirs.root(), format!("autoenv trust \"{}\"", for_env_manifest.to_string()));
|
nu!(cwd: dirs.root(), format!("autoenv trust \"{}\"", for_env_manifest));
|
||||||
let out = block();
|
let out = block();
|
||||||
nu!(cwd: dirs.root(), format!("autoenv untrust \"{}\"", for_env_manifest.to_string()));
|
nu!(cwd: dirs.root(), format!("autoenv untrust \"{}\"", for_env_manifest));
|
||||||
|
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue