forked from extern/nushell
Fix clippy lint and disable broken lint (#3865)
This commit is contained in:
@ -63,7 +63,7 @@ pub fn letcmd(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||
.expect("Internal error: type checker should require args");
|
||||
|
||||
let var_name = positional[0].var_name()?;
|
||||
let rhs_raw = evaluate_baseline_expr(&positional[2], &ctx)?;
|
||||
let rhs_raw = evaluate_baseline_expr(&positional[2], ctx)?;
|
||||
let tag: Tag = positional[2].span.into();
|
||||
|
||||
let rhs: CapturedBlock = FromValue::from_value(&rhs_raw)?;
|
||||
@ -98,7 +98,7 @@ pub fn letcmd(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||
};
|
||||
|
||||
ctx.scope.enter_scope();
|
||||
let value = evaluate_baseline_expr(expr, &ctx);
|
||||
let value = evaluate_baseline_expr(expr, ctx);
|
||||
ctx.scope.exit_scope();
|
||||
|
||||
let value = value?;
|
||||
|
@ -51,7 +51,7 @@ pub fn source(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||
let contents = std::fs::read_to_string(&expand_path(Cow::Borrowed(Path::new(&filename.item))));
|
||||
match contents {
|
||||
Ok(contents) => {
|
||||
let result = script::run_script_standalone(contents, true, &ctx, false);
|
||||
let result = script::run_script_standalone(contents, true, ctx, false);
|
||||
|
||||
if let Err(err) = result {
|
||||
ctx.error(err);
|
||||
|
@ -175,7 +175,7 @@ fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
UntaggedValue::DataFrame(df) => {
|
||||
let df = df.as_ref();
|
||||
|
||||
let res = perform_dataframe_aggregation(&df, op, &operation.tag)?;
|
||||
let res = perform_dataframe_aggregation(df, op, &operation.tag)?;
|
||||
|
||||
Ok(OutputStream::one(NuDataFrame::dataframe_to_value(res, tag)))
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let casted = series.bool().map_err(|e| {
|
||||
parse_polars_error(
|
||||
&e,
|
||||
&&series_span,
|
||||
&series_span,
|
||||
Some("Perhaps you want to use a series with booleans as mask"),
|
||||
)
|
||||
})?;
|
||||
@ -82,7 +82,7 @@ fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
|
||||
let res = df
|
||||
.as_ref()
|
||||
.filter(&casted)
|
||||
.filter(casted)
|
||||
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||
|
||||
Ok(OutputStream::one(NuDataFrame::dataframe_to_value(res, tag)))
|
||||
|
@ -180,11 +180,11 @@ fn check_column_datatypes<T: AsRef<str>>(
|
||||
for (l, r) in l_cols.iter().zip(r_cols.iter()) {
|
||||
let l_series = df_l
|
||||
.column(l.as_ref())
|
||||
.map_err(|e| parse_polars_error::<&str>(&e, &l_col_span, None))?;
|
||||
.map_err(|e| parse_polars_error::<&str>(&e, l_col_span, None))?;
|
||||
|
||||
let r_series = df_r
|
||||
.column(r.as_ref())
|
||||
.map_err(|e| parse_polars_error::<&str>(&e, &r_col_span, None))?;
|
||||
.map_err(|e| parse_polars_error::<&str>(&e, r_col_span, None))?;
|
||||
|
||||
if l_series.dtype() != r_series.dtype() {
|
||||
return Err(ShellError::labeled_error_with_secondary(
|
||||
|
@ -139,11 +139,11 @@ fn check_column_datatypes<T: AsRef<str>>(
|
||||
for w in cols.windows(2) {
|
||||
let l_series = df
|
||||
.column(w[0].as_ref())
|
||||
.map_err(|e| parse_polars_error::<&str>(&e, &col_span, None))?;
|
||||
.map_err(|e| parse_polars_error::<&str>(&e, col_span, None))?;
|
||||
|
||||
let r_series = df
|
||||
.column(w[1].as_ref())
|
||||
.map_err(|e| parse_polars_error::<&str>(&e, &col_span, None))?;
|
||||
.map_err(|e| parse_polars_error::<&str>(&e, col_span, None))?;
|
||||
|
||||
if l_series.dtype() != r_series.dtype() {
|
||||
return Err(ShellError::labeled_error_with_secondary(
|
||||
|
@ -85,7 +85,7 @@ fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
)
|
||||
})?;
|
||||
|
||||
let mut res = chunked.concat(&other_chunked);
|
||||
let mut res = chunked.concat(other_chunked);
|
||||
|
||||
res.rename(series.name());
|
||||
|
||||
|
@ -99,7 +99,7 @@ fn command(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
|
||||
let rhs = evaluate_baseline_expr(&expression.right, &args.context)?;
|
||||
|
||||
filter_dataframe(args, &col_name, &col_name_span, &rhs, &expression.op)
|
||||
filter_dataframe(args, col_name, col_name_span, &rhs, &expression.op)
|
||||
}
|
||||
|
||||
macro_rules! comparison_arm {
|
||||
|
@ -86,7 +86,7 @@ pub fn set_env(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||
ctx.scope.enter_scope();
|
||||
ctx.scope.add_vars(&captured.entries);
|
||||
|
||||
let value = evaluate_baseline_expr(&expr, &ctx);
|
||||
let value = evaluate_baseline_expr(&expr, ctx);
|
||||
|
||||
ctx.scope.exit_scope();
|
||||
|
||||
|
@ -85,10 +85,10 @@ pub fn load_env(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||
let ctx = &args.context;
|
||||
|
||||
if let Some(values) = args.opt::<Vec<Value>>(0)? {
|
||||
load_env_from_table(values, &ctx)?;
|
||||
load_env_from_table(values, ctx)?;
|
||||
}
|
||||
|
||||
load_env_from_table(args.input, &ctx)?;
|
||||
load_env_from_table(args.input, ctx)?;
|
||||
|
||||
Ok(ActionStream::empty())
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ fn with_env(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||
context.scope.add_env(env);
|
||||
context.scope.add_vars(&block.captured.entries);
|
||||
|
||||
let result = run_block(&block.block, &context, args.input, external_redirection);
|
||||
let result = run_block(&block.block, context, args.input, external_redirection);
|
||||
context.scope.exit_scope();
|
||||
|
||||
result.map(|x| x.into_action_stream())
|
||||
|
@ -67,7 +67,7 @@ fn collect(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
|
||||
let result = run_block(
|
||||
&block.block,
|
||||
&context,
|
||||
context,
|
||||
InputStream::empty(),
|
||||
external_redirection,
|
||||
);
|
||||
|
@ -52,7 +52,7 @@ fn merge(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||
context.scope.add_vars(&block.captured.entries);
|
||||
let result = run_block(
|
||||
&block.block,
|
||||
&context,
|
||||
context,
|
||||
InputStream::empty(),
|
||||
ExternalRedirection::Stdout,
|
||||
);
|
||||
|
@ -37,7 +37,6 @@ impl WholeStreamCommand for Reverse {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::needless_collect)]
|
||||
fn reverse(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||
let input = args.input.collect::<Vec<_>>();
|
||||
Ok((input.into_iter().rev().map(ReturnSuccess::value)).into_action_stream())
|
||||
|
@ -69,10 +69,10 @@ fn from_json(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
|
||||
let concat_string = args.input.collect_string(name_tag.clone())?;
|
||||
|
||||
let string_clone: Vec<_> = concat_string.item.lines().map(|x| x.to_string()).collect();
|
||||
|
||||
if objects {
|
||||
Ok(string_clone
|
||||
#[allow(clippy::needless_collect)]
|
||||
let lines: Vec<_> = concat_string.item.lines().map(|x| x.to_string()).collect();
|
||||
Ok(lines
|
||||
.into_iter()
|
||||
.filter_map(move |json_str| {
|
||||
if json_str.is_empty() {
|
||||
|
@ -218,7 +218,7 @@ fn which(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let mut output = vec![];
|
||||
|
||||
for app in which_args.applications {
|
||||
let values = which_single(app, which_args.all, &args.scope());
|
||||
let values = which_single(app, which_args.all, args.scope());
|
||||
output.extend(values);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user