From be17df52b23201a241b77beb0471fbac9076df16 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:32:01 -0400 Subject: [PATCH] clippy:if_not_else warning: unnecessary `!=` operation --> src/xls.rs:1323:5 | 1323 | / if stack.len() != 1 { 1324 | | Err(XlsError::InvalidFormula { 1325 | | stack_size: stack.len(), 1326 | | }) 1327 | | } else { 1328 | | Ok(formula) 1329 | | } | |_____^ | = help: change to `==` and swap the blocks of the `if`/`else` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else = note: `-W clippy::if-not-else` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::if_not_else)]` warning: unnecessary `!=` operation --> src/xlsb.rs:1082:5 | 1082 | / if stack.len() != 1 { 1083 | | Err(XlsbError::StackLen) 1084 | | } else { 1085 | | Ok(formula) 1086 | | } | |_____^ | = help: change to `==` and swap the blocks of the `if`/`else` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else warning: unnecessary boolean `not` operation --> src/de.rs:395:9 | 395 | / if !self.has_headers() { 396 | | visitor.visit_seq(self) 397 | | } else { 398 | | visitor.visit_map(self) 399 | | } | |_________^ | = help: remove the `!` and swap the blocks of the `if`/`else` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else warning: unnecessary boolean `not` operation --> src/de.rs:408:9 | 408 | / if !self.has_headers() { 409 | | visitor.visit_seq(self) 410 | | } else { 411 | | visitor.visit_map(self) 412 | | } | |_________^ | = help: remove the `!` and swap the blocks of the `if`/`else` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else --- src/de.rs | 12 ++++++------ src/xls.rs | 6 +++--- src/xlsb.rs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/de.rs b/src/de.rs index b6a3d281..16a414fa 100644 --- a/src/de.rs +++ b/src/de.rs @@ -392,10 +392,10 @@ where } fn deserialize_map>(self, visitor: V) -> Result { - if !self.has_headers() { - visitor.visit_seq(self) - } else { + if self.has_headers() { visitor.visit_map(self) + } else { + visitor.visit_seq(self) } } @@ -405,10 +405,10 @@ where _cells: &'static [&'static str], visitor: V, ) -> Result { - if !self.has_headers() { - visitor.visit_seq(self) - } else { + if self.has_headers() { visitor.visit_map(self) + } else { + visitor.visit_seq(self) } } diff --git a/src/xls.rs b/src/xls.rs index 7df58862..80ed0dab 100644 --- a/src/xls.rs +++ b/src/xls.rs @@ -1320,12 +1320,12 @@ fn parse_formula( } } } - if stack.len() != 1 { + if stack.len() == 1 { + Ok(formula) + } else { Err(XlsError::InvalidFormula { stack_size: stack.len(), }) - } else { - Ok(formula) } } diff --git a/src/xlsb.rs b/src/xlsb.rs index 638c14f1..c4351211 100644 --- a/src/xlsb.rs +++ b/src/xlsb.rs @@ -1079,10 +1079,10 @@ fn parse_formula( } } - if stack.len() != 1 { - Err(XlsbError::StackLen) - } else { + if stack.len() == 1 { Ok(formula) + } else { + Err(XlsbError::StackLen) } }