From 888efeb93f3b5eeba51de6c111292c6c3b51da6c Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Wed, 7 Feb 2024 13:28:56 -0600 Subject: [PATCH] stage: clippy fix and gate dxo_edge_reader --- src/binary_bitmap.rs | 2 +- src/common/BitArrayTestCase.rs | 6 +++--- src/common/adaptive_threshold_binarizer.rs | 4 ++-- src/common/bit_matrix.rs | 4 ++-- src/common/cpp_essentials/base_extentions/bitmatrix.rs | 2 +- src/common/cpp_essentials/util.rs | 10 +++++----- src/luma_luma_source.rs | 2 +- src/maxicode/detector.rs | 2 +- src/multi_format_reader.rs | 3 +++ src/oned/mod.rs | 1 + src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs | 4 ++-- src/planar_yuv_luminance_source.rs | 4 ++-- src/rgb_luminance_source.rs | 6 +++--- 13 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/binary_bitmap.rs b/src/binary_bitmap.rs index 152c0a3..9e4807e 100644 --- a/src/binary_bitmap.rs +++ b/src/binary_bitmap.rs @@ -205,7 +205,7 @@ impl BinaryBitmap { } pub fn get_source(&self) -> &B::Source { - &self.binarizer.get_luminance_source() + self.binarizer.get_luminance_source() } pub fn get_binarizer(&self) -> &B { diff --git a/src/common/BitArrayTestCase.rs b/src/common/BitArrayTestCase.rs index 4ca8853..e25881f 100644 --- a/src/common/BitArrayTestCase.rs +++ b/src/common/BitArrayTestCase.rs @@ -320,12 +320,12 @@ fn test_xor_2() { match i { 1 => assert_eq!(array_1.getBitArray(), &[0b1]), 2 => assert_eq!(array_1.getBitArray(), &[0b10]), - 3 => assert_eq!(array_1.getBitArray(), &[0b10_1]), + 3 => assert_eq!(array_1.getBitArray(), &[0b101]), 4 => assert_eq!(array_1.getBitArray(), &[0b10_10]), - 5 => assert_eq!(array_1.getBitArray(), &[0b10_10_1]), + 5 => assert_eq!(array_1.getBitArray(), &[0b1_0101]), 6 => assert_eq!(array_1.getBitArray(), &[0b10_10_11]), 7..=24 => assert_eq!(array_1.getBitArray(), &[0b10_10_11 << (i - 6)], "{i}"), - _ => assert_eq!(array_1.getBitArray(), &[0b10_10_11 << i - 6, 0], "{i}"), + _ => assert_eq!(array_1.getBitArray(), &[0b10_10_11 << (i - 6), 0], "{i}"), } } } diff --git a/src/common/adaptive_threshold_binarizer.rs b/src/common/adaptive_threshold_binarizer.rs index 7d51966..30088f3 100644 --- a/src/common/adaptive_threshold_binarizer.rs +++ b/src/common/adaptive_threshold_binarizer.rs @@ -40,7 +40,7 @@ impl AdaptiveThresholdBinarizer { }; let filtered_iamge = - imageproc::contrast::adaptive_threshold(&image_buffer, self.radius.into()); + imageproc::contrast::adaptive_threshold(&image_buffer, self.radius); let dynamic_filtered = DynamicImage::from(filtered_iamge); @@ -79,7 +79,7 @@ impl Binarizer for AdaptiveThresholdBinarizer { Self: Sized, { Self { - source: source, + source, matrix: OnceCell::new(), radius: self.radius, } diff --git a/src/common/bit_matrix.rs b/src/common/bit_matrix.rs index 32771f7..b116d59 100644 --- a/src/common/bit_matrix.rs +++ b/src/common/bit_matrix.rs @@ -76,10 +76,10 @@ impl BitMatrix { Ok(Self { width, height, - row_size: ((width as usize + BASE_BITS - 1) / BASE_BITS) as usize, + row_size: ((width as usize + BASE_BITS - 1) / BASE_BITS), bits: vec![ 0; - (((width as usize + BASE_BITS - 1) / BASE_BITS) * height as usize) as usize + ((width as usize + BASE_BITS - 1) / BASE_BITS) * height as usize ], }) // this.width = width; diff --git a/src/common/cpp_essentials/base_extentions/bitmatrix.rs b/src/common/cpp_essentials/base_extentions/bitmatrix.rs index a5c19f8..26a2563 100644 --- a/src/common/cpp_essentials/base_extentions/bitmatrix.rs +++ b/src/common/cpp_essentials/base_extentions/bitmatrix.rs @@ -1,4 +1,4 @@ -use crate::common::cpp_essentials::PatternRow; + use crate::common::BitMatrix; use crate::common::Result; use crate::point_f; diff --git a/src/common/cpp_essentials/util.rs b/src/common/cpp_essentials/util.rs index 970ecf5..707b974 100644 --- a/src/common/cpp_essentials/util.rs +++ b/src/common/cpp_essentials/util.rs @@ -1,5 +1,5 @@ use std::iter::Sum; -use std::ops::Shl; + use crate::common::Result; use crate::qrcode::cpp_port::detector::AppendBit; @@ -80,10 +80,10 @@ pub fn ToInt(a: &[u32]) -> Option { let mut pattern = 0; for (i, element) in a.iter().copied().enumerate() { // for (int i = 0; i < Size(a); i++) - pattern = (pattern << element) | !(0xffffffff << element) * (!i & 1) as u32; + pattern = (pattern << element) | (!(0xffffffff << element) * (!i & 1) as u32); } - return Some(pattern); + Some(pattern) } pub fn ToIntPos( @@ -94,7 +94,7 @@ pub fn ToIntPos( // assert(0 <= count && count <= 8 * (int)sizeof(T)); // assert(0 <= pos && pos + count <= bits.size()); - let count = std::cmp::min(count as usize, bits.len()); + let count = std::cmp::min(count, bits.len()); let mut res = 0; for bit in bits.iter().skip(pos).take(count) { AppendBit(&mut res, bit == &0); @@ -103,5 +103,5 @@ pub fn ToIntPos( // for (int i = 0; i < count; ++i, ++it) // {AppendBit(res, *it);} - return Some(res as u32); + Some(res as u32) } diff --git a/src/luma_luma_source.rs b/src/luma_luma_source.rs index 9cf1fce..2313327 100644 --- a/src/luma_luma_source.rs +++ b/src/luma_luma_source.rs @@ -40,7 +40,7 @@ impl LuminanceSource for Luma8LuminanceSource { .chunks_exact(self.original_dimension.0 as usize) .skip(self.origin.1 as usize) .fold(Vec::default(), |mut acc, e| { - acc.push(e[self.origin.0 as usize + x as usize]); + acc.push(e[self.origin.0 as usize + x]); acc }) .iter() diff --git a/src/maxicode/detector.rs b/src/maxicode/detector.rs index df37975..d09eb74 100644 --- a/src/maxicode/detector.rs +++ b/src/maxicode/detector.rs @@ -1143,7 +1143,7 @@ mod detector_test { .read_to_string(&mut expected_result) .unwrap(); - let detection = super::detect(&bitmatrix, true).unwrap(); + let detection = super::detect(bitmatrix, true).unwrap(); // let i: image::DynamicImage = detection.getBits().into(); // i.save("dbgfle-transformed.png") diff --git a/src/multi_format_reader.rs b/src/multi_format_reader.rs index 1c017aa..8b84e7d 100644 --- a/src/multi_format_reader.rs +++ b/src/multi_format_reader.rs @@ -17,6 +17,7 @@ use std::collections::{HashMap, HashSet}; use crate::common::Result; +#[cfg(feature="experimental_features")] use crate::oned::cpp::ODReader; use crate::qrcode::cpp_port::QrReader; use crate::{ @@ -195,6 +196,7 @@ impl MultiFormatReader { BarcodeFormat::MAXICODE => { MaxiCodeReader::default().decode_with_hints(image, &self.hints) } + #[cfg(feature="experimental_features")] BarcodeFormat::DXFilmEdge => { ODReader::new(&self.hints).decode_with_hints(image, &self.hints) } @@ -234,6 +236,7 @@ impl MultiFormatReader { if let Ok(res) = MaxiCodeReader::default().decode_with_hints(image, &self.hints) { return Ok(res); } + #[cfg(feature="experimental_features")] if let Ok(res) = ODReader::new(&self.hints).decode_with_hints(image, &self.hints) { return Ok(res); } diff --git a/src/oned/mod.rs b/src/oned/mod.rs index 6588870..2d3171b 100644 --- a/src/oned/mod.rs +++ b/src/oned/mod.rs @@ -94,4 +94,5 @@ pub use upc_e_writer::*; mod telepen_common; +#[cfg(feature = "experimental_features")] pub mod cpp; diff --git a/src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs b/src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs index daac8c4..b9b7d12 100644 --- a/src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs +++ b/src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs @@ -42,7 +42,7 @@ pub struct AI013x0x1xDecoder<'a> { impl AI01weightDecoder for AI013x0x1xDecoder<'_> { fn addWeightCode(&self, buf: &mut String, weight: u32) { buf.push('('); - buf.push_str(&self.firstAIdigits); + buf.push_str(self.firstAIdigits); buf.push_str(&(weight / 100000).to_string()); buf.push(')'); } @@ -108,7 +108,7 @@ impl<'a> AI013x0x1xDecoder<'_> { } buf.push('('); - buf.push_str(&self.dateCode); + buf.push_str(self.dateCode); buf.push(')'); let day = numericDate % 32; diff --git a/src/planar_yuv_luminance_source.rs b/src/planar_yuv_luminance_source.rs index 6191d84..29efbbc 100644 --- a/src/planar_yuv_luminance_source.rs +++ b/src/planar_yuv_luminance_source.rs @@ -259,7 +259,7 @@ impl LuminanceSource for PlanarYUVLuminanceSource { row } - fn get_column(&self, x: usize) -> Vec { + fn get_column(&self, _x: usize) -> Vec { unimplemented!() } @@ -332,7 +332,7 @@ impl LuminanceSource for PlanarYUVLuminanceSource { self.invert = !self.invert; } - fn get_luma8_point(&self, x: usize, y: usize) -> u8 { + fn get_luma8_point(&self, _x: usize, _y: usize) -> u8 { unimplemented!() } } diff --git a/src/rgb_luminance_source.rs b/src/rgb_luminance_source.rs index 7ee00b2..1ede0a0 100644 --- a/src/rgb_luminance_source.rs +++ b/src/rgb_luminance_source.rs @@ -60,7 +60,7 @@ impl LuminanceSource for RGBLuminanceSource { row } - fn get_column(&self, x: usize) -> Vec { + fn get_column(&self, _x: usize) -> Vec { unimplemented!() } @@ -131,9 +131,9 @@ impl LuminanceSource for RGBLuminanceSource { } fn get_luma8_point(&self, x: usize, y: usize) -> u8 { - let width = self.get_width(); + let _width = self.get_width(); let row_offset = (y + self.top) * self.dataWidth + self.left; - let col_offset = (x + self.left); + let col_offset = x + self.left; self.luminances[row_offset + col_offset] }