Fix clippy lints (#2651)

This commit is contained in:
Jonathan Turner 2020-10-09 10:47:51 +13:00 committed by GitHub
parent 152ba32eb7
commit 1159d3365a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 70 deletions

View File

@ -10,25 +10,16 @@ pub enum AutoPivotMode {
impl AutoPivotMode {
pub fn is_auto(&self) -> bool {
match &self {
AutoPivotMode::Auto => true,
_ => false,
}
matches!(self, AutoPivotMode::Auto)
}
pub fn is_always(&self) -> bool {
match &self {
AutoPivotMode::Always => true,
_ => false,
}
matches!(self, AutoPivotMode::Always)
}
#[allow(unused)]
pub fn is_never(&self) -> bool {
match &self {
AutoPivotMode::Never => true,
_ => false,
}
matches!(self, AutoPivotMode::Never)
}
}

View File

@ -135,7 +135,7 @@ fn parse_aligned_columns<'a>(
.flat_map(|s| find_indices(*s))
.collect::<Vec<usize>>();
indices.sort();
indices.sort_unstable();
indices.dedup();
let headers: Vec<(String, usize)> = indices

View File

@ -218,17 +218,13 @@ fn move_after(
));
};
let columns_moved = table
.data_descriptors()
.into_iter()
.map(|name| {
if columns.contains(&name) {
None
} else {
Some(name)
}
})
.collect::<Vec<_>>();
let columns_moved = table.data_descriptors().into_iter().map(|name| {
if columns.contains(&name) {
None
} else {
Some(name)
}
});
let mut reordered_columns = vec![];
let mut insert = false;
@ -281,17 +277,13 @@ fn move_before(
));
};
let columns_moved = table
.data_descriptors()
.into_iter()
.map(|name| {
if columns.contains(&name) {
None
} else {
Some(name)
}
})
.collect::<Vec<_>>();
let columns_moved = table.data_descriptors().into_iter().map(|name| {
if columns.contains(&name) {
None
} else {
Some(name)
}
});
let mut reordered_columns = vec![];
let mut inserted = false;

View File

@ -266,11 +266,11 @@ mod tests {
impl SignatureRegistry for VecRegistry {
fn has(&self, name: &str) -> bool {
self.0.iter().any(|v| &v.name == name)
self.0.iter().any(|v| v.name == name)
}
fn get(&self, name: &str) -> Option<nu_protocol::Signature> {
self.0.iter().find(|v| &v.name == name).map(Clone::clone)
self.0.iter().find(|v| v.name == name).map(Clone::clone)
}
fn clone_box(&self) -> Box<dyn SignatureRegistry> {

View File

@ -53,15 +53,8 @@ pub fn test_examples(cmd: Command) -> Result<(), ShellError> {
if let Some(expected) = &sample_pipeline.result {
let result = block_on(evaluate_block(block, &mut ctx))?;
ctx.with_errors(|reasons| {
reasons
.iter()
.cloned()
.take(1)
.next()
.and_then(|err| Some(err))
})
.map_or(Ok(()), |reason| Err(reason))?;
ctx.with_errors(|reasons| reasons.iter().cloned().take(1).next())
.map_or(Ok(()), Err)?;
if expected.len() != result.len() {
let rows_returned =
@ -115,15 +108,8 @@ pub fn test(cmd: impl WholeStreamCommand + 'static) -> Result<(), ShellError> {
if let Some(expected) = &sample_pipeline.result {
let result = block_on(evaluate_block(block, &mut ctx))?;
ctx.with_errors(|reasons| {
reasons
.iter()
.cloned()
.take(1)
.next()
.and_then(|err| Some(err))
})
.map_or(Ok(()), |reason| Err(reason))?;
ctx.with_errors(|reasons| reasons.iter().cloned().take(1).next())
.map_or(Ok(()), Err)?;
if expected.len() != result.len() {
let rows_returned =
@ -180,15 +166,8 @@ pub fn test_anchors(cmd: Command) -> Result<(), ShellError> {
let block = parse_line(&pipeline_with_anchor, &mut ctx)?;
let result = block_on(evaluate_block(block, &mut ctx))?;
ctx.with_errors(|reasons| {
reasons
.iter()
.cloned()
.take(1)
.next()
.and_then(|err| Some(err))
})
.map_or(Ok(()), |reason| Err(reason))?;
ctx.with_errors(|reasons| reasons.iter().cloned().take(1).next())
.map_or(Ok(()), Err)?;
for actual in result.iter() {
if !is_anchor_carried(actual, mock_path()) {
@ -366,7 +345,7 @@ impl WholeStreamCommand for MockEcho {
match i.as_string() {
Ok(s) => OutputStream::one(Ok(ReturnSuccess::Value(Value {
value: UntaggedValue::Primitive(Primitive::String(s)),
tag: base_value.tag.clone(),
tag: base_value.tag,
}))),
_ => match i {
Value {
@ -384,7 +363,7 @@ impl WholeStreamCommand for MockEcho {
.to_output_stream(),
_ => OutputStream::one(Ok(ReturnSuccess::Value(Value {
value: i.value.clone(),
tag: base_value.tag.clone(),
tag: base_value.tag,
}))),
},
}

View File

@ -9,7 +9,7 @@ fn into_int_filesize() {
"#
));
assert!(actual.out.contains("1"));
assert!(actual.out.contains('1'));
}
#[test]
@ -21,5 +21,5 @@ fn into_int_int() {
"#
));
assert!(actual.out.contains("1"));
assert!(actual.out.contains('1'));
}

View File

@ -1,3 +1,3 @@
mod keep;
mod rows;
mod until;
mod while_;

View File

@ -33,5 +33,5 @@ fn generates_0() {
"#
));
assert!(actual.out.contains("0"));
assert!(actual.out.contains('0'));
}