many warnings cleaned up

This commit is contained in:
Henry Schimke
2022-12-30 16:19:45 -06:00
parent 6a9ac8fa89
commit b383d7b0d4
48 changed files with 107 additions and 127 deletions

View File

@@ -169,7 +169,6 @@ impl Default for CodaBarWriter {
mod CodaBarWriterTestCase {
use crate::{
common::{BitMatrix, BitMatrixTestCase},
oned::OneDimensionalCodeWriter,
BarcodeFormat, Writer,
};

View File

@@ -18,7 +18,7 @@ use one_d_proc_derive::OneDWriter;
use crate::BarcodeFormat;
use super::{code_128_reader, Code128Reader, OneDimensionalCodeWriter, CODE_PATTERNS};
use super::{code_128_reader, OneDimensionalCodeWriter};
const CODE_START_A: usize = 103;
const CODE_START_B: usize = 104;

View File

@@ -44,7 +44,7 @@ use crate::{
use super::Code128Writer;
lazy_static! {
static ref writer: Code128Writer = Code128Writer::default();
static ref WRITER: Code128Writer = Code128Writer::default();
}
#[test]
@@ -330,7 +330,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetABadCharacter() {
EncodeHintType::FORCE_CODE_SET,
EncodeHintValue::ForceCodeSet("A".to_string()),
);
writer
WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode");
}
@@ -348,7 +348,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetBBadCharacter() {
);
// let hints = new EnumMap<>(EncodeHintType.class);
// hints.put(EncodeHintType.FORCE_CODE_SET, "B");
writer
WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode");
}
@@ -366,7 +366,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetCBadCharactersNonNum() {
);
// let hints = new EnumMap<>(EncodeHintType.class);
// hints.put(EncodeHintType.FORCE_CODE_SET, "C");
writer
WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode");
}
@@ -382,7 +382,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetCBadCharactersFncCode() {
EncodeHintType::FORCE_CODE_SET,
EncodeHintValue::ForceCodeSet("C".to_string()),
);
writer
WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode");
}
@@ -398,7 +398,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetCWrongAmountOfDigits() {
EncodeHintType::FORCE_CODE_SET,
EncodeHintValue::ForceCodeSet("C".to_string()),
);
writer
WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode");
}
@@ -429,7 +429,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetA() {
EncodeHintType::FORCE_CODE_SET,
EncodeHintValue::ForceCodeSet("A".to_string()),
);
let result = writer
let result = WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode");
@@ -462,7 +462,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetB() {
EncodeHintType::FORCE_CODE_SET,
EncodeHintValue::ForceCodeSet("B".to_string()),
);
let result = writer
let result = WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode");
@@ -481,7 +481,7 @@ fn encode(toEncode: &str, compact: bool, expectedLoopback: &str) -> Result<BitMa
);
}
let encRXingResult =
writer.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)?;
WRITER.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)?;
if !expectedLoopback.is_empty() {
let row = encRXingResult.getRow(0, BitArray::new());
let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
@@ -493,7 +493,7 @@ fn encode(toEncode: &str, compact: bool, expectedLoopback: &str) -> Result<BitMa
let row = encRXingResult.getRow(0, BitArray::new());
let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
let actual = rtRXingResult.getText();
let encRXingResultFast = writer.encode(toEncode, &BarcodeFormat::CODE_128, 0, 0)?;
let encRXingResultFast = WRITER.encode(toEncode, &BarcodeFormat::CODE_128, 0, 0)?;
let row = encRXingResultFast.getRow(0, BitArray::new());
let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
assert_eq!(rtRXingResult.getText(), actual);

View File

@@ -95,12 +95,13 @@ impl Code93Writer {
* @return 9
* @deprecated without replacement; intended as an internal-only method
*/
#[allow(dead_code)]
#[deprecated]
fn appendPatternWithPatternStart(
target: &mut [bool],
pos: usize,
pattern: &[usize],
startColor: bool,
_startColor: bool,
) -> u32 {
let mut pos = pos;
for bit in pattern {
@@ -219,7 +220,7 @@ impl Code93Writer {
mod Code93WriterTestCase {
use crate::{
common::BitMatrixTestCase,
oned::{Code93Writer, OneDimensionalCodeWriter},
oned::{Code93Writer},
BarcodeFormat, Writer,
};

View File

@@ -67,7 +67,7 @@ impl OneDimensionalCodeWriter for EAN13Writer {
}
}
EAN13Writer::checkNumeric(&contents);
EAN13Writer::checkNumeric(&contents)?;
let firstDigit = contents.chars().nth(0).unwrap().to_digit(10).unwrap() as usize; //, 10);
let parities = EAN13Reader::FIRST_DIGIT_ENCODINGS[firstDigit];

View File

@@ -22,7 +22,7 @@ use crate::Reader;
use super::EAN13Reader;
use super::EAN8Reader;
use super::StandIn;
use super::STAND_IN;
use super::UPCAReader;
use super::UPCEReader;
use super::{OneDReader, UPCEANReader};
@@ -124,7 +124,7 @@ impl OneDReader for MultiFormatUPCEANReader {
hints: &crate::DecodingHintDictionary,
) -> Result<crate::RXingResult, crate::Exceptions> {
// Compute this location once and reuse it on multiple implementations
let startGuardPattern = StandIn.findStartGuardPattern(row)?;
let startGuardPattern = STAND_IN.findStartGuardPattern(row)?;
for reader in &self.0 {
// for (UPCEANReader reader : readers) {
let try_result =

View File

@@ -202,7 +202,7 @@ impl Writer for L {
}
}
impl OneDimensionalCodeWriter for L {
fn encode_oned(&self, contents: &str) -> Result<Vec<bool>, Exceptions> {
fn encode_oned(&self, _contents: &str) -> Result<Vec<bool>, Exceptions> {
todo!()
}
}

View File

@@ -78,13 +78,13 @@ fn checkWeight(weight: u32) -> u32 {
mod AI013103DecoderTest {
use crate::oned::rss::expanded::decoders::abstract_decoder_test_utils::*;
const header: &str = "..X..";
const HEADER: &str = "..X..";
#[test]
fn test0131031() {
let data = format!(
"{}{}{}",
header, compressedGtin900123456798908, compressed15bitWeight1750
HEADER, compressedGtin900123456798908, compressed15bitWeight1750
);
let expected = "(01)90012345678908(3103)001750";
assertCorrectBinaryString(&data, expected);
@@ -94,7 +94,7 @@ mod AI013103DecoderTest {
fn test0131032() {
let data = format!(
"{}{}{}",
header, compressedGtin900000000000008, compressed15bitWeight0
HEADER, compressedGtin900000000000008, compressed15bitWeight0
);
let expected = "(01)90000000000003(3103)000000";
assertCorrectBinaryString(&data, expected);
@@ -105,7 +105,7 @@ mod AI013103DecoderTest {
fn test013103invalid() {
let data = format!(
"{}{}{}..",
header, compressedGtin900123456798908, compressed15bitWeight1750
HEADER, compressedGtin900123456798908, compressed15bitWeight1750
);
assertCorrectBinaryString(&data, "");
}

View File

@@ -30,13 +30,13 @@ use super::abstract_decoder_test_utils::*;
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
*/
const header: &str = "..X.X";
const HEADER: &str = "..X.X";
#[test]
fn test0132021() {
let data = format!(
"{}{}{}",
header, compressedGtin900123456798908, compressed15bitWeight1750
HEADER, compressedGtin900123456798908, compressed15bitWeight1750
);
let expected = "(01)90012345678908(3202)001750";
@@ -47,7 +47,7 @@ fn test0132021() {
fn test0132031() {
let data = format!(
"{}{}{}",
header, compressedGtin900123456798908, compressed15bitWeight11750
HEADER, compressedGtin900123456798908, compressed15bitWeight11750
);
let expected = "(01)90012345678908(3203)001750";

View File

@@ -139,20 +139,20 @@ impl<'a> AI013x0x1xDecoder<'_> {
mod AI013X0X1XDecoderTest {
use crate::oned::rss::expanded::decoders::abstract_decoder_test_utils::*;
const header310x11: &str = "..XXX...";
const header320x11: &str = "..XXX..X";
const header310x13: &str = "..XXX.X.";
const header320x13: &str = "..XXX.XX";
const header310x15: &str = "..XXXX..";
const header320x15: &str = "..XXXX.X";
const header310x17: &str = "..XXXXX.";
const header320x17: &str = "..XXXXXX";
const HEADER310X11: &str = "..XXX...";
const HEADER320X11: &str = "..XXX..X";
const HEADER310X13: &str = "..XXX.X.";
const HEADER320X13: &str = "..XXX.XX";
const HEADER310X15: &str = "..XXXX..";
const HEADER320X15: &str = "..XXXX.X";
const HEADER310X17: &str = "..XXXXX.";
const HEADER320X17: &str = "..XXXXXX";
#[test]
fn test01310X1XendDate() {
let data = format!(
"{}{}{}{}",
header310x11,
HEADER310X11,
compressedGtin900123456798908,
compressed20bitWeight1750,
compressedDateEnd
@@ -166,7 +166,7 @@ mod AI013X0X1XDecoderTest {
fn test01310X111() {
let data = format!(
"{}{}{}{}",
header310x11,
HEADER310X11,
compressedGtin900123456798908,
compressed20bitWeight1750,
compressedDateMarch12th2010
@@ -180,7 +180,7 @@ mod AI013X0X1XDecoderTest {
fn test01320X111() {
let data = format!(
"{}{}{}{}",
header320x11,
HEADER320X11,
compressedGtin900123456798908,
compressed20bitWeight1750,
compressedDateMarch12th2010
@@ -194,7 +194,7 @@ mod AI013X0X1XDecoderTest {
fn test01310X131() {
let data = format!(
"{}{}{}{}",
header310x13,
HEADER310X13,
compressedGtin900123456798908,
compressed20bitWeight1750,
compressedDateMarch12th2010
@@ -208,7 +208,7 @@ mod AI013X0X1XDecoderTest {
fn test01320X131() {
let data = format!(
"{}{}{}{}",
header320x13,
HEADER320X13,
compressedGtin900123456798908,
compressed20bitWeight1750,
compressedDateMarch12th2010
@@ -222,7 +222,7 @@ mod AI013X0X1XDecoderTest {
fn test01310X151() {
let data = format!(
"{}{}{}{}",
header310x15,
HEADER310X15,
compressedGtin900123456798908,
compressed20bitWeight1750,
compressedDateMarch12th2010
@@ -236,7 +236,7 @@ mod AI013X0X1XDecoderTest {
fn test01320X151() {
let data = format!(
"{}{}{}{}",
header320x15,
HEADER320X15,
compressedGtin900123456798908,
compressed20bitWeight1750,
compressedDateMarch12th2010
@@ -250,7 +250,7 @@ mod AI013X0X1XDecoderTest {
fn test01310X171() {
let data = format!(
"{}{}{}{}",
header310x17,
HEADER310X17,
compressedGtin900123456798908,
compressed20bitWeight1750,
compressedDateMarch12th2010
@@ -264,7 +264,7 @@ mod AI013X0X1XDecoderTest {
fn test01320X171() {
let data = format!(
"{}{}{}{}",
header320x17,
HEADER320X17,
compressedGtin900123456798908,
compressed20bitWeight1750,
compressedDateMarch12th2010

View File

@@ -48,7 +48,7 @@ impl DecodedNumeric {
pub fn new(newPosition: usize, firstDigit: u32, secondDigit: u32) -> Result<Self, Exceptions> {
// super(newPosition);
if firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10 {
if /*firstDigit < 0 ||*/ firstDigit > 10 || /*secondDigit < 0 ||*/ secondDigit > 10 {
return Err(Exceptions::FormatException(
".getFormatInstance();".to_owned(),
));

View File

@@ -21,7 +21,7 @@ use crate::{
RXingResultMetadataValue, RXingResultPoint,
};
use super::{upc_ean_reader, StandIn, UPCEANReader};
use super::{upc_ean_reader, STAND_IN, UPCEANReader};
/**
* @see UPCEANExtension5Support
@@ -88,7 +88,7 @@ impl UPCEANExtension2Support {
let mut x = 0;
while x < 2 && rowOffset < end {
// for (int x = 0; x < 2 && rowOffset < end; x++) {
let bestMatch = StandIn.decodeDigit(
let bestMatch = STAND_IN.decodeDigit(
row,
&mut counters,
rowOffset,

View File

@@ -21,7 +21,7 @@ use crate::{
RXingResultMetadataValue, RXingResultPoint,
};
use super::{upc_ean_reader, StandIn, UPCEANReader};
use super::{upc_ean_reader, STAND_IN, UPCEANReader};
/**
* @see UPCEANExtension2Support
@@ -90,7 +90,7 @@ impl UPCEANExtension5Support {
let mut x = 0;
while x < 5 && rowOffset < end {
// for (int x = 0; x < 5 && rowOffset < end; x++) {
let bestMatch = StandIn.decodeDigit(
let bestMatch = STAND_IN.decodeDigit(
row,
&mut counters,
rowOffset,

View File

@@ -16,7 +16,7 @@
use crate::{common::BitArray, Exceptions, RXingResult};
use super::{StandIn, UPCEANExtension2Support, UPCEANExtension5Support, UPCEANReader};
use super::{STAND_IN, UPCEANExtension2Support, UPCEANExtension5Support, UPCEANReader};
pub struct UPCEANExtensionSupport {
twoSupport: UPCEANExtension2Support,
@@ -41,7 +41,7 @@ impl UPCEANExtensionSupport {
rowOffset: usize,
) -> Result<RXingResult, Exceptions> {
let extensionStartRange =
StandIn.findGuardPattern(row, rowOffset, false, &Self::EXTENSION_START_PATTERN)?;
STAND_IN.findGuardPattern(row, rowOffset, false, &Self::EXTENSION_START_PATTERN)?;
if let Ok(res_1) = self
.fiveSupport
.decodeRow(rowNumber, row, &extensionStartRange)

View File

@@ -245,7 +245,7 @@ pub trait UPCEANReader: OneDReader {
Ok(())
};
let try_result = attempt();
let _try_result = attempt();
// if let Err(Exceptions::ReaderException(_)) = try_result {
// } else if try_result.is_err() {
// return Err(try_result.err().unwrap());
@@ -564,4 +564,4 @@ impl Reader for StandInStruct {
}
}
pub(crate) const StandIn: StandInStruct = StandInStruct {};
pub(crate) const STAND_IN: StandInStruct = StandInStruct {};