Skip to content

Commit 13b78fa

Browse files
committed
fix some clippy lints and update CI workflow
This fixes some clippy lints in the tests and updates the CI workflow to use --all-targets with clippy, error out on doc failures, and use checkout@v4. Signed-off-by: Daniel Estévez <[email protected]>
1 parent 6158a3d commit 13b78fa

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

.github/workflows/rust.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ jobs:
1010
name: Default features
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v4
1414
- name: Format
1515
run: cargo fmt --all -- --check
1616
- name: Clippy
17-
run: cargo clippy -- -D warnings
17+
run: cargo clippy --all-targets -- -D warnings
1818
- name: Doc
19-
run: cargo doc
19+
run: RUSTDOCFLAGS="-D warnings" cargo doc
2020
- name: Build
2121
run: cargo build --verbose
2222
- name: Run tests
@@ -26,13 +26,13 @@ jobs:
2626
name: No features
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v4
3030
- name: Format
3131
run: cargo fmt --all -- --check
3232
- name: Clippy
33-
run: cargo clippy --no-default-features -- -D warnings
33+
run: cargo clippy --all-targets --no-default-features -- -D warnings
3434
- name: Doc
35-
run: cargo doc
35+
run: RUSTDOCFLAGS="-D warnings" cargo doc
3636
- name: Build
3737
run: cargo build --no-default-features --verbose
3838
- name: Run tests

src/bbframe.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ mod test {
676676
30 31 32 33 34 35 36 37"
677677
);
678678

679-
static MULTIPLE_FRAGMENTS: [&'static [u8]; 3] = [&FRAGMENT0, &FRAGMENT1, &FRAGMENT2];
679+
static MULTIPLE_FRAGMENTS: [&[u8]; 3] = [&FRAGMENT0, &FRAGMENT1, &FRAGMENT2];
680680

681681
#[test]
682682
fn single_fragment_defrag() {
@@ -861,7 +861,7 @@ mod proptests {
861861
// twice in order to flush a partial BBHEADER left
862862
// by the garbage.
863863
assert!(times_called.get() <= garbage_data.len() + 2);
864-
if times_called.get() >= garbage_data.len() + 1 {
864+
if times_called.get() > garbage_data.len() {
865865
assert_eq!(bbframe, Bytes::from_static(&SINGLE_FRAGMENT));
866866
}
867867
}
@@ -894,7 +894,7 @@ mod proptests {
894894
while times_called.get() <= garbage_data.len() {
895895
if let Ok(bbframe) = recv.get_bbframe() {
896896
assert!(times_called.get() <= garbage_data.len() + 1);
897-
if times_called.get() >= garbage_data.len() + 1 {
897+
if times_called.get() > garbage_data.len() {
898898
assert_eq!(bbframe, Bytes::from_static(&SINGLE_FRAGMENT));
899899
}
900900
}

src/gseheader.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ mod proptests {
539539
header.protocol_type();
540540
if let Some(label) = header.label() {
541541
label.as_slice();
542-
assert_eq!(label.is_empty(), label.len() == 0);
542+
let len = label.len();
543+
assert_eq!(label.is_empty(), len == 0);
543544
}
544545
assert!(header.len() >= 3);
545546
assert!(!header.is_empty());

src/gsepacket.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ mod proptests {
379379
fn defrag_garbage(garbage_bbframes in garbage()) {
380380
let mut defrag = GSEPacketDefrag::new();
381381
for bbframe in &garbage_bbframes {
382-
if let Ok(pdus) = defrag.defragment(&bbframe) {
382+
if let Ok(pdus) = defrag.defragment(bbframe) {
383383
for pdu in pdus {
384384
pdu.data();
385385
pdu.protocol_type();

0 commit comments

Comments
 (0)