-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(clippy): Apply more clippy lints #70
Conversation
src/bits.rs
Outdated
0b010__110__10, // 90 | ||
0b1__001_1010, // 154 | ||
0b1100__1011, // 203 | ||
0b0110_1101, // 109 | ||
0b01_1001_00, // 100 | ||
0b01__111_001, // 121 | ||
0b0_1110_001, // 113 | ||
0b1__0000000, // 128 | ||
0b0101_1010, // 90 | ||
0b1001_1010, // 154 | ||
0b1100_1011, // 203 | ||
0b0110_1101, // 109 | ||
0b0110_0100, // 100 | ||
0b0111_1001, // 121 | ||
0b0111_0001, // 113 | ||
0b1000_0000, // 128 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert these and #[rustfmt::skip]
or #[allow]
them (whichever tool that tells you to make that change), these are intentionally separated like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted these. #[rustfmt::skip]
or #[allow]
are not added.
src/bits.rs
Outdated
assert_eq!(bits.into_bytes(), vec![0b0111_0000, 0b1001_0000]); | ||
} | ||
|
||
#[test] | ||
fn test_899() { | ||
let mut bits = Bits::new(Version::Normal(1)); | ||
assert_eq!(bits.push_eci_designator(899), Ok(())); | ||
assert_eq!(bits.into_bytes(), vec![0b0111__10_00, 0b00111000, 0b0011__0000]); | ||
assert_eq!(bits.into_bytes(), vec![0b0111_1000, 0b0011_1000, 0b0011_0000]); | ||
} | ||
|
||
#[test] | ||
fn test_999999() { | ||
let mut bits = Bits::new(Version::Normal(1)); | ||
assert_eq!(bits.push_eci_designator(999999), Ok(())); | ||
assert_eq!(bits.into_bytes(), vec![0b0111__110_0, 0b11110100, 0b00100011, 0b1111__0000]); | ||
assert_eq!(bits.push_eci_designator(999_999), Ok(())); | ||
assert_eq!(bits.into_bytes(), vec![0b0111_1100, 0b1111_0100, 0b0010_0011, 0b1111_0000]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto for the binary literals
src/bits.rs
Outdated
@@ -357,7 +358,7 @@ mod numeric_tests { | |||
assert_eq!(bits.push_numeric_data(b"01234567"), Ok(())); | |||
assert_eq!( | |||
bits.into_bytes(), | |||
vec![0b0001_0000, 0b001000_00, 0b00001100, 0b01010110, 0b01_100001, 0b1__0000000] | |||
vec![0b0001_0000, 0b0010_0000, 0b0000_1100, 0b0101_0110, 0b0110_0001, 0b1000_0000] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/bits.rs
Outdated
0b0001_0000, | ||
0b010000_00, | ||
0b00001100, | ||
0b01010110, | ||
0b01_101010, | ||
0b0100_0000, | ||
0b0000_1100, | ||
0b0101_0110, | ||
0b0110_1010, | ||
0b0110_1110, | ||
0b000101_00, | ||
0b11101010, | ||
0b0101__0000, | ||
0b0001_0100, | ||
0b1110_1010, | ||
0b0101_0000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/bits.rs
Outdated
0b0011_0111, | ||
0b0000_1010, | ||
0b0111_0101, | ||
0b0010_1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/bits.rs
Outdated
@@ -522,7 +523,7 @@ mod byte_tests { | |||
0b1010_1011, | |||
0b1100_1101, | |||
0b1110_1111, | |||
0b0000__0000, | |||
0b0000_0000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/bits.rs
Outdated
@@ -577,7 +578,7 @@ mod kanji_tests { | |||
fn test_iso_18004_example() { | |||
let mut bits = Bits::new(Version::Normal(1)); | |||
assert_eq!(bits.push_kanji_data(b"\x93\x5f\xe4\xaa"), Ok(())); | |||
assert_eq!(bits.into_bytes(), vec![0b1000_0000, 0b0010_0110, 0b11001111, 0b1_1101010, 0b101010__00]); | |||
assert_eq!(bits.into_bytes(), vec![0b1000_0000, 0b0010_0110, 0b1100_1111, 0b1110_1010, 0b1010_1000]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/bits.rs
Outdated
assert_eq!(bits.into_bytes(), vec![0b1011_1111, 0b0011_1110, 0b0011_0000]); | ||
} | ||
|
||
#[test] | ||
fn test_no_padding() { | ||
let mut bits = Bits::new(Version::Micro(1)); | ||
assert_eq!(bits.push_numeric_data(b"9999"), Ok(())); | ||
assert_eq!(bits.push_terminator(EcLevel::L), Ok(())); | ||
assert_eq!(bits.into_bytes(), vec![0b100_11111, 0b00111_100, 0b1_000__0000]); | ||
assert_eq!(bits.into_bytes(), vec![0b1001_1111, 0b0011_1100, 0b1000_0000]); | ||
} | ||
|
||
#[test] | ||
fn test_micro_version_1_half_byte_padding() { | ||
let mut bits = Bits::new(Version::Micro(1)); | ||
assert_eq!(bits.push_numeric_data(b"999"), Ok(())); | ||
assert_eq!(bits.push_terminator(EcLevel::L), Ok(())); | ||
assert_eq!(bits.into_bytes(), vec![0b011_11111, 0b00111_000, 0b0000__0000]); | ||
assert_eq!(bits.into_bytes(), vec![0b0111_1111, 0b0011_1000, 0b0000_0000]); | ||
} | ||
|
||
#[test] | ||
fn test_micro_version_1_full_byte_padding() { | ||
let mut bits = Bits::new(Version::Micro(1)); | ||
assert_eq!(bits.push_numeric_data(b""), Ok(())); | ||
assert_eq!(bits.push_terminator(EcLevel::L), Ok(())); | ||
assert_eq!(bits.into_bytes(), vec![0b000_000_00, 0b11101100, 0]); | ||
assert_eq!(bits.into_bytes(), vec![0b0000_0000, 0b1110_1100, 0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/bits.rs
Outdated
]) | ||
); | ||
} | ||
|
||
#[test] | ||
fn test_auto_mode_switch() { | ||
let res = encode(b"123A", Version::Micro(2), EcLevel::L); | ||
assert_eq!(res, Ok(vec![0b0_0011_000, 0b1111011_1, 0b001_00101, 0b0_00000__00, 0b11101100])); | ||
assert_eq!(res, Ok(vec![0b0001_1000, 0b1111_0111, 0b0010_0101, 0b0000_0000, 0b1110_1100])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/types.rs
Outdated
assert!(!(Numeric < Kanji)); | ||
assert!(!(Numeric >= Kanji)); | ||
assert!(matches!(Numeric.partial_cmp(&Kanji), None | Some(Ordering::Equal | Ordering::Greater))); | ||
assert!(matches!(Numeric.partial_cmp(&Kanji), None | Some(Ordering::Less))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??????
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the result of applying https://rust-lang.github.io/rust-clippy/master/index.html#neg_cmp_op_on_partial_ord. I'll revert this.
Overview:
|
I applied
clippy::cargo
,clippy::nursery
andclippy::pedantic
. I also applied these automatically apply lint suggestions and fixed as many parts as possible that could be fixed manually. Also, functions which can be converted toconst fn
are converted toconst fn
.Additionally, the following
rustfmt
options were applied:format_code_in_doc_comments
wrap_comments
This should not cause any breaking changes to the API.