Skip to content

Commit

Permalink
fix_clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
epompeii committed Oct 20, 2024
1 parent 38804d8 commit 9dacef9
Show file tree
Hide file tree
Showing 38 changed files with 99 additions and 93 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ variant_size_differences = "warn"

[workspace.lints.clippy]
# https://github.com/rust-lang/rust-clippy
all = "warn"
all = { level = "warn", priority = -1 }
# cargo
cargo = { level = "warn", priority = -1 }
cargo_common_metadata = "allow" # Checks to see if all common metadata is defined in Cargo.toml.
multiple_crate_versions = "allow" # Checks to see if multiple versions of a crate are being used.
# pedantic
pedantic = "warn"
missing_errors_doc = "allow" # Checks the doc comments of publicly visible functions that return a Result type and warns if there is no # Errors section.
missing_panics_doc = "allow" # Checks the doc comments of publicly visible functions that may panic and warns if there is no # Panics section.
module_name_repetitions = "allow" # Detects type names that are prefixed or suffixed by the containing module’s name.
must_use_candidate = "allow" # Checks for public functions that have no #[must_use] attribute, but return something not already marked must-use, have no mutable arg and mutate no statics.
pedantic = { level = "warn", priority = -1 }
missing_errors_doc = "allow" # Checks the doc comments of publicly visible functions that return a Result type and warns if there is no # Errors section.
missing_panics_doc = "allow" # Checks the doc comments of publicly visible functions that may panic and warns if there is no # Panics section.
module_name_repetitions = "allow" # Detects type names that are prefixed or suffixed by the containing module’s name.
must_use_candidate = "allow" # Checks for public functions that have no #[must_use] attribute, but return something not already marked must-use, have no mutable arg and mutate no statics.
# restriction
absolute_paths = "warn" # Checks for usage of items through absolute paths, like std::env::current_dir.
as_underscore = "warn" # Checks for the usage of as _ conversion using inferred type.
Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_adapter/src/adapters/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ impl Visitor<'_> for UnitsVisitor {
formatter.write_str("a standard unit abbreviation")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
value.parse().map_err(E::custom)
v.parse().map_err(E::custom)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_adapter/src/results/adapter_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ impl AdapterResults {
impl std::ops::Add for AdapterResults {
type Output = Self;

fn add(self, other: Self) -> Self {
self.combined(other, CombinedKind::Add)
fn add(self, rhs: Self) -> Self {
self.combined(rhs, CombinedKind::Add)
}
}

Expand Down
5 changes: 3 additions & 2 deletions lib/bencher_client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ fn main() {
let ast = syn::parse2(tokens).unwrap();
let content = prettyplease::unparse(&ast);

let mut out_file = Path::new(&std::env::var("OUT_DIR").unwrap()).to_path_buf();
out_file.push("codegen.rs");
let out_file = Path::new(&std::env::var("OUT_DIR").unwrap())
.to_path_buf()
.join("codegen.rs");

#[cfg(unix)]
{
Expand Down
5 changes: 3 additions & 2 deletions lib/bencher_client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl BencherClient {
/// # Parameters
///
/// - `sender`: A function that takes a `codegen::Client` and returns a `Future` that resolves
/// to a `Result` containing a `serde_json::Value` or an `Error`
/// to a `Result` containing a `serde_json::Value` or an `Error`
///
/// # Returns
///
Expand Down Expand Up @@ -141,7 +141,7 @@ impl BencherClient {
/// # Parameters
///
/// - `sender`: A function that takes a `codegen::Client` and returns a `Future` that resolves
/// to a `Result` containing a `ResponseValue` or an `Error`
/// to a `Result` containing a `ResponseValue` or an `Error`
///
/// # Returns
///
Expand Down Expand Up @@ -260,6 +260,7 @@ impl BencherClient {
Err(ClientError::SendTimeout(attempts))
}

#[allow(clippy::result_large_err)]
fn log<T>(&self, response: &T) -> Result<(), ClientError>
where
T: Serialize,
Expand Down
8 changes: 4 additions & 4 deletions lib/bencher_json/src/project/metric/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ impl Ord for JsonNewMetric {
impl Add for JsonNewMetric {
type Output = Self;

fn add(self, other: Self) -> Self {
let value = self.value + other.value;
let lower_value = option_add(self.lower_value, self.value, other.lower_value, other.value);
let upper_value = option_add(self.upper_value, self.value, other.upper_value, other.value);
fn add(self, rhs: Self) -> Self {
let value = self.value + rhs.value;
let lower_value = option_add(self.lower_value, self.value, rhs.lower_value, rhs.value);
let upper_value = option_add(self.upper_value, self.value, rhs.upper_value, rhs.value);
Self {
value,
lower_value,
Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/benchmark_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ impl Visitor<'_> for BenchmarkNameVisitor {
formatter.write_str("a valid benchmark name")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
value.parse().map_err(E::custom)
v.parse().map_err(E::custom)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/branch_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ impl Visitor<'_> for BranchNameVisitor {
formatter.write_str("a valid branch name")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
value.parse().map_err(E::custom)
v.parse().map_err(E::custom)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ impl Visitor<'_> for DateTimeMillisVisitor {
formatter.write_str("a date time timestamp in milliseconds")
}

fn visit_i64<E>(self, value: i64) -> Result<Self::Value, E>
fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>
where
E: de::Error,
{
value.try_into().map_err(E::custom)
v.try_into().map_err(E::custom)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ impl Visitor<'_> for EmailVisitor {
formatter.write_str("a valid email")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
value.parse().map_err(E::custom)
v.parse().map_err(E::custom)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/git_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ impl Visitor<'_> for GitHashVisitor {
formatter.write_str("a valid git_hash")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
value.parse().map_err(E::custom)
v.parse().map_err(E::custom)
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/bencher_valid/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ impl Visitor<'_> for IndexVisitor {
formatter.write_str("a plot index greater than or equal to 0 and less than or equal to 64")
}

fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
self.visit_u8(u8::try_from(value).map_err(E::custom)?)
self.visit_u8(u8::try_from(v).map_err(E::custom)?)
}

fn visit_u8<E>(self, value: u8) -> Result<Self::Value, E>
fn visit_u8<E>(self, v: u8) -> Result<Self::Value, E>
where
E: de::Error,
{
value.try_into().map_err(E::custom)
v.try_into().map_err(E::custom)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ impl Visitor<'_> for JwtVisitor {
formatter.write_str("a valid jwt")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
value.parse().map_err(E::custom)
v.parse().map_err(E::custom)
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/bencher_valid/src/model/boundary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ impl Visitor<'_> for BoundaryVisitor {
formatter.write_str("a floating point boundary")
}

fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
#[allow(clippy::cast_precision_loss)]
(value as f64).try_into().map_err(E::custom)
(v as f64).try_into().map_err(E::custom)
}

fn visit_f64<E>(self, value: f64) -> Result<Self::Value, E>
fn visit_f64<E>(self, v: f64) -> Result<Self::Value, E>
where
E: de::Error,
{
value.try_into().map_err(E::custom)
v.try_into().map_err(E::custom)
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/bencher_valid/src/model/sample_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,18 @@ impl Visitor<'_> for SampleSizeVisitor {
formatter.write_str("a model sample size greater than or equal to 2")
}

fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
self.visit_u32(u32::try_from(value).map_err(E::custom)?)
self.visit_u32(u32::try_from(v).map_err(E::custom)?)
}

fn visit_u32<E>(self, value: u32) -> Result<Self::Value, E>
fn visit_u32<E>(self, v: u32) -> Result<Self::Value, E>
where
E: de::Error,
{
value.try_into().map_err(E::custom)
v.try_into().map_err(E::custom)
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/bencher_valid/src/model/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ impl Visitor<'_> for WindowVisitor {
formatter.write_str("a model window greater than or equal to 1")
}

fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
self.visit_u32(u32::try_from(value).map_err(E::custom)?)
self.visit_u32(u32::try_from(v).map_err(E::custom)?)
}

fn visit_u32<E>(self, value: u32) -> Result<Self::Value, E>
fn visit_u32<E>(self, v: u32) -> Result<Self::Value, E>
where
E: de::Error,
{
value.try_into().map_err(E::custom)
v.try_into().map_err(E::custom)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/name_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ impl Visitor<'_> for NameIdVisitor {
formatter.write_str("a valid UUID or slug.")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
NameId::from_str(value).map_err(|_e| E::invalid_value(Unexpected::Str(value), &self))
NameId::from_str(v).map_err(|_e| E::invalid_value(Unexpected::Str(v), &self))
}
}
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/non_empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ impl Visitor<'_> for NonEmptyVisitor {
formatter.write_str("a non-empty string")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
value.parse().map_err(E::custom)
v.parse().map_err(E::custom)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/plus/brand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ impl Visitor<'_> for CardBrandVisitor {
formatter.write_str("a valid payment card brand")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
value.parse().map_err(E::custom)
v.parse().map_err(E::custom)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/plus/cvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ impl Visitor<'_> for CardCvcVisitor {
formatter.write_str("a valid payment card CVC")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
value.parse().map_err(E::custom)
v.parse().map_err(E::custom)
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/bencher_valid/src/plus/entitlements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ impl Visitor<'_> for EntitlementsVisitor {
formatter.write_str("an integer greater than zero")
}

fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
self.visit_u32(u32::try_from(value).map_err(E::custom)?)
self.visit_u32(u32::try_from(v).map_err(E::custom)?)
}

fn visit_u32<E>(self, value: u32) -> Result<Self::Value, E>
fn visit_u32<E>(self, v: u32) -> Result<Self::Value, E>
where
E: de::Error,
{
value.try_into().map_err(E::custom)
v.try_into().map_err(E::custom)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_valid/src/plus/last_four.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ impl Visitor<'_> for LastFourVisitor {
formatter.write_str("a valid payment card last four numbers")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
value.parse().map_err(E::custom)
v.parse().map_err(E::custom)
}
}

Expand Down
Loading

0 comments on commit 9dacef9

Please sign in to comment.