From fdde95f6754a533d56bf3c6bface7fee893d2963 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Mon, 6 Dec 2021 07:23:43 +1300 Subject: [PATCH] Update clippy to check all features (#441) * Update clippy to check all features * Fix tests * oops --- .github/workflows/ci.yml | 4 +-- .../src/dataframe/nu_dataframe/describe.rs | 4 +-- .../src/dataframe/nu_dataframe/dtypes.rs | 8 +++--- .../src/dataframe/nu_dataframe/mod.rs | 2 +- .../src/dataframe/nu_dataframe/open.rs | 2 +- .../src/dataframe/nu_dataframe/to_df.rs | 2 +- .../between_values.rs | 0 .../{nu_dataframe => values}/conversion.rs | 2 +- .../{nu_dataframe => values}/custom_value.rs | 0 .../{nu_dataframe => values}/mod.rs | 0 .../{nu_dataframe => values}/operations.rs | 0 crates/nu-command/src/filesystem/rm.rs | 1 + src/tests.rs | 25 +++++++++++++++---- 13 files changed, 33 insertions(+), 17 deletions(-) rename crates/nu-command/src/dataframe/nu_dataframe/{nu_dataframe => values}/between_values.rs (100%) rename crates/nu-command/src/dataframe/nu_dataframe/{nu_dataframe => values}/conversion.rs (99%) rename crates/nu-command/src/dataframe/nu_dataframe/{nu_dataframe => values}/custom_value.rs (100%) rename crates/nu-command/src/dataframe/nu_dataframe/{nu_dataframe => values}/mod.rs (100%) rename crates/nu-command/src/dataframe/nu_dataframe/{nu_dataframe => values}/operations.rs (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12ed146404..9b3a066fc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: test - args: --all + args: --all --all-features - uses: actions-rs/cargo@v1 with: @@ -39,4 +39,4 @@ jobs: - uses: actions-rs/cargo@v1 with: command: clippy - args: -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect + args: --all --all-features -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect diff --git a/crates/nu-command/src/dataframe/nu_dataframe/describe.rs b/crates/nu-command/src/dataframe/nu_dataframe/describe.rs index 2aa62f440b..80bf415828 100644 --- a/crates/nu-command/src/dataframe/nu_dataframe/describe.rs +++ b/crates/nu-command/src/dataframe/nu_dataframe/describe.rs @@ -1,4 +1,4 @@ -use super::nu_dataframe::{Column, NuDataFrame}; +use super::values::{Column, NuDataFrame}; use nu_protocol::{ ast::Call, @@ -103,7 +103,7 @@ fn command( call: &Call, input: PipelineData, ) -> Result { - let df = NuDataFrame::try_from_pipeline(input, call.head.clone())?; + let df = NuDataFrame::try_from_pipeline(input, call.head)?; let names = ChunkedArray::::new_from_opt_slice( "descriptor", diff --git a/crates/nu-command/src/dataframe/nu_dataframe/dtypes.rs b/crates/nu-command/src/dataframe/nu_dataframe/dtypes.rs index 4212d54185..3152f0d91d 100644 --- a/crates/nu-command/src/dataframe/nu_dataframe/dtypes.rs +++ b/crates/nu-command/src/dataframe/nu_dataframe/dtypes.rs @@ -1,4 +1,4 @@ -use super::nu_dataframe::{Column, NuDataFrame}; +use super::values::{Column, NuDataFrame}; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, @@ -60,7 +60,7 @@ fn command( call: &Call, input: PipelineData, ) -> Result { - let df = NuDataFrame::try_from_pipeline(input, call.head.clone())?; + let df = NuDataFrame::try_from_pipeline(input, call.head)?; let mut dtypes: Vec = Vec::new(); let names: Vec = df @@ -76,12 +76,12 @@ fn command( let dtype_str = dtype.to_string(); dtypes.push(Value::String { - val: dtype_str.into(), + val: dtype_str, span: call.head, }); Value::String { - val: v.to_string().into(), + val: v.to_string(), span: call.head, } }) diff --git a/crates/nu-command/src/dataframe/nu_dataframe/mod.rs b/crates/nu-command/src/dataframe/nu_dataframe/mod.rs index 53dd228717..c90f0b6fb4 100644 --- a/crates/nu-command/src/dataframe/nu_dataframe/mod.rs +++ b/crates/nu-command/src/dataframe/nu_dataframe/mod.rs @@ -1,4 +1,4 @@ -mod nu_dataframe; +mod values; mod describe; mod dtypes; diff --git a/crates/nu-command/src/dataframe/nu_dataframe/open.rs b/crates/nu-command/src/dataframe/nu_dataframe/open.rs index 828ae50977..19fb85f9d4 100644 --- a/crates/nu-command/src/dataframe/nu_dataframe/open.rs +++ b/crates/nu-command/src/dataframe/nu_dataframe/open.rs @@ -1,4 +1,4 @@ -use super::nu_dataframe::NuDataFrame; +use super::values::NuDataFrame; use nu_engine::CallExt; use nu_protocol::{ ast::Call, diff --git a/crates/nu-command/src/dataframe/nu_dataframe/to_df.rs b/crates/nu-command/src/dataframe/nu_dataframe/to_df.rs index 95df4049c2..603d56fcbb 100644 --- a/crates/nu-command/src/dataframe/nu_dataframe/to_df.rs +++ b/crates/nu-command/src/dataframe/nu_dataframe/to_df.rs @@ -1,4 +1,4 @@ -use super::nu_dataframe::{Column, NuDataFrame}; +use super::values::{Column, NuDataFrame}; use nu_protocol::{ ast::Call, diff --git a/crates/nu-command/src/dataframe/nu_dataframe/nu_dataframe/between_values.rs b/crates/nu-command/src/dataframe/nu_dataframe/values/between_values.rs similarity index 100% rename from crates/nu-command/src/dataframe/nu_dataframe/nu_dataframe/between_values.rs rename to crates/nu-command/src/dataframe/nu_dataframe/values/between_values.rs diff --git a/crates/nu-command/src/dataframe/nu_dataframe/nu_dataframe/conversion.rs b/crates/nu-command/src/dataframe/nu_dataframe/values/conversion.rs similarity index 99% rename from crates/nu-command/src/dataframe/nu_dataframe/nu_dataframe/conversion.rs rename to crates/nu-command/src/dataframe/nu_dataframe/values/conversion.rs index 5fe78714a4..a466e4651d 100644 --- a/crates/nu-command/src/dataframe/nu_dataframe/nu_dataframe/conversion.rs +++ b/crates/nu-command/src/dataframe/nu_dataframe/values/conversion.rs @@ -531,6 +531,6 @@ pub fn from_parsed_columns(column_values: ColumnMap) -> Result Vec { use std::io::Error; result = if trash { trash::delete(&f).map_err(|e: trash::Error| { + use std::io::ErrorKind; Error::new(ErrorKind::Other, format!("{:?}", e)) }) } else if metadata.is_file() { diff --git a/src/tests.rs b/src/tests.rs index d54f5ffff6..4b9754b00a 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1190,21 +1190,36 @@ fn comment_skipping_2() -> TestResult { #[test] fn command_filter_reject_1() -> TestResult { - run_test("[[lang, gems]; [nu, 100]] | reject gems", "{lang: nu}") + run_test( + "[[lang, gems]; [nu, 100]] | reject gems | to json", + r#"[ + { + "lang": "nu" + } +]"#, + ) } #[test] fn command_filter_reject_2() -> TestResult { run_test( - "[[lang, gems, grade]; [nu, 100, a]] | reject gems grade", - "{lang: nu}", + "[[lang, gems, grade]; [nu, 100, a]] | reject gems grade | to json", + r#"[ + { + "lang": "nu" + } +]"#, ) } #[test] fn command_filter_reject_3() -> TestResult { run_test( - "[[lang, gems, grade]; [nu, 100, a]] | reject grade gems", - "{lang: nu}", + "[[lang, gems, grade]; [nu, 100, a]] | reject grade gems | to json", + r#"[ + { + "lang": "nu" + } +]"#, ) }