Update clippy to check all features (#441)

* Update clippy to check all features

* Fix tests

* oops
This commit is contained in:
JT 2021-12-06 07:23:43 +13:00 committed by GitHub
parent 9548e5ef5b
commit fdde95f675
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 33 additions and 17 deletions

View File

@ -29,7 +29,7 @@ jobs:
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:
command: test command: test
args: --all args: --all --all-features
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:
@ -39,4 +39,4 @@ jobs:
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:
command: clippy 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

View File

@ -1,4 +1,4 @@
use super::nu_dataframe::{Column, NuDataFrame}; use super::values::{Column, NuDataFrame};
use nu_protocol::{ use nu_protocol::{
ast::Call, ast::Call,
@ -103,7 +103,7 @@ fn command(
call: &Call, call: &Call,
input: PipelineData, input: PipelineData,
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
let df = NuDataFrame::try_from_pipeline(input, call.head.clone())?; let df = NuDataFrame::try_from_pipeline(input, call.head)?;
let names = ChunkedArray::<Utf8Type>::new_from_opt_slice( let names = ChunkedArray::<Utf8Type>::new_from_opt_slice(
"descriptor", "descriptor",

View File

@ -1,4 +1,4 @@
use super::nu_dataframe::{Column, NuDataFrame}; use super::values::{Column, NuDataFrame};
use nu_protocol::{ use nu_protocol::{
ast::Call, ast::Call,
engine::{Command, EngineState, Stack}, engine::{Command, EngineState, Stack},
@ -60,7 +60,7 @@ fn command(
call: &Call, call: &Call,
input: PipelineData, input: PipelineData,
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
let df = NuDataFrame::try_from_pipeline(input, call.head.clone())?; let df = NuDataFrame::try_from_pipeline(input, call.head)?;
let mut dtypes: Vec<Value> = Vec::new(); let mut dtypes: Vec<Value> = Vec::new();
let names: Vec<Value> = df let names: Vec<Value> = df
@ -76,12 +76,12 @@ fn command(
let dtype_str = dtype.to_string(); let dtype_str = dtype.to_string();
dtypes.push(Value::String { dtypes.push(Value::String {
val: dtype_str.into(), val: dtype_str,
span: call.head, span: call.head,
}); });
Value::String { Value::String {
val: v.to_string().into(), val: v.to_string(),
span: call.head, span: call.head,
} }
}) })

View File

@ -1,4 +1,4 @@
mod nu_dataframe; mod values;
mod describe; mod describe;
mod dtypes; mod dtypes;

View File

@ -1,4 +1,4 @@
use super::nu_dataframe::NuDataFrame; use super::values::NuDataFrame;
use nu_engine::CallExt; use nu_engine::CallExt;
use nu_protocol::{ use nu_protocol::{
ast::Call, ast::Call,

View File

@ -1,4 +1,4 @@
use super::nu_dataframe::{Column, NuDataFrame}; use super::values::{Column, NuDataFrame};
use nu_protocol::{ use nu_protocol::{
ast::Call, ast::Call,

View File

@ -531,6 +531,6 @@ pub fn from_parsed_columns(column_values: ColumnMap) -> Result<NuDataFrame, Shel
} }
DataFrame::new(df_series) DataFrame::new(df_series)
.map(|df| NuDataFrame::new(df)) .map(NuDataFrame::new)
.map_err(|e| ShellError::LabeledError("Error creating dataframe".into(), e.to_string())) .map_err(|e| ShellError::LabeledError("Error creating dataframe".into(), e.to_string()))
} }

View File

@ -242,6 +242,7 @@ fn rm_helper(call: &Call, args: RmArgs) -> Vec<Value> {
use std::io::Error; use std::io::Error;
result = if trash { result = if trash {
trash::delete(&f).map_err(|e: trash::Error| { trash::delete(&f).map_err(|e: trash::Error| {
use std::io::ErrorKind;
Error::new(ErrorKind::Other, format!("{:?}", e)) Error::new(ErrorKind::Other, format!("{:?}", e))
}) })
} else if metadata.is_file() { } else if metadata.is_file() {

View File

@ -1190,21 +1190,36 @@ fn comment_skipping_2() -> TestResult {
#[test] #[test]
fn command_filter_reject_1() -> TestResult { 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] #[test]
fn command_filter_reject_2() -> TestResult { fn command_filter_reject_2() -> TestResult {
run_test( run_test(
"[[lang, gems, grade]; [nu, 100, a]] | reject gems grade", "[[lang, gems, grade]; [nu, 100, a]] | reject gems grade | to json",
"{lang: nu}", r#"[
{
"lang": "nu"
}
]"#,
) )
} }
#[test] #[test]
fn command_filter_reject_3() -> TestResult { fn command_filter_reject_3() -> TestResult {
run_test( run_test(
"[[lang, gems, grade]; [nu, 100, a]] | reject grade gems", "[[lang, gems, grade]; [nu, 100, a]] | reject grade gems | to json",
"{lang: nu}", r#"[
{
"lang": "nu"
}
]"#,
) )
} }