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

Fix clippy CI #84

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Install clippy-sarif and sarif-fmt
run: cargo install clippy-sarif sarif-fmt --locked --git https://github.com/psastras/sarif-rs.git --rev 11c33a53f6ffeaed736856b86fb6b7b09fabdfd8

- name: Cargo clippy
- name: Cargo clippy-sarif
run: cargo clippy --all-features --tests --message-format=json |
clippy-sarif | tee clippy_result.sarif | sarif-fmt
env:
Expand All @@ -49,6 +49,14 @@ jobs:
with:
sarif_file: clippy_result.sarif

# Run it again but this time without the sarif output so that the
# status code of the command is caught and reported as failed in GitHub.
# This should be cached from the previous step and should be fast.
- name: Cargo clippy
run: cargo clippy --all-features --tests
env:
RUSTFLAGS: "-D warnings"
dani-garcia marked this conversation as resolved.
Show resolved Hide resolved

- name: Install cargo-sort
run: cargo install cargo-sort --locked --git https://github.com/DevinR528/cargo-sort.git --rev f5047967021cbb1f822faddc355b3b07674305a1

Expand Down
1 change: 1 addition & 0 deletions crates/bitwarden-core/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const INDIFFERENT: GeneralPurposeConfig =
pub const STANDARD_INDIFFERENT: GeneralPurpose =
GeneralPurpose::new(&alphabet::STANDARD, INDIFFERENT);

#[allow(dead_code)]
#[cfg(test)]
pub async fn start_mock(mocks: Vec<wiremock::Mock>) -> (wiremock::MockServer, crate::Client) {
let server = wiremock::MockServer::start().await;
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-error-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod full;
/// # Attributes
///
/// ## Error type

///
/// - `basic`: The error is converted into a string using the `ToString` trait.
/// - `flat`: The error is converted into a flat structure using the `FlatError` trait.
/// - `full`: The entire error stack is made available using `serde`.
Expand Down
4 changes: 2 additions & 2 deletions crates/bitwarden-fido/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ pub enum Origin {
Android(UnverifiedAssetLink),
}

impl<'a> TryFrom<Origin> for passkey::client::Origin<'a> {
impl TryFrom<Origin> for passkey::client::Origin<'_> {
type Error = InvalidOriginError;

fn try_from(value: Origin) -> Result<Self, Self::Error> {
Expand All @@ -404,7 +404,7 @@ impl<'a> TryFrom<Origin> for passkey::client::Origin<'a> {
}
}

impl<'a> TryFrom<UnverifiedAssetLink> for passkey::client::UnverifiedAssetLink<'a> {
impl TryFrom<UnverifiedAssetLink> for passkey::client::UnverifiedAssetLink<'_> {
type Error = InvalidOriginError;

fn try_from(value: UnverifiedAssetLink) -> Result<Self, Self::Error> {
Expand Down
14 changes: 6 additions & 8 deletions crates/bitwarden-uniffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ pub enum Error {

// Generators
#[error(transparent)]
UsernameError(#[from] UsernameError),
Username(#[from] UsernameError),
#[error(transparent)]
PassphraseError(#[from] PassphraseError),
Passphrase(#[from] PassphraseError),
#[error(transparent)]
PasswordError(#[from] PasswordError),
Password(#[from] PasswordError),

// Vault
#[error(transparent)]
Expand All @@ -61,7 +61,7 @@ pub enum Error {
Totp(#[from] bitwarden_vault::TotpError),

#[error(transparent)]
ExportError(#[from] ExportError),
Export(#[from] ExportError),

// Fido
#[error(transparent)]
Expand All @@ -71,11 +71,9 @@ pub enum Error {
#[error(transparent)]
SilentlyDiscoverCredentials(#[from] bitwarden_fido::SilentlyDiscoverCredentialsError),
#[error(transparent)]
CredentialsForAutofillError(#[from] bitwarden_fido::CredentialsForAutofillError),
CredentialsForAutofill(#[from] bitwarden_fido::CredentialsForAutofillError),
#[error(transparent)]
DecryptFido2AutofillCredentialsError(
#[from] bitwarden_fido::DecryptFido2AutofillCredentialsError,
),
DecryptFido2AutofillCredentials(#[from] bitwarden_fido::DecryptFido2AutofillCredentialsError),
#[error(transparent)]
Fido2Client(#[from] bitwarden_fido::Fido2ClientError),
}
4 changes: 2 additions & 2 deletions crates/bitwarden-uniffi/src/platform/fido2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
.0
.fido2()
.decrypt_fido2_autofill_credentials(cipher_view)
.map_err(Error::DecryptFido2AutofillCredentialsError)?;
.map_err(Error::DecryptFido2AutofillCredentials)?;

Check warning on line 55 in crates/bitwarden-uniffi/src/platform/fido2.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/platform/fido2.rs#L55

Added line #L55 was not covered by tests

Ok(result)
}
Expand Down Expand Up @@ -122,7 +122,7 @@
let result = auth
.credentials_for_autofill()
.await
.map_err(Error::CredentialsForAutofillError)?;
.map_err(Error::CredentialsForAutofill)?;

Check warning on line 125 in crates/bitwarden-uniffi/src/platform/fido2.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/platform/fido2.rs#L125

Added line #L125 was not covered by tests
Ok(result)
}
}
Expand Down
14 changes: 7 additions & 7 deletions crates/bitwarden-uniffi/src/tool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
.0
.generator()
.password(settings)
.map_err(Error::PasswordError)?)
.map_err(Error::Password)?)

Check warning on line 30 in crates/bitwarden-uniffi/src/tool/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/mod.rs#L30

Added line #L30 was not covered by tests
}

/// Generate Passphrase
Expand All @@ -37,7 +37,7 @@
.0
.generator()
.passphrase(settings)
.map_err(Error::PassphraseError)?)
.map_err(Error::Passphrase)?)

Check warning on line 40 in crates/bitwarden-uniffi/src/tool/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/mod.rs#L40

Added line #L40 was not covered by tests
}

/// Generate Username
Expand All @@ -48,7 +48,7 @@
.generator()
.username(settings)
.await
.map_err(Error::UsernameError)?)
.map_err(Error::Username)?)

Check warning on line 51 in crates/bitwarden-uniffi/src/tool/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/mod.rs#L51

Added line #L51 was not covered by tests
}
}

Expand All @@ -69,7 +69,7 @@
.0
.exporters()
.export_vault(folders, ciphers, format)
.map_err(Error::ExportError)?)
.map_err(Error::Export)?)

Check warning on line 72 in crates/bitwarden-uniffi/src/tool/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/mod.rs#L72

Added line #L72 was not covered by tests
}

/// Export organization vault
Expand All @@ -84,7 +84,7 @@
.0
.exporters()
.export_organization_vault(collections, ciphers, format)
.map_err(Error::ExportError)?)
.map_err(Error::Export)?)

Check warning on line 87 in crates/bitwarden-uniffi/src/tool/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/mod.rs#L87

Added line #L87 was not covered by tests
}

/// Credential Exchange Format (CXF)
Expand All @@ -99,7 +99,7 @@
.0
.exporters()
.export_cxf(account, ciphers)
.map_err(Error::ExportError)?)
.map_err(Error::Export)?)

Check warning on line 102 in crates/bitwarden-uniffi/src/tool/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/mod.rs#L102

Added line #L102 was not covered by tests
}

/// Credential Exchange Format (CXF)
Expand All @@ -114,6 +114,6 @@
.0
.exporters()
.import_cxf(payload)
.map_err(Error::ExportError)?)
.map_err(Error::Export)?)

Check warning on line 117 in crates/bitwarden-uniffi/src/tool/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/mod.rs#L117

Added line #L117 was not covered by tests
}
}
2 changes: 1 addition & 1 deletion crates/bitwarden-vault/src/cipher/attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct AttachmentFileView<'a> {
pub contents: &'a [u8],
}

impl<'a> KeyEncryptable<SymmetricCryptoKey, AttachmentEncryptResult> for AttachmentFileView<'a> {
impl KeyEncryptable<SymmetricCryptoKey, AttachmentEncryptResult> for AttachmentFileView<'_> {
fn encrypt_with_key(
self,
key: &SymmetricCryptoKey,
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-vault/src/mobile/client_attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct ClientAttachments<'a> {
pub(crate) client: &'a Client,
}

impl<'a> ClientAttachments<'a> {
impl ClientAttachments<'_> {
pub fn encrypt_buffer(
&self,
cipher: Cipher,
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-vault/src/mobile/client_ciphers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct ClientCiphers<'a> {
pub(crate) client: &'a Client,
}

impl<'a> ClientCiphers<'a> {
impl ClientCiphers<'_> {
pub fn encrypt(&self, mut cipher_view: CipherView) -> Result<Cipher, Error> {
let enc = self.client.internal.get_encryption_settings()?;

Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-vault/src/mobile/client_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct ClientCollections<'a> {
pub(crate) client: &'a Client,
}

impl<'a> ClientCollections<'a> {
impl ClientCollections<'_> {
pub fn decrypt(&self, collection: Collection) -> Result<CollectionView, Error> {
let enc = self.client.internal.get_encryption_settings()?;
let key = collection.locate_key(&enc, &None)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-vault/src/mobile/client_folders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct ClientFolders<'a> {
pub(crate) client: &'a Client,
}

impl<'a> ClientFolders<'a> {
impl ClientFolders<'_> {
pub fn encrypt(&self, folder_view: FolderView) -> Result<Folder, Error> {
let enc = self.client.internal.get_encryption_settings()?;
let key = enc.get_key(&None)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct ClientPasswordHistory<'a> {
pub(crate) client: &'a Client,
}

impl<'a> ClientPasswordHistory<'a> {
impl ClientPasswordHistory<'_> {
pub fn encrypt(&self, history_view: PasswordHistoryView) -> Result<PasswordHistory, Error> {
let enc = self.client.internal.get_encryption_settings()?;
let key = enc.get_key(&None)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-wasm-internal/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
env!("SDK_VERSION").to_owned()
}

pub async fn throw(&self, msg: String) -> Result<(), TestError> {
pub fn throw(&self, msg: String) -> Result<(), TestError> {

Check warning on line 57 in crates/bitwarden-wasm-internal/src/client.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-wasm-internal/src/client.rs#L57

Added line #L57 was not covered by tests
Err(TestError(msg))
}

Expand Down
Loading