Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
epi052 committed Dec 13, 2024
1 parent 9c7b74c commit 4401ccb
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 26 deletions.
3 changes: 2 additions & 1 deletion src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ pub enum Action {
impl Action {
/// returns `true` if the action is [`Action::Discard`] or has a flow control
/// directive of [`FlowControl::Discard`]; false otherwise
pub fn should_discard(&self) -> bool {
#[must_use]
pub const fn should_discard(&self) -> bool {
matches!(self, Self::Discard)
|| matches!(self, Action::AddToCorpus(_, _, FlowControl::Discard))
}
Expand Down
11 changes: 5 additions & 6 deletions src/corpora/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,11 @@ where
continue;
}

if let Ok(associated_type) = line.parse() {
// since the associated type `Item` must implement FromStr
// we can call .parse() to convert it into the expected
// type before pushing it onto the container
items.push(associated_type);
}
// since the associated type `Item` must implement FromStr
// we can call .parse() to convert it into the expected
// type before pushing it onto the container. unwrap is safe here
let associated_type = line.parse().unwrap();
items.push(associated_type);
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/corpora/wordlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,11 @@ impl Wordlist {
continue;
}

if let Ok(associated_type) = line.parse() {
// since the associated type `Item` must implement FromStr
// we can call .parse() to convert it into the expected
// type before pushing it onto the container of type T
items.push(associated_type);
}
// since the associated type `Item` must implement FromStr
// we can call .parse() to convert it into the expected
// type before pushing it onto the container. unwrap is safe here
let associated_type = line.parse().unwrap();
items.push(associated_type);
}

Ok(WordlistBuilder {
Expand Down
12 changes: 8 additions & 4 deletions src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ pub struct FuzzNTimes {
}

/// This event is emitted when a fuzzer enters its fuzzing loop via the
/// [`Fuzzer::fuzz_once`] method. If the fuzzer was started with [`Fuzzer::fuzz_n_iterations`]
/// [`Fuzzer::fuzz_once`] method.
///
/// If the fuzzer was started with [`Fuzzer::fuzz_n_iterations`]
/// or [`Fuzzer::fuzz`], this event will be emitted once per iteration.
///
/// [`Fuzzer::fuzz_once`]: crate::fuzzers::AsyncFuzzing::fuzz_once
Expand Down Expand Up @@ -187,9 +189,11 @@ pub struct FuzzOnce {
pub corpora_length: usize,
}

/// This event is emitted when a fuzzer exits the fuzzing loop. This can happen
/// when the fuzzer has iterated over the entire corpus for the specified number
/// of times, or when the fuzzer exits early due to an [`Action::StopFuzzing`]
/// This event is emitted when a fuzzer exits the fuzzing loop.
///
/// This can happen when the fuzzer has iterated over the entire
/// corpus for the specified number of times, or when the fuzzer
/// exits early due to an [`Action::StopFuzzing`]
///
/// [`Action::StopFuzzing`]: crate::actions::Action::StopFuzzing
#[derive(Copy, Default, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down
6 changes: 4 additions & 2 deletions src/processors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ pub enum Ordering {
}

/// marker trait; post-processors are used to perform actions after observations
/// are made and actions are taken. They can be thought of a 'final action' that
/// the fuzzer should perform, i.e. logging/printing etc...
/// are made and actions are taken.
///
/// They can be thought of a 'final action' that the fuzzer should perform,
/// i.e. logging/printing etc...
pub trait Processor: DynClone + AsAny + Named {}

/// defines the hooks that are executed for the purpose of processing
Expand Down
9 changes: 5 additions & 4 deletions src/processors/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ use crate::{actions::Action, responses::Response};
use serde::{Deserialize, Serialize};
use tracing::instrument;

/// a `RequestProcessor` provides access to the fuzzer's mutated [`Request`] that
/// is about to be sent to the target, as well as the [`Action`] returned
/// from calling the analogous hook on [`Deciders`]. Those two objects may
/// be used to produce side-effects, such as printing, logging, etc...
/// a `RequestProcessor` provides access to the fuzzer's mutated [`Request`]
/// and the [`Action`] returned from calling the analogous hook on [`Deciders`].
///
/// Those two objects may be used to produce side-effects, such as printing,
/// logging, etc...
///
/// [`Deciders`]: crate::deciders::Deciders
///
Expand Down
1 change: 1 addition & 0 deletions src/processors/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tracing::instrument;

/// a `ResponseProcessor` provides access to the fuzzer's instance of [`ResponseObserver`]
/// as well as the [`Action`] returned from calling the analogous hook on [`Deciders`].
///
/// Those two objects may be used to produce side-effects, such as printing, logging,
/// etc...
///
Expand Down
1 change: 1 addition & 0 deletions src/processors/statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::sync::{Arc, RwLock};

/// a `StatisticsProcessor` provides access to the fuzzer's instance of [`Statistics`]
/// as well as the [`Action`] returned from calling the analogous hook on [`Deciders`].
///
/// Those two objects may be used to produce side-effects, such as printing, logging,
/// etc...
///
Expand Down
7 changes: 4 additions & 3 deletions src/requests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! provides the core [`Request`] type and the [`ShouldFuzz`] directives that dictate
//! what parts of a `Request` should be mutated. Additionally, a
//! [URL Encoder](./requests/encoders/enum.Encoder.html) is provided by default, while other
//! encoders are available on an opt-in basis via feature flags
//! what parts of a `Request` should be mutated.
//!
//! Additionally, a [URL Encoder](./requests/encoders/enum.Encoder.html) is provided
//! by default, while other encoders are available on an opt-in basis via feature flags
mod directives;
mod encoders;
mod request;
Expand Down

0 comments on commit 4401ccb

Please sign in to comment.