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

Deny unused async #838

Merged
merged 2 commits into from
Jun 13, 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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.5.0
bitwarden-vault = { path = "crates/bitwarden-vault", version = "=0.5.0" }

[workspace.lints.clippy]
unused_async = "deny"
unwrap_used = "deny"

# Compile all dependencies with some optimizations when building this crate on debug
Expand Down
2 changes: 0 additions & 2 deletions crates/bitwarden-uniffi/src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ impl ClientAuth {
.await
.auth()
.password_strength(password, email, additional_inputs)
.await
}

/// Evaluate if the provided password satisfies the provided policy
Expand All @@ -42,7 +41,6 @@ impl ClientAuth {
.await
.auth()
.satisfies_policy(password, strength, &policy)
.await
}

/// Hash the user password
Expand Down
8 changes: 3 additions & 5 deletions crates/bitwarden-uniffi/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@
.write()
.await
.crypto()
.update_password(new_password)
.await?)
.update_password(new_password)?)

Check warning on line 63 in crates/bitwarden-uniffi/src/crypto.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/crypto.rs#L63

Added line #L63 was not covered by tests
}

/// Generates a PIN protected user key from the provided PIN. The result can be stored and later
/// used to initialize another client instance by using the PIN and the PIN key with
/// `initialize_user_crypto`.
pub async fn derive_pin_key(&self, pin: String) -> Result<DerivePinKeyResponse> {
Ok(self.0 .0.write().await.crypto().derive_pin_key(pin).await?)
Ok(self.0 .0.write().await.crypto().derive_pin_key(pin)?)

Check warning on line 70 in crates/bitwarden-uniffi/src/crypto.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/crypto.rs#L70

Added line #L70 was not covered by tests
}

/// Derives the pin protected user key from encrypted pin. Used when pin requires master
Expand All @@ -80,8 +79,7 @@
.write()
.await
.crypto()
.derive_pin_user_key(encrypted_pin)
.await?)
.derive_pin_user_key(encrypted_pin)?)

Check warning on line 82 in crates/bitwarden-uniffi/src/crypto.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/crypto.rs#L82

Added line #L82 was not covered by tests
}

pub async fn enroll_admin_password_reset(
Expand Down
24 changes: 4 additions & 20 deletions crates/bitwarden-uniffi/src/tool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,12 @@
impl ClientGenerators {
/// **API Draft:** Generate Password
pub async fn password(&self, settings: PasswordGeneratorRequest) -> Result<String> {
Ok(self
.0
.0
.read()
.await
.generator()
.password(settings)
.await?)
Ok(self.0 .0.read().await.generator().password(settings)?)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L21 was not covered by tests
}

/// **API Draft:** Generate Passphrase
pub async fn passphrase(&self, settings: PassphraseGeneratorRequest) -> Result<String> {
Ok(self
.0
.0
.read()
.await
.generator()
.passphrase(settings)
.await?)
Ok(self.0 .0.read().await.generator().passphrase(settings)?)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L26 was not covered by tests
}

/// **API Draft:** Generate Username
Expand Down Expand Up @@ -71,8 +57,7 @@
.read()
.await
.exporters()
.export_vault(folders, ciphers, format)
.await?)
.export_vault(folders, ciphers, format)?)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L60 was not covered by tests
}

/// **API Draft:** Export organization vault
Expand All @@ -88,7 +73,6 @@
.read()
.await
.exporters()
.export_organization_vault(collections, ciphers, format)
.await?)
.export_organization_vault(collections, ciphers, format)?)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L76 was not covered by tests
}
}
46 changes: 15 additions & 31 deletions crates/bitwarden-uniffi/src/tool/sends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
impl ClientSends {
/// Encrypt send
pub async fn encrypt(&self, send: SendView) -> Result<Send> {
Ok(self.0 .0.write().await.sends().encrypt(send).await?)
Ok(self.0 .0.write().await.sends().encrypt(send)?)

Check warning on line 14 in crates/bitwarden-uniffi/src/tool/sends.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/sends.rs#L14

Added line #L14 was not covered by tests
}

/// Encrypt a send file in memory
Expand All @@ -22,8 +22,7 @@
.write()
.await
.sends()
.encrypt_buffer(send, &buffer)
.await?)
.encrypt_buffer(send, &buffer)?)

Check warning on line 25 in crates/bitwarden-uniffi/src/tool/sends.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/sends.rs#L25

Added line #L25 was not covered by tests
}

/// Encrypt a send file located in the file system
Expand All @@ -33,28 +32,21 @@
decrypted_file_path: String,
encrypted_file_path: String,
) -> Result<()> {
Ok(self
.0
.0
.write()
.await
.sends()
.encrypt_file(
send,
Path::new(&decrypted_file_path),
Path::new(&encrypted_file_path),
)
.await?)
Ok(self.0 .0.write().await.sends().encrypt_file(
send,
Path::new(&decrypted_file_path),
Path::new(&encrypted_file_path),
)?)

Check warning on line 39 in crates/bitwarden-uniffi/src/tool/sends.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/sends.rs#L35-L39

Added lines #L35 - L39 were not covered by tests
}

/// Decrypt send
pub async fn decrypt(&self, send: Send) -> Result<SendView> {
Ok(self.0 .0.write().await.sends().decrypt(send).await?)
Ok(self.0 .0.write().await.sends().decrypt(send)?)

Check warning on line 44 in crates/bitwarden-uniffi/src/tool/sends.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/sends.rs#L44

Added line #L44 was not covered by tests
}

/// Decrypt send list
pub async fn decrypt_list(&self, sends: Vec<Send>) -> Result<Vec<SendListView>> {
Ok(self.0 .0.write().await.sends().decrypt_list(sends).await?)
Ok(self.0 .0.write().await.sends().decrypt_list(sends)?)

Check warning on line 49 in crates/bitwarden-uniffi/src/tool/sends.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/sends.rs#L49

Added line #L49 was not covered by tests
}

/// Decrypt a send file in memory
Expand All @@ -65,8 +57,7 @@
.write()
.await
.sends()
.decrypt_buffer(send, &buffer)
.await?)
.decrypt_buffer(send, &buffer)?)

Check warning on line 60 in crates/bitwarden-uniffi/src/tool/sends.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/sends.rs#L60

Added line #L60 was not covered by tests
}

/// Decrypt a send file located in the file system
Expand All @@ -76,17 +67,10 @@
encrypted_file_path: String,
decrypted_file_path: String,
) -> Result<()> {
Ok(self
.0
.0
.write()
.await
.sends()
.decrypt_file(
send,
Path::new(&encrypted_file_path),
Path::new(&decrypted_file_path),
)
.await?)
Ok(self.0 .0.write().await.sends().decrypt_file(
send,
Path::new(&encrypted_file_path),
Path::new(&decrypted_file_path),
)?)

Check warning on line 74 in crates/bitwarden-uniffi/src/tool/sends.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/tool/sends.rs#L70-L74

Added lines #L70 - L74 were not covered by tests
}
}
46 changes: 14 additions & 32 deletions crates/bitwarden-uniffi/src/vault/attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
.await
.vault()
.attachments()
.encrypt_buffer(cipher, attachment, &buffer)
.await?)
.encrypt_buffer(cipher, attachment, &buffer)?)

Check warning on line 26 in crates/bitwarden-uniffi/src/vault/attachments.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/attachments.rs#L26

Added line #L26 was not covered by tests
}

/// Encrypt an attachment file located in the file system
Expand All @@ -35,20 +34,12 @@
decrypted_file_path: String,
encrypted_file_path: String,
) -> Result<Attachment> {
Ok(self
.0
.0
.write()
.await
.vault()
.attachments()
.encrypt_file(
cipher,
attachment,
Path::new(&decrypted_file_path),
Path::new(&encrypted_file_path),
)
.await?)
Ok(self.0 .0.write().await.vault().attachments().encrypt_file(
cipher,
attachment,
Path::new(&decrypted_file_path),
Path::new(&encrypted_file_path),
)?)

Check warning on line 42 in crates/bitwarden-uniffi/src/vault/attachments.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/attachments.rs#L37-L42

Added lines #L37 - L42 were not covered by tests
}
/// Decrypt an attachment file in memory
pub async fn decrypt_buffer(
Expand All @@ -64,8 +55,7 @@
.await
.vault()
.attachments()
.decrypt_buffer(cipher, attachment, &buffer)
.await?)
.decrypt_buffer(cipher, attachment, &buffer)?)

Check warning on line 58 in crates/bitwarden-uniffi/src/vault/attachments.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/attachments.rs#L58

Added line #L58 was not covered by tests
}

/// Decrypt an attachment file located in the file system
Expand All @@ -76,19 +66,11 @@
encrypted_file_path: String,
decrypted_file_path: String,
) -> Result<()> {
Ok(self
.0
.0
.write()
.await
.vault()
.attachments()
.decrypt_file(
cipher,
attachment,
Path::new(&encrypted_file_path),
Path::new(&decrypted_file_path),
)
.await?)
Ok(self.0 .0.write().await.vault().attachments().decrypt_file(
cipher,
attachment,
Path::new(&encrypted_file_path),
Path::new(&decrypted_file_path),
)?)

Check warning on line 74 in crates/bitwarden-uniffi/src/vault/attachments.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/attachments.rs#L69-L74

Added lines #L69 - L74 were not covered by tests
}
}
19 changes: 4 additions & 15 deletions crates/bitwarden-uniffi/src/vault/ciphers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,12 @@
.await
.vault()
.ciphers()
.encrypt(cipher_view)
.await?)
.encrypt(cipher_view)?)

Check warning on line 22 in crates/bitwarden-uniffi/src/vault/ciphers.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/ciphers.rs#L22

Added line #L22 was not covered by tests
}

/// Decrypt cipher
pub async fn decrypt(&self, cipher: Cipher) -> Result<CipherView> {
Ok(self
.0
.0
.write()
.await
.vault()
.ciphers()
.decrypt(cipher)
.await?)
Ok(self.0 .0.write().await.vault().ciphers().decrypt(cipher)?)

Check warning on line 27 in crates/bitwarden-uniffi/src/vault/ciphers.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/ciphers.rs#L27

Added line #L27 was not covered by tests
}

/// Decrypt cipher list
Expand All @@ -45,8 +36,7 @@
.await
.vault()
.ciphers()
.decrypt_list(ciphers)
.await?)
.decrypt_list(ciphers)?)

Check warning on line 39 in crates/bitwarden-uniffi/src/vault/ciphers.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/ciphers.rs#L39

Added line #L39 was not covered by tests
}

/// Move a cipher to an organization, reencrypting the cipher key if necessary
Expand All @@ -62,7 +52,6 @@
.await
.vault()
.ciphers()
.move_to_organization(cipher, organization_id)
.await?)
.move_to_organization(cipher, organization_id)?)

Check warning on line 55 in crates/bitwarden-uniffi/src/vault/ciphers.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/ciphers.rs#L55

Added line #L55 was not covered by tests
}
}
6 changes: 2 additions & 4 deletions crates/bitwarden-uniffi/src/vault/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
.await
.vault()
.collections()
.decrypt(collection)
.await?)
.decrypt(collection)?)

Check warning on line 21 in crates/bitwarden-uniffi/src/vault/collections.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/collections.rs#L21

Added line #L21 was not covered by tests
}

/// Decrypt collection list
Expand All @@ -31,7 +30,6 @@
.await
.vault()
.collections()
.decrypt_list(collections)
.await?)
.decrypt_list(collections)?)

Check warning on line 33 in crates/bitwarden-uniffi/src/vault/collections.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/collections.rs#L33

Added line #L33 was not covered by tests
}
}
23 changes: 3 additions & 20 deletions crates/bitwarden-uniffi/src/vault/folders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,12 @@
impl ClientFolders {
/// Encrypt folder
pub async fn encrypt(&self, folder: FolderView) -> Result<Folder> {
Ok(self
.0
.0
.write()
.await
.vault()
.folders()
.encrypt(folder)
.await?)
Ok(self.0 .0.write().await.vault().folders().encrypt(folder)?)

Check warning on line 14 in crates/bitwarden-uniffi/src/vault/folders.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/folders.rs#L14

Added line #L14 was not covered by tests
}

/// Decrypt folder
pub async fn decrypt(&self, folder: Folder) -> Result<FolderView> {
Ok(self
.0
.0
.write()
.await
.vault()
.folders()
.decrypt(folder)
.await?)
Ok(self.0 .0.write().await.vault().folders().decrypt(folder)?)

Check warning on line 19 in crates/bitwarden-uniffi/src/vault/folders.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/folders.rs#L19

Added line #L19 was not covered by tests
}

/// Decrypt folder list
Expand All @@ -44,7 +28,6 @@
.await
.vault()
.folders()
.decrypt_list(folders)
.await?)
.decrypt_list(folders)?)

Check warning on line 31 in crates/bitwarden-uniffi/src/vault/folders.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/folders.rs#L31

Added line #L31 was not covered by tests
}
}
6 changes: 2 additions & 4 deletions crates/bitwarden-uniffi/src/vault/password_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
.await
.vault()
.password_history()
.encrypt(password_history)
.await?)
.encrypt(password_history)?)

Check warning on line 21 in crates/bitwarden-uniffi/src/vault/password_history.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/password_history.rs#L21

Added line #L21 was not covered by tests
}

/// Decrypt password history
Expand All @@ -34,7 +33,6 @@
.await
.vault()
.password_history()
.decrypt_list(list)
.await?)
.decrypt_list(list)?)

Check warning on line 36 in crates/bitwarden-uniffi/src/vault/password_history.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/password_history.rs#L36

Added line #L36 was not covered by tests
}
}
4 changes: 2 additions & 2 deletions crates/bitwarden/src/auth/client_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#[cfg(feature = "internal")]
impl<'a> ClientAuth<'a> {
pub async fn password_strength(
pub fn password_strength(

Check warning on line 49 in crates/bitwarden/src/auth/client_auth.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden/src/auth/client_auth.rs#L49

Added line #L49 was not covered by tests
&self,
password: String,
email: String,
Expand All @@ -55,7 +55,7 @@
password_strength(password, email, additional_inputs)
}

pub async fn satisfies_policy(
pub fn satisfies_policy(

Check warning on line 58 in crates/bitwarden/src/auth/client_auth.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden/src/auth/client_auth.rs#L58

Added line #L58 was not covered by tests
&self,
password: String,
strength: u8,
Expand Down
Loading
Loading