Skip to content

Commit

Permalink
chore: run clippy with and w/o tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mlegner committed Oct 6, 2023
1 parent 8342c13 commit b01fff7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions crates/scion/src/reliable/common_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub enum DecodeError {
}

/// Partial or fully decoded commonHeader
#[allow(dead_code)]
pub(super) enum DecodedHeader {
Partial(PartialHeader),
Full(CommonHeader),
Expand Down Expand Up @@ -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)
}
Expand All @@ -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(),
Expand Down Expand Up @@ -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<DecodedHeader, DecodeError> {
assert!(
buffer.remaining() >= CommonHeader::MIN_LENGTH,
Expand All @@ -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<Self, DecodeError> {
PartialHeader::decode(buffer).map(|header| header.finish_decoding(buffer))
}
Expand Down
2 changes: 2 additions & 0 deletions crates/scion/src/reliable/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit b01fff7

Please sign in to comment.