From b01fff74b7354ae970315cb4568aff42474d987a Mon Sep 17 00:00:00 2001 From: Markus Legner Date: Fri, 6 Oct 2023 17:53:18 +0200 Subject: [PATCH] chore: run clippy with and w/o tests --- .github/workflows/rust.yml | 4 +++- .pre-commit-config.yaml | 9 ++++++++- crates/scion/src/reliable/common_header.rs | 5 +++++ crates/scion/src/reliable/registration.rs | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e5ae242..97704ad 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -152,7 +152,9 @@ jobs: --config group_imports=StdExternalCrate,imports_granularity=Crate,imports_layout=HorizontalVertical - name: Check sorting of dependencies run: cargo sort -w -c - - name: Lint using clippy + - name: Lint using clippy (w/o tests) + run: cargo clippy --all-features --no-deps -- -D warnings + - name: Lint using clippy (w/ tests) run: cargo clippy --all-features --tests --no-deps -- -D warnings build: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a57cccc..257146d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,10 +45,17 @@ repos: language: system types: [rust] pass_filenames: false + - id: clippy-with-tests + name: clippy-with-tests + entry: cargo clippy + args: ["--all-features", "--tests", "--", "-D", "warnings"] + language: system + types: [rust] + pass_filenames: false - id: clippy name: clippy entry: cargo clippy - args: ["--all-features", "--tests", "--", "-D", "warnings"] + args: ["--all-features", "--", "-D", "warnings"] language: system types: [rust] pass_filenames: false diff --git a/crates/scion/src/reliable/common_header.rs b/crates/scion/src/reliable/common_header.rs index 69a5fb5..a53d932 100644 --- a/crates/scion/src/reliable/common_header.rs +++ b/crates/scion/src/reliable/common_header.rs @@ -26,6 +26,7 @@ pub enum DecodeError { } /// Partial or fully decoded commonHeader +#[allow(dead_code)] pub(super) enum DecodedHeader { Partial(PartialHeader), Full(CommonHeader), @@ -76,6 +77,7 @@ impl PartialHeader { } /// Number of bytes required to finish decoding the full common header. + #[allow(dead_code)] pub fn required_bytes(&self) -> usize { encoded_address_and_port_length(self.host_type) } @@ -85,6 +87,7 @@ impl PartialHeader { /// # Panics /// /// Panics if there is not at least self.required_bytes() available in the buffer. + #[allow(dead_code)] pub fn finish_decoding(self, buffer: &mut impl Buf) -> CommonHeader { assert!( buffer.remaining() >= self.required_bytes(), @@ -188,6 +191,7 @@ impl CommonHeader { /// /// Panics if there is not at least [`CommonHeader::MIN_LENGTH`] bytes available /// in the buffer. + #[allow(dead_code)] pub fn partial_decode(buffer: &mut impl Buf) -> Result { assert!( buffer.remaining() >= CommonHeader::MIN_LENGTH, @@ -210,6 +214,7 @@ impl CommonHeader { /// Panics if there is insufficient data in the buffer to decode the entire header. /// To avoid the panic, ensure there is [`Self::MAX_LENGTH`] bytes available, or /// use [`Self::partial_decode()`] instead. + #[allow(dead_code)] pub fn decode(buffer: &mut impl Buf) -> Result { PartialHeader::decode(buffer).map(|header| header.finish_decoding(buffer)) } diff --git a/crates/scion/src/reliable/registration.rs b/crates/scion/src/reliable/registration.rs index 30ddf95..7580c89 100644 --- a/crates/scion/src/reliable/registration.rs +++ b/crates/scion/src/reliable/registration.rs @@ -50,6 +50,7 @@ pub(super) struct RegistrationRequest { impl RegistrationRequest { /// Return a new registration request for the specified IsdAsn and public address. + #[allow(dead_code)] pub fn new(isd_asn: IsdAsn, public_address: SocketAddr) -> Self { Self { isd_asn, @@ -67,6 +68,7 @@ impl RegistrationRequest { } /// Add the provided associated service address to the request. + #[allow(dead_code)] pub fn with_associated_service(mut self, address: ServiceAddress) -> Self { self.associated_service = Some(address); self