Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: check rustfmt and clippy in Rust build #220

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,21 @@ jobs:

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy, rustfmt

- name: Set up CI
run: cd prototype && make setup-ci
- name: Integrate bridge
run: cd prototype && make frb-integrate
- name: Build

- name: Rustfmt
run: cargo fmt -- --check
- name: Clippy
# Note: this also verifies that the lock file is up to date
run: cargo clippy --locked --all-targets
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
1 change: 1 addition & 0 deletions applogic/src/api/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ impl From<ConversationMessage> for UiConversationMessage {
}
}

#[expect(clippy::large_enum_variant)]
#[derive(PartialEq, Debug, Clone)]
pub enum UiMessage {
ContentFlight(Vec<UiContentMessage>),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified backend/scripts/generate_test_certs.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion backend/src/auth_service/privacy_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<'a, 'b> AuthServiceBatchedKeyStoreProvider<'a, 'b> {
}

#[async_trait]
impl<'a, 'b> BatchedKeyStore for AuthServiceBatchedKeyStoreProvider<'a, 'b> {
impl BatchedKeyStore for AuthServiceBatchedKeyStoreProvider<'_, '_> {
/// Inserts a keypair with a given `truncated_token_key_id` into the key store.
async fn insert(
&self,
Expand Down
1 change: 1 addition & 0 deletions backend/src/ds/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ pub struct ExternalCommitInfo {
pub encrypted_client_info: Vec<(EncryptedClientCredential, EncryptedSignatureEarKey)>,
}

#[expect(clippy::large_enum_variant)]
#[derive(Debug, TlsSerialize, TlsSize)]
#[repr(u8)]
pub enum DsProcessResponse {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/qs/add_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mod persistence {

for (i, encrypted_add_package) in encrypted_add_packages.into_iter().enumerate() {
// Add values to the query arguments. None of these should throw an error.
query_args.add(&client_id)?;
query_args.add(client_id)?;
query_args.add(&*encrypted_add_package)?;
query_args.add(is_last_resort)?;

Expand Down Expand Up @@ -99,7 +99,7 @@ mod persistence {
r#"WITH deleted_package AS (
DELETE FROM key_packages
USING qs_client_records qcr
WHERE
WHERE
key_packages.client_id = qcr.client_id
AND key_packages.client_id = $1
AND qcr.user_id = $2
Expand Down
48 changes: 24 additions & 24 deletions backend/src/qs/client_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub(super) struct QsClientRecord {
}

impl QsClientRecord {
#[expect(clippy::too_many_arguments)]
pub(super) async fn new_and_store(
connection: &mut PgConnection,
rng: &mut (impl CryptoRng + RngCore),
Expand Down Expand Up @@ -109,11 +110,11 @@ mod persistence {
let ratchet = PhnxCodec::to_vec(&self.ratchet_key)?;

sqlx::query!(
"INSERT INTO
qs_client_records
(client_id, user_id, encrypted_push_token, owner_public_key, owner_signature_key, ratchet, activity_time)
VALUES
($1, $2, $3, $4, $5, $6, $7)",
"INSERT INTO
qs_client_records
(client_id, user_id, encrypted_push_token, owner_public_key, owner_signature_key, ratchet, activity_time)
VALUES
($1, $2, $3, $4, $5, $6, $7)",
&self.client_id as &QsClientId,
&self.user_id as &QsUserId,
self.encrypted_push_token.as_ref() as Option<&EncryptedPushToken>,
Expand All @@ -134,16 +135,16 @@ mod persistence {
) -> Result<Option<QsClientRecord>, StorageError> {
let client_id = client_id.as_uuid();
sqlx::query!(
r#"SELECT
user_id as "user_id: QsUserId",
encrypted_push_token as "encrypted_push_token: EncryptedPushToken",
owner_public_key,
owner_signature_key,
ratchet,
r#"SELECT
user_id as "user_id: QsUserId",
encrypted_push_token as "encrypted_push_token: EncryptedPushToken",
owner_public_key,
owner_signature_key,
ratchet,
activity_time as "activity_time: TimeStamp"
FROM
qs_client_records
WHERE
FROM
qs_client_records
WHERE
client_id = $1"#,
client_id,
)
Expand All @@ -152,12 +153,11 @@ mod persistence {
.map(|record| {
let owner_public_key = PhnxCodec::from_slice(&record.owner_public_key)?;
let owner_signature_key = PhnxCodec::from_slice(&record.owner_signature_key)?;
let ratchet = PhnxCodec::from_slice(&record.ratchet)?;
let ratchet_key = QueueRatchet::from(ratchet);
let ratchet_key = PhnxCodec::from_slice(&record.ratchet)?;

Ok(QsClientRecord {
user_id: record.user_id,
client_id: client_id.clone().into(),
client_id: (*client_id).into(),
encrypted_push_token: record.encrypted_push_token,
queue_encryption_key: owner_public_key,
auth_key: owner_signature_key,
Expand All @@ -178,13 +178,13 @@ mod persistence {

sqlx::query!(
"UPDATE qs_client_records
SET
encrypted_push_token = $1,
owner_public_key = $2,
owner_signature_key = $3,
ratchet = $4,
activity_time = $5
WHERE
SET
encrypted_push_token = $1,
owner_public_key = $2,
owner_signature_key = $3,
ratchet = $4,
activity_time = $5
WHERE
client_id = $6",
self.encrypted_push_token.as_ref() as Option<&EncryptedPushToken>,
owner_public_key,
Expand Down
2 changes: 1 addition & 1 deletion coreclient/src/contacts/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl Contact {
}
}

pub(crate) const PARTIAL_CONTACT_INSERT_TRIGGER: &str =
pub(crate) const PARTIAL_CONTACT_INSERT_TRIGGER: &str =
"DROP TRIGGER IF EXISTS no_partial_contact_overlap_on_insert;

CREATE TRIGGER no_partial_contact_overlap_on_insert
Expand Down
4 changes: 3 additions & 1 deletion coreclient/src/conversations/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl TimestampedMessage {
}

/// Mark the message as sent and update the timestamp. If the message was
/// already marked as sent, nothing happens.
/// already marked as sent, nothing happens.
pub(super) fn mark_as_sent(&mut self, ds_timestamp: TimeStamp) {
if let Message::Content(content) = &mut self.message {
self.timestamp = ds_timestamp;
Expand Down Expand Up @@ -177,6 +177,7 @@ impl ConversationMessage {

// WARNING: If this type is changed, a new `VersionedMessage` variant must be
// introduced and the storage logic changed accordingly.
#[expect(clippy::large_enum_variant)]
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
pub enum Message {
Content(ContentMessage),
Expand Down Expand Up @@ -295,6 +296,7 @@ impl ErrorMessage {
}
}

#[expect(clippy::large_enum_variant)]
#[derive(Debug, Clone)]
pub enum NotificationType {
ConversationChange(ConversationId), // The id of the changed conversation.
Expand Down
4 changes: 2 additions & 2 deletions coreclient/src/groups/client_auth_info/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ impl Storable for GroupMembership {
}
}

pub(crate) const GROUP_MEMBERSHIP_TRIGGER: &str =
"CREATE TRIGGER IF NOT EXISTS delete_orphaned_data
pub(crate) const GROUP_MEMBERSHIP_TRIGGER: &str =
"CREATE TRIGGER IF NOT EXISTS delete_orphaned_data
AFTER DELETE ON group_membership
FOR EACH ROW
BEGIN
Expand Down
4 changes: 2 additions & 2 deletions coreclient/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ impl Group {
remove.remove_proposal().removed(),
)?;
}
let commit = AssistedMessageOut::new(mls_message, Some(group_info.into()))?;
let commit = AssistedMessageOut::new(mls_message, Some(group_info))?;
Ok(UpdateClientParamsOut {
commit,
sender: self.mls_group.own_leaf_index(),
Expand Down Expand Up @@ -1404,7 +1404,7 @@ impl Group {
diff.user_auth_key = Some(user_auth_signing_key);
self.pending_diff = Some(diff.stage());

let commit = AssistedMessageOut::new(commit, Some(group_info.into()))?;
let commit = AssistedMessageOut::new(commit, Some(group_info))?;
let params = UpdateClientParamsOut {
commit,
sender: self.mls_group.own_leaf_index(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ pub(crate) struct StorableEncryptionKeyPairRef<'a, EncryptionKeyPair: Entity<CUR
pub &'a EncryptionKeyPair,
);

impl<'a, EncryptionKeyPair: Entity<CURRENT_VERSION>>
StorableEncryptionKeyPairRef<'a, EncryptionKeyPair>
impl<EncryptionKeyPair: Entity<CURRENT_VERSION>>
StorableEncryptionKeyPairRef<'_, EncryptionKeyPair>
{
pub(super) fn store<EncryptionKey: Key<CURRENT_VERSION>>(
&self,
Expand All @@ -67,8 +67,8 @@ pub(crate) struct StorableEncryptionPublicKeyRef<'a, EncryptionPublicKey: Key<CU
pub &'a EncryptionPublicKey,
);

impl<'a, EncryptionPublicKey: Key<CURRENT_VERSION>>
StorableEncryptionPublicKeyRef<'a, EncryptionPublicKey>
impl<EncryptionPublicKey: Key<CURRENT_VERSION>>
StorableEncryptionPublicKeyRef<'_, EncryptionPublicKey>
{
pub(super) fn delete(&self, connection: &rusqlite::Connection) -> Result<(), rusqlite::Error> {
connection.execute(
Expand Down
4 changes: 2 additions & 2 deletions coreclient/src/groups/openmls_provider/epoch_key_pairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub(super) struct StorableEpochKeyPairsRef<'a, EpochKeyPairs: Entity<CURRENT_VER
pub &'a [EpochKeyPairs],
);

impl<'a, EpochKeyPairs: Entity<CURRENT_VERSION>> StorableEpochKeyPairsRef<'a, EpochKeyPairs> {
impl<EpochKeyPairs: Entity<CURRENT_VERSION>> StorableEpochKeyPairsRef<'_, EpochKeyPairs> {
pub(super) fn store<GroupId: Key<CURRENT_VERSION>, EpochKey: Key<CURRENT_VERSION>>(
&self,
connection: &rusqlite::Connection,
Expand All @@ -71,7 +71,7 @@ impl<'a, EpochKeyPairs: Entity<CURRENT_VERSION>> StorableEpochKeyPairsRef<'a, Ep
}
}

impl<'a, GroupId: Key<CURRENT_VERSION>> StorableGroupIdRef<'a, GroupId> {
impl<GroupId: Key<CURRENT_VERSION>> StorableGroupIdRef<'_, GroupId> {
pub(super) fn delete_epoch_key_pair<EpochKey: Key<CURRENT_VERSION>>(
&self,
connection: &rusqlite::Connection,
Expand Down
4 changes: 2 additions & 2 deletions coreclient/src/groups/openmls_provider/group_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<GroupData: Entity<CURRENT_VERSION>> StorableGroupData<GroupData> {
}
}

impl<'a, GroupData: Entity<CURRENT_VERSION>> StorableGroupDataRef<'a, GroupData> {
impl<GroupData: Entity<CURRENT_VERSION>> StorableGroupDataRef<'_, GroupData> {
pub(super) fn store<GroupId: Key<CURRENT_VERSION>>(
&self,
connection: &Connection,
Expand All @@ -122,7 +122,7 @@ impl<'a, GroupData: Entity<CURRENT_VERSION>> StorableGroupDataRef<'a, GroupData>
}
}

impl<'a, GroupId: Key<CURRENT_VERSION>> StorableGroupIdRef<'a, GroupId> {
impl<GroupId: Key<CURRENT_VERSION>> StorableGroupIdRef<'_, GroupId> {
pub(super) fn delete_group_data(
&self,
connection: &Connection,
Expand Down
4 changes: 2 additions & 2 deletions coreclient/src/groups/openmls_provider/key_packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub(super) struct StorableKeyPackageRef<'a, KeyPackage: Entity<CURRENT_VERSION>>
pub &'a KeyPackage,
);

impl<'a, KeyPackage: Entity<CURRENT_VERSION>> StorableKeyPackageRef<'a, KeyPackage> {
impl<KeyPackage: Entity<CURRENT_VERSION>> StorableKeyPackageRef<'_, KeyPackage> {
pub(super) fn store<KeyPackageRef: Key<CURRENT_VERSION>>(
&self,
connection: &rusqlite::Connection,
Expand All @@ -58,7 +58,7 @@ impl<'a, KeyPackage: Entity<CURRENT_VERSION>> StorableKeyPackageRef<'a, KeyPacka

pub(super) struct StorableHashRef<'a, KeyPackageRef: Key<CURRENT_VERSION>>(pub &'a KeyPackageRef);

impl<'a, KeyPackageRef: Key<CURRENT_VERSION>> StorableHashRef<'a, KeyPackageRef> {
impl<KeyPackageRef: Key<CURRENT_VERSION>> StorableHashRef<'_, KeyPackageRef> {
pub(super) fn delete_key_package(
&self,
connection: &rusqlite::Connection,
Expand Down
2 changes: 1 addition & 1 deletion coreclient/src/groups/openmls_provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<'a> OpenMlsProvider for PhnxOpenMlsProvider<'a> {
}
}

impl<'a> OpenMlsRand for PhnxOpenMlsProvider<'a> {
impl OpenMlsRand for PhnxOpenMlsProvider<'_> {
type Error = PhnxRandomnessError;

fn random_array<const N: usize>(&self) -> std::result::Result<[u8; N], Self::Error> {
Expand Down
4 changes: 2 additions & 2 deletions coreclient/src/groups/openmls_provider/own_leaf_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<LeafNode: Entity<CURRENT_VERSION>> StorableLeafNode<LeafNode> {

pub(crate) struct StorableLeafNodeRef<'a, LeafNode: Entity<CURRENT_VERSION>>(pub &'a LeafNode);

impl<'a, LeafNode: Entity<CURRENT_VERSION>> StorableLeafNodeRef<'a, LeafNode> {
impl<LeafNode: Entity<CURRENT_VERSION>> StorableLeafNodeRef<'_, LeafNode> {
pub(super) fn store<GroupId: Key<CURRENT_VERSION>>(
&self,
connection: &rusqlite::Connection,
Expand All @@ -55,7 +55,7 @@ impl<'a, LeafNode: Entity<CURRENT_VERSION>> StorableLeafNodeRef<'a, LeafNode> {
}
}

impl<'a, GroupId: Key<CURRENT_VERSION>> StorableGroupIdRef<'a, GroupId> {
impl<GroupId: Key<CURRENT_VERSION>> StorableGroupIdRef<'_, GroupId> {
pub(super) fn delete_leaf_nodes(
&self,
connection: &rusqlite::Connection,
Expand Down
6 changes: 3 additions & 3 deletions coreclient/src/groups/openmls_provider/proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ pub(super) struct StorableProposalRef<
ProposalRef: Entity<CURRENT_VERSION>,
>(pub &'a ProposalRef, pub &'a Proposal);

impl<'a, Proposal: Entity<CURRENT_VERSION>, ProposalRef: Entity<CURRENT_VERSION>>
StorableProposalRef<'a, Proposal, ProposalRef>
impl<Proposal: Entity<CURRENT_VERSION>, ProposalRef: Entity<CURRENT_VERSION>>
StorableProposalRef<'_, Proposal, ProposalRef>
{
pub(super) fn store<GroupId: Key<CURRENT_VERSION>>(
&self,
Expand All @@ -92,7 +92,7 @@ impl<'a, Proposal: Entity<CURRENT_VERSION>, ProposalRef: Entity<CURRENT_VERSION>
}
}

impl<'a, GroupId: Key<CURRENT_VERSION>> StorableGroupIdRef<'a, GroupId> {
impl<GroupId: Key<CURRENT_VERSION>> StorableGroupIdRef<'_, GroupId> {
pub(super) fn delete_all_proposals(
&self,
connection: &rusqlite::Connection,
Expand Down
Loading
Loading