Skip to content

Commit

Permalink
chore: resolved some clippy::pedantic lints (#254)
Browse files Browse the repository at this point in the history
# Rationale for this change

We have cargo clippy running in our CI in order to enforce code quality.
In order to increase our standards, we should enable the
clippy::pedantic lint group.

# What changes are included in this PR?

Resolved the following lint warnings

`module_name_repetitions`
`wildcard_imports`
`unused_self`
`manual_let_else`
`struct_field_names`
`unicode_not_nfc`                
`manual_string_new`
`large_types_passed_by_value`   

# Are these changes tested?
Yes.
  • Loading branch information
mehulmathur16 authored Oct 11, 2024
1 parent 0634804 commit 61d850c
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 19 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,11 @@ cast_lossless = "deny"
redundant_closure_for_method_calls = "deny"
inconsistent_struct_constructor = "deny"
default_trait_access = "deny"
module_name_repetitions = "deny"
wildcard_imports = "deny"
unused_self = "deny"
manual_let_else = "deny"
struct_field_names = "deny"
unicode_not_nfc = "deny"
manual_string_new = "deny"
large_types_passed_by_value = "deny"
9 changes: 7 additions & 2 deletions crates/proof-of-sql-parser/src/intermediate_ast_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ use crate::{
utility::*,
SelectStatement,
};
use alloc::{borrow::ToOwned, string::ToString, vec};
use alloc::{
borrow::ToOwned,
string::{String, ToString},
vec,
};

// Sting parser tests
#[test]
Expand All @@ -26,7 +30,7 @@ fn we_can_correctly_escape_the_single_quote_character() {

#[test]
fn we_can_parse_empty_strings() {
assert_eq!(StringLiteralParser::new().parse("''"), Ok("".to_string()));
assert_eq!(StringLiteralParser::new().parse("''"), Ok(String::new()));
}

#[test]
Expand Down Expand Up @@ -108,6 +112,7 @@ fn we_can_parse_strings_having_control_characters() {
);
}

#[allow(clippy::unicode_not_nfc)]
#[test]
fn unnormalized_strings_should_differ() {
let lhs = StringLiteralParser::new().parse("'á'").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/proof-of-sql/benches/scaffold/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn jaeger_scaffold<CP: CommitmentEvaluationProof>(
.unwrap();
}

#[allow(dead_code)]
#[allow(dead_code, clippy::module_name_repetitions)]
pub fn criterion_scaffold<CP: CommitmentEvaluationProof>(
c: &mut Criterion,
title: &str,
Expand Down
5 changes: 4 additions & 1 deletion crates/proof-of-sql/examples/hello_world/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

use blitzar::{compute::init_backend, proof::InnerProductProof};
use proof_of_sql::{
base::database::{owned_table_utility::*, OwnedTableTestAccessor, TestAccessor},
base::database::{
owned_table_utility::{bigint, owned_table, varchar},
OwnedTableTestAccessor, TestAccessor,
},
sql::{parse::QueryExpr, proof::QueryProof},
};
use std::{
Expand Down
14 changes: 13 additions & 1 deletion crates/proof-of-sql/src/base/database/owned_column_operation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
use super::{ColumnOperationError, ColumnOperationResult};
use crate::base::{
database::{column_operation::*, OwnedColumn},
database::{
column_operation::{
eq_decimal_columns, ge_decimal_columns, le_decimal_columns, slice_and, slice_eq,
slice_eq_with_casting, slice_ge, slice_ge_with_casting, slice_le,
slice_le_with_casting, slice_not, slice_or, try_add_decimal_columns, try_add_slices,
try_add_slices_with_casting, try_divide_decimal_columns, try_divide_slices,
try_divide_slices_left_upcast, try_divide_slices_right_upcast,
try_multiply_decimal_columns, try_multiply_slices, try_multiply_slices_with_casting,
try_subtract_decimal_columns, try_subtract_slices, try_subtract_slices_left_upcast,
try_subtract_slices_right_upcast,
},
OwnedColumn,
},
scalar::Scalar,
};
use core::ops::{Add, Div, Mul, Sub};
Expand Down
5 changes: 5 additions & 0 deletions crates/proof-of-sql/src/proof_primitive/dory/dory_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ark_ff::Field;
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use num_traits::Zero;

#[allow(clippy::struct_field_names)]
#[derive(Default, Clone, CanonicalSerialize, CanonicalDeserialize, PartialEq, Eq, Debug)]
/// The messages sent from the prover to the verifier in the interactive protocol.
/// This is, in essence, the proof.
Expand Down Expand Up @@ -51,6 +52,8 @@ impl DoryMessages {
transcript.extend_canonical_serialize_as_le(&message);
self.G2_messages.insert(0, message);
}

#[allow(clippy::large_types_passed_by_value)]
/// Pushes a GT element from the prover onto the queue, and appends it to the transcript.
pub(super) fn prover_send_GT_message(&mut self, transcript: &mut impl Transcript, message: GT) {
transcript.extend_canonical_serialize_as_le(&message);
Expand Down Expand Up @@ -102,6 +105,8 @@ impl DoryMessages {
transcript.extend_canonical_serialize_as_le(&message);
message
}

#[allow(clippy::unused_self)]
/// This is the F message that the verifier sends to the prover.
/// This message is produces as a challenge from the transcript.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
use super::{
dory_reduce_helper::*,
extended_dory_reduce_helper::*,
dory_reduce_helper::{
dory_reduce_prove_compute_Cs, dory_reduce_prove_compute_Ds, dory_reduce_prove_fold_v_vecs,
dory_reduce_prove_mutate_v_vecs, dory_reduce_verify_update_C, dory_reduce_verify_update_Ds,
},
extended_dory_reduce_helper::{
extended_dory_reduce_prove_compute_E_betas, extended_dory_reduce_prove_compute_signed_Es,
extended_dory_reduce_prove_fold_s_vecs, extended_dory_reduce_verify_update_Es,
},
extended_state::{ExtendedProverState, ExtendedVerifierState},
DoryMessages, ProverSetup, VerifierSetup,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl DynProofExprBuilder<'_> {
)))
}

#[allow(clippy::unused_self)]
fn visit_literal<C: Commitment>(
&self,
lit: &Literal,
Expand Down
1 change: 1 addition & 0 deletions crates/proof-of-sql/src/sql/parse/query_context_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ impl<'a> QueryContextBuilder<'a> {
}
}

#[allow(clippy::unused_self)]
fn visit_literal(&self, literal: &Literal) -> Result<ColumnType, ConversionError> {
match literal {
Literal::Boolean(_) => Ok(ColumnType::Boolean),
Expand Down
16 changes: 11 additions & 5 deletions crates/proof-of-sql/src/sql/proof_exprs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use multiply_expr::MultiplyExpr;
mod multiply_expr_test;

mod bitwise_verification;
use bitwise_verification::*;
use bitwise_verification::{
is_within_acceptable_range, verify_constant_abs_decomposition,
verify_constant_sign_decomposition,
};
#[cfg(test)]
mod bitwise_verification_test;

Expand All @@ -39,12 +42,12 @@ use and_expr::AndExpr;
mod and_expr_test;

mod inequality_expr;
use inequality_expr::*;
use inequality_expr::InequalityExpr;
#[cfg(all(test, feature = "blitzar"))]
mod inequality_expr_test;

mod or_expr;
use or_expr::*;
use or_expr::{count_or, prover_evaluate_or, result_evaluate_or, verifier_evaluate_or, OrExpr};
#[cfg(all(test, feature = "blitzar"))]
mod or_expr_test;

Expand All @@ -62,12 +65,15 @@ pub(crate) use numerical_util::{
};

mod equals_expr;
use equals_expr::*;
use equals_expr::{
count_equals_zero, prover_evaluate_equals_zero, result_evaluate_equals_zero,
verifier_evaluate_equals_zero, EqualsExpr,
};
#[cfg(all(test, feature = "blitzar"))]
mod equals_expr_test;

mod sign_expr;
use sign_expr::*;
use sign_expr::{count_sign, prover_evaluate_sign, result_evaluate_sign, verifier_evaluate_sign};
#[cfg(all(test, feature = "blitzar"))]
mod sign_expr_test;

Expand Down
11 changes: 4 additions & 7 deletions crates/proof-of-sql/src/sql/proof_plans/filter_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,10 @@ fn verify_filter<C: Commitment>(
) -> Result<(), ProofError> {
let one_eval = builder.mle_evaluations.one_evaluation;

let chi_eval = match builder.mle_evaluations.result_indexes_evaluation {
Some(eval) => eval,
None => {
return Err(ProofError::VerificationError {
error: "Result indexes not valid.",
})
}
let Some(chi_eval) = builder.mle_evaluations.result_indexes_evaluation else {
return Err(ProofError::VerificationError {
error: "Result indexes not valid.",
});
};

let c_fold_eval = alpha * one_eval + fold_vals(beta, c_evals);
Expand Down

0 comments on commit 61d850c

Please sign in to comment.