From 8212f4f76d9546177303a8afa8678f75be426196 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 29 Sep 2023 07:58:46 -0400 Subject: [PATCH 1/5] `typo`: RangeWithoutRowCompontent -> RangeWithoutRowComponent --- src/xlsx.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xlsx.rs b/src/xlsx.rs index 8dc48906..25febc10 100644 --- a/src/xlsx.rs +++ b/src/xlsx.rs @@ -68,7 +68,7 @@ pub enum XlsxError { /// There is no column component in the range string RangeWithoutColumnComponent, /// There is no row component in the range string - RangeWithoutRowCompontent, + RangeWithoutRowComponent, /// Unexpected error Unexpected(&'static str), /// Unrecognized data @@ -121,7 +121,7 @@ impl std::fmt::Display for XlsxError { XlsxError::RangeWithoutColumnComponent => { write!(f, "Range is missing the expected column component.") } - XlsxError::RangeWithoutRowCompontent => { + XlsxError::RangeWithoutRowComponent => { write!(f, "Range is missing the expected row component.") } XlsxError::Unexpected(e) => write!(f, "{}", e), @@ -1213,7 +1213,7 @@ fn get_row_and_optional_column(range: &[u8]) -> Result<(u32, Option), XlsxE } let row = row .checked_sub(1) - .ok_or(XlsxError::RangeWithoutRowCompontent)?; + .ok_or(XlsxError::RangeWithoutRowComponent)?; Ok((row, col.checked_sub(1))) } From 1f9c828e68f2c0a4af4ad08f380f5d0e0b0e9b00 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 29 Sep 2023 07:59:27 -0400 Subject: [PATCH 2/5] `typo`: meta misspelling --- Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 86b9e0f5..91ce25ec 100644 --- a/Changelog.md +++ b/Changelog.md @@ -87,7 +87,7 @@ - docs: add `deserialize_with` example in readme - fix: Skip phonetic run - fix: Fix XLS float parsing error -- docs: Correct MBSC to MBCS in vba.rs (mispelled before) +- docs: Correct MBSC to MBCS in vba.rs (misspelled before) - style: use 2018 edition paths - fix: Add the ability to read formula values from XLSB - fix: support integral date types From 9ff2cc845a3d9faaf8a56e14b44d21496778e8bb Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:05:08 -0400 Subject: [PATCH 3/5] clippy: redundant_closure_for_method_calls warning: redundant closure --> src/xlsx.rs:383:37 | 383 | .filter_map(|a| a.ok()) | ^^^^^^^^^^ help: replace the closure with the method itself: `std::result::Result::ok` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls --- src/xlsx.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xlsx.rs b/src/xlsx.rs index 25febc10..ff425bf7 100644 --- a/src/xlsx.rs +++ b/src/xlsx.rs @@ -380,7 +380,7 @@ impl Xlsx { Ok(Event::Start(ref e)) if e.local_name().as_ref() == b"definedName" => { if let Some(a) = e .attributes() - .filter_map(|a| a.ok()) + .filter_map(std::result::Result::ok) .find(|a| a.key == QName(b"name")) { let name = a.decode_and_unescape_value(&xml)?.to_string(); From e810a7ab41ffa69a999d262845cb4e0f9c053545 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:08:48 -0400 Subject: [PATCH 4/5] clippy:needless_pass_by_value warning: this argument is passed by value, but not consumed in the function body --> src/xlsb.rs:380:51 | 380 | fn worksheet_range_from_path(&mut self, path: String) -> Result, XlsbError> { | ^^^^^^ help: consider changing the type to: `&str` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value = note: `-W clippy::needless-pass-by-value` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::needless_pass_by_value)]` --- src/xlsb.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xlsb.rs b/src/xlsb.rs index c6abd2c1..638c14f1 100644 --- a/src/xlsb.rs +++ b/src/xlsb.rs @@ -377,7 +377,7 @@ impl Xlsb { } } - fn worksheet_range_from_path(&mut self, path: String) -> Result, XlsbError> { + fn worksheet_range_from_path(&mut self, path: &str) -> Result, XlsbError> { let mut iter = RecordIter::from_zip(&mut self.zip, &path)?; let mut buf = vec![0; 1024]; let formats = &self.formats; @@ -651,7 +651,7 @@ impl Reader for Xlsb { Some((_, path)) => path.clone(), None => return None, }; - Some(self.worksheet_range_from_path(path)) + Some(self.worksheet_range_from_path(&path)) } /// MS-XLSB 2.1.7.62 @@ -669,7 +669,7 @@ impl Reader for Xlsb { sheets .into_iter() .filter_map(|(name, path)| { - let ws = self.worksheet_range_from_path(path).ok()?; + let ws = self.worksheet_range_from_path(&path).ok()?; Some((name, ws)) }) .collect() 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 5/5] 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) } }