diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0c1169aed..81f9af608 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -47,3 +47,8 @@ jobs: run: cargo doc --no-deps --features internal env: RUSTDOCFLAGS: "-D warnings" + + - name: Cargo clippy + run: cargo clippy --all-features + env: + RUSTFLAGS: "-D warnings" diff --git a/crates/bitwarden-c/src/c.rs b/crates/bitwarden-c/src/c.rs index 0f7c2855d..e7184c0fc 100644 --- a/crates/bitwarden-c/src/c.rs +++ b/crates/bitwarden-c/src/c.rs @@ -15,10 +15,10 @@ pub async extern "C" fn run_command( println!("{}", input_str); let result = client.run_command(input_str).await; - return match std::ffi::CString::new(result) { + match std::ffi::CString::new(result) { Ok(cstr) => cstr.into_raw(), Err(_) => panic!("failed to return command result: null encountered"), - }; + } } // Init client, potential leak! You need to call free_mem after this! @@ -26,12 +26,12 @@ pub async extern "C" fn run_command( pub extern "C" fn init(c_str_ptr: *const c_char) -> *mut Client { env_logger::init(); if c_str_ptr.is_null() { - return box_ptr!(Client::new(None)); + box_ptr!(Client::new(None)) } else { let input_string = str::from_utf8(unsafe { CStr::from_ptr(c_str_ptr).to_bytes() }) .unwrap() .to_owned(); - return box_ptr!(Client::new(Some(input_string))); + box_ptr!(Client::new(Some(input_string))) } } diff --git a/crates/bitwarden-c/src/lib.rs b/crates/bitwarden-c/src/lib.rs index c27b8372b..2d6961b8e 100644 --- a/crates/bitwarden-c/src/lib.rs +++ b/crates/bitwarden-c/src/lib.rs @@ -1,3 +1,6 @@ +// These are the C bindings, we're going to have to use unsafe raw pointers +#![allow(clippy::not_unsafe_ptr_arg_deref)] + #[cfg(not(target_arch = "wasm32"))] pub use c::*; diff --git a/crates/bitwarden-napi/src/client.rs b/crates/bitwarden-napi/src/client.rs index 280ad83c6..ed24c8e64 100644 --- a/crates/bitwarden-napi/src/client.rs +++ b/crates/bitwarden-napi/src/client.rs @@ -38,6 +38,6 @@ impl BitwardenClient { #[napi] pub async unsafe fn run_command(&mut self, command_input: String) -> String { - self.0.run_command(&command_input).await.into() + self.0.run_command(&command_input).await } } diff --git a/crates/bitwarden-wasm/src/client.rs b/crates/bitwarden-wasm/src/client.rs index 366dbe7b5..7d3d991db 100644 --- a/crates/bitwarden-wasm/src/client.rs +++ b/crates/bitwarden-wasm/src/client.rs @@ -50,6 +50,9 @@ impl BitwardenClient { #[wasm_bindgen] pub fn run_command(&mut self, js_input: String) -> Promise { let rc = self.0.clone(); + // TODO: We should probably switch to an async-aware RwLock here, + // but it probably doesn't matter much in a single threaded environment + #[allow(clippy::await_holding_lock)] future_to_promise(async move { let mut client = rc.write().unwrap(); let result = client.run_command(&js_input).await; diff --git a/crates/bitwarden/src/auth/api/request/mod.rs b/crates/bitwarden/src/auth/api/request/mod.rs index 8ba3d239f..44d2e8ab6 100644 --- a/crates/bitwarden/src/auth/api/request/mod.rs +++ b/crates/bitwarden/src/auth/api/request/mod.rs @@ -58,5 +58,5 @@ async fn send_identity_connect_request( let status = response.status(); let text = response.text().await?; - parse_identity_response(status, &text) + parse_identity_response(status, text) } diff --git a/crates/bitwarden/src/auth/api/request/renew_token_request.rs b/crates/bitwarden/src/auth/api/request/renew_token_request.rs index 2f7b1161f..b5a91dca4 100644 --- a/crates/bitwarden/src/auth/api/request/renew_token_request.rs +++ b/crates/bitwarden/src/auth/api/request/renew_token_request.rs @@ -11,12 +11,11 @@ pub struct RenewTokenRequest { impl RenewTokenRequest { pub fn new(refresh_token: String, client_id: String) -> Self { - let obj = Self { + Self { refresh_token, client_id, grant_type: "refresh_token".to_string(), - }; - obj + } } pub(crate) async fn send( diff --git a/crates/bitwarden/src/auth/api/response/identity_token_response.rs b/crates/bitwarden/src/auth/api/response/identity_token_response.rs index 008b49905..ae6cc81e5 100644 --- a/crates/bitwarden/src/auth/api/response/identity_token_response.rs +++ b/crates/bitwarden/src/auth/api/response/identity_token_response.rs @@ -14,30 +14,30 @@ pub enum IdentityTokenResponse { Authenticated(IdentityTokenSuccessResponse), Payload(IdentityTokenPayloadResponse), Refreshed(IdentityTokenRefreshResponse), - TwoFactorRequired(IdentityTwoFactorResponse), + TwoFactorRequired(Box), CaptchaRequired(IdentityCaptchaResponse), } pub fn parse_identity_response( status: StatusCode, - response: &str, + response: String, ) -> Result { - if let Ok(r) = serde_json::from_str::(response) { + if let Ok(r) = serde_json::from_str::(&response) { Ok(IdentityTokenResponse::Authenticated(r)) - } else if let Ok(r) = serde_json::from_str::(response) { + } else if let Ok(r) = serde_json::from_str::(&response) { Ok(IdentityTokenResponse::Payload(r)) - } else if let Ok(r) = serde_json::from_str::(response) { + } else if let Ok(r) = serde_json::from_str::(&response) { Ok(IdentityTokenResponse::Refreshed(r)) - } else if let Ok(r) = serde_json::from_str::(response) { - Ok(IdentityTokenResponse::TwoFactorRequired(r)) - } else if let Ok(r) = serde_json::from_str::(response) { + } else if let Ok(r) = serde_json::from_str::(&response) { + Ok(IdentityTokenResponse::TwoFactorRequired(Box::new(r))) + } else if let Ok(r) = serde_json::from_str::(&response) { Ok(IdentityTokenResponse::CaptchaRequired(r)) - } else if let Ok(r) = serde_json::from_str::(response) { + } else if let Ok(r) = serde_json::from_str::(&response) { Err(Error::IdentityFail(r)) } else { Err(Error::ResponseContent { - status: status, - message: response.to_owned(), + status, + message: response, }) } } @@ -51,16 +51,16 @@ mod test { let expected = IdentityTokenSuccessResponse::default(); let success = serde_json::to_string(&expected).unwrap(); let expected = IdentityTokenResponse::Authenticated(expected); - let actual = parse_identity_response(StatusCode::OK, &success).unwrap(); + let actual = parse_identity_response(StatusCode::OK, success).unwrap(); assert_eq!(expected, actual); } #[test] fn two_factor() { - let expected = IdentityTwoFactorResponse::default(); + let expected = Box::new(IdentityTwoFactorResponse::default()); let two_factor = serde_json::to_string(&expected).unwrap(); let expected = IdentityTokenResponse::TwoFactorRequired(expected); - let actual = parse_identity_response(StatusCode::BAD_REQUEST, &two_factor).unwrap(); + let actual = parse_identity_response(StatusCode::BAD_REQUEST, two_factor).unwrap(); assert_eq!(expected, actual); } @@ -69,7 +69,7 @@ mod test { let expected = IdentityCaptchaResponse::default(); let captcha = serde_json::to_string(&expected).unwrap(); let expected = IdentityTokenResponse::CaptchaRequired(expected); - let actual = parse_identity_response(StatusCode::BAD_REQUEST, &captcha).unwrap(); + let actual = parse_identity_response(StatusCode::BAD_REQUEST, captcha).unwrap(); assert_eq!(expected, actual); } } diff --git a/crates/bitwarden/src/auth/commands/login.rs b/crates/bitwarden/src/auth/commands/login.rs index 6633ecf5f..2bb7f34a2 100644 --- a/crates/bitwarden/src/auth/commands/login.rs +++ b/crates/bitwarden/src/auth/commands/login.rs @@ -133,7 +133,7 @@ pub(crate) async fn access_token_login( let payload: Payload = serde_json::from_slice(&decrypted_payload)?; - let encryption_key = BASE64_ENGINE.decode(&payload.encryption_key)?; + let encryption_key = BASE64_ENGINE.decode(payload.encryption_key)?; let encryption_key = SymmetricCryptoKey::try_from(encryption_key.as_slice())?; @@ -192,7 +192,7 @@ async fn request_identity_tokens( ) -> Result { let config = client.get_api_configurations().await; PasswordTokenRequest::new(&input.email, password_hash) - .send(&config) + .send(config) .await } @@ -203,7 +203,7 @@ async fn request_api_identity_tokens( ) -> Result { let config = client.get_api_configurations().await; ApiTokenRequest::new(&input.client_id, &input.client_secret) - .send(&config) + .send(config) .await } @@ -213,7 +213,7 @@ async fn request_access_token( ) -> Result { let config = client.get_api_configurations().await; AccessTokenRequest::new(input.service_account_id, &input.client_secret) - .send(&config) + .send(config) .await } @@ -254,7 +254,7 @@ pub(crate) async fn renew_token(client: &mut Client) -> Result<()> { client_secret, .. } => { - AccessTokenRequest::new(*service_account_id, &client_secret) + AccessTokenRequest::new(*service_account_id, client_secret) .send(&client.__api_configurations) .await? } diff --git a/crates/bitwarden/src/client/access_token.rs b/crates/bitwarden/src/client/access_token.rs index d76711376..e734bc7d9 100644 --- a/crates/bitwarden/src/client/access_token.rs +++ b/crates/bitwarden/src/client/access_token.rs @@ -46,7 +46,7 @@ impl FromStr for AccessToken { crate::crypto::stretch_key(encryption_key, "accesstoken", Some("sm-access-token")); Ok(AccessToken { - service_account_id: service_account_id, + service_account_id, client_secret: client_secret.to_owned(), encryption_key, }) diff --git a/crates/bitwarden/src/client/encryption_settings.rs b/crates/bitwarden/src/client/encryption_settings.rs index 6720369ac..fd3699689 100644 --- a/crates/bitwarden/src/client/encryption_settings.rs +++ b/crates/bitwarden/src/client/encryption_settings.rs @@ -54,7 +54,7 @@ impl FromStr for SymmetricCryptoKey { fn from_str(s: &str) -> Result { let bytes = BASE64_ENGINE - .decode(&s) + .decode(s) .map_err(|_| CryptoError::InvalidKey)?; SymmetricCryptoKey::try_from(bytes.as_slice()) } @@ -120,7 +120,7 @@ impl EncryptionSettings { _ => return Err(CryptoError::InvalidKey.into()), }; - let dec = decrypt_aes256(&iv, &mac, &data, Some(mac_key), key)?; + let dec = decrypt_aes256(&iv, &mac, data, Some(mac_key), key)?; SymmetricCryptoKey::try_from(dec.as_slice())? }; @@ -178,10 +178,7 @@ impl EncryptionSettings { } match org_id { - Some(org_id) => match self.org_keys.get(org_id) { - Some(k) => Some(k), - None => return None, - }, + Some(org_id) => self.org_keys.get(org_id), None => Some(&self.user_key), } } @@ -203,17 +200,17 @@ impl EncryptionSettings { pub fn decrypt(cipher: &CipherString, key: &SymmetricCryptoKey) -> Result> { match cipher { CipherString::AesCbc256_HmacSha256_B64 { iv, mac, data } => { - let dec = decrypt_aes256(iv, mac, data, key.mac_key, key.key)?; + let dec = decrypt_aes256(iv, mac, data.clone(), key.mac_key, key.key)?; Ok(dec) } - _ => return Err(CryptoError::InvalidKey.into()), + _ => Err(CryptoError::InvalidKey.into()), } } pub fn decrypt_aes256( iv: &[u8; 16], mac: &[u8; 32], - data: &Vec, + data: Vec, mac_key: Option>, key: GenericArray, ) -> Result> { @@ -223,14 +220,14 @@ pub fn decrypt_aes256( }; // Validate HMAC - let res = validate_mac(&mac_key, iv, data)?; + let res = validate_mac(&mac_key, iv, &data)?; if res != *mac { return Err(CryptoError::InvalidMac.into()); } // Decrypt data let iv = GenericArray::from_slice(iv); - let mut data = data.clone(); + let mut data = data; let decrypted_key_slice = cbc::Decryptor::::new(&key, iv) .decrypt_padded_mut::(&mut data) .map_err(|_| CryptoError::KeyDecrypt)?; diff --git a/crates/bitwarden/src/client/mod.rs b/crates/bitwarden/src/client/mod.rs index 386f462e3..ee2a956df 100644 --- a/crates/bitwarden/src/client/mod.rs +++ b/crates/bitwarden/src/client/mod.rs @@ -4,6 +4,7 @@ pub(crate) use client::*; pub(crate) mod access_token; #[cfg(any(feature = "internal", feature = "mobile"))] pub(crate) mod auth_settings; +#[allow(clippy::module_inception)] mod client; pub mod client_settings; pub(crate) mod encryption_settings; diff --git a/crates/bitwarden/src/crypto.rs b/crates/bitwarden/src/crypto.rs index 7cf6a5262..d1809adf5 100644 --- a/crates/bitwarden/src/crypto.rs +++ b/crates/bitwarden/src/crypto.rs @@ -306,7 +306,7 @@ pub(crate) fn stretch_key(secret: [u8; 16], name: &str, info: Option<&str>) -> S // TODO: Are these the final `key` and `info` parameters or should we change them? I followed the pattern used for sends let res = Hmac::::new_from_slice(format!("bitwarden-{}", name).as_bytes()) .unwrap() - .chain_update(&secret) + .chain_update(secret) .finalize() .into_bytes(); @@ -317,7 +317,7 @@ pub(crate) fn stretch_key(secret: [u8; 16], name: &str, info: Option<&str>) -> S // TODO: Should we have a default value for info? // Should it be required? let i = info.map(|i| i.as_bytes()).unwrap_or(&[]); - hkdf.expand(&i, &mut key).unwrap(); + hkdf.expand(i, &mut key).unwrap(); SymmetricCryptoKey::try_from(key.as_slice()).unwrap() } @@ -343,7 +343,7 @@ fn hash_word(hash: [u8; 32]) -> Result { let minimum_entropy = 64; let entropy_per_word = (EFF_LONG_WORD_LIST.len() as f64).log2(); - let num_words = ((minimum_entropy as f64 / entropy_per_word).ceil() as f64).to_owned() as i64; + let num_words = ((minimum_entropy as f64 / entropy_per_word).ceil()).to_owned() as i64; let hash_arr: Vec = hash.to_vec(); let entropy_available = hash_arr.len() * 4; @@ -358,7 +358,7 @@ fn hash_word(hash: [u8; 32]) -> Result { let mut hash_number = BigUint::from_bytes_be(&hash_arr); for _ in 0..num_words { let remainder = hash_number.clone() % EFF_LONG_WORD_LIST.len(); - hash_number = hash_number / EFF_LONG_WORD_LIST.len(); + hash_number /= EFF_LONG_WORD_LIST.len(); phrase.push(EFF_LONG_WORD_LIST[remainder.to_usize().unwrap()].to_string()); } @@ -382,7 +382,7 @@ impl Encryptable for String { impl Decryptable for CipherString { fn decrypt(&self, enc: &EncryptionSettings, org_id: &Option) -> Result { - enc.decrypt(&self, org_id) + enc.decrypt(self, org_id) } } @@ -406,7 +406,7 @@ impl, Output> Encryptable> for Vec { impl, Output> Decryptable> for Vec { fn decrypt(&self, enc: &EncryptionSettings, org_id: &Option) -> Result> { - self.into_iter().map(|e| e.decrypt(enc, org_id)).collect() + self.iter().map(|e| e.decrypt(enc, org_id)).collect() } } @@ -432,12 +432,24 @@ impl, Output, Id: Hash + Eq + Copy> Decryptable, ) -> Result> { - self.into_iter() + self.iter() .map(|(id, e)| Ok((*id, e.decrypt(enc, org_id)?))) .collect::>>() } } +impl, Output> Encryptable for Box { + fn encrypt(self, enc: &EncryptionSettings, org_id: &Option) -> Result { + (*self).encrypt(enc, org_id) + } +} + +impl, Output> Decryptable for Box { + fn decrypt(&self, enc: &EncryptionSettings, org_id: &Option) -> Result { + (**self).decrypt(enc, org_id) + } +} + #[cfg(test)] mod tests { use super::stretch_key; diff --git a/crates/bitwarden/src/mobile/vault/ciphers/cipher_decrypt.rs b/crates/bitwarden/src/mobile/vault/ciphers/cipher_decrypt.rs index df4fd88b0..7d14b2a39 100644 --- a/crates/bitwarden/src/mobile/vault/ciphers/cipher_decrypt.rs +++ b/crates/bitwarden/src/mobile/vault/ciphers/cipher_decrypt.rs @@ -6,11 +6,11 @@ use crate::vault::{Cipher, CipherView}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct CipherDecryptRequest { - pub cipher: Cipher, + pub cipher: Box, } #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct CipherDecryptResponse { - pub cipher: CipherView, + pub cipher: Box, } diff --git a/crates/bitwarden/src/mobile/vault/ciphers/cipher_encrypt.rs b/crates/bitwarden/src/mobile/vault/ciphers/cipher_encrypt.rs index 00b6edf1c..78c8be287 100644 --- a/crates/bitwarden/src/mobile/vault/ciphers/cipher_encrypt.rs +++ b/crates/bitwarden/src/mobile/vault/ciphers/cipher_encrypt.rs @@ -6,11 +6,11 @@ use crate::vault::{Cipher, CipherView}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct CipherEncryptRequest { - pub cipher: CipherView, + pub cipher: Box, } #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct CipherEncryptResponse { - pub cipher: Cipher, + pub cipher: Box, } diff --git a/crates/bitwarden/src/mobile/vault/client_ciphers.rs b/crates/bitwarden/src/mobile/vault/client_ciphers.rs index 0fd4c36f0..6e1d42ded 100644 --- a/crates/bitwarden/src/mobile/vault/client_ciphers.rs +++ b/crates/bitwarden/src/mobile/vault/client_ciphers.rs @@ -17,7 +17,7 @@ impl<'a> ClientCiphers<'a> { pub async fn encrypt(&self, req: CipherEncryptRequest) -> Result { let enc = self.client.get_encryption_settings()?; - let cipher = req.cipher.encrypt(enc, &None)?; + let cipher = Box::new(req.cipher.encrypt(enc, &None)?); Ok(CipherEncryptResponse { cipher }) } @@ -25,7 +25,7 @@ impl<'a> ClientCiphers<'a> { pub async fn decrypt(&self, req: CipherDecryptRequest) -> Result { let enc = self.client.get_encryption_settings()?; - let cipher = req.cipher.decrypt(enc, &None)?; + let cipher = Box::new(req.cipher.decrypt(enc, &None)?); Ok(CipherDecryptResponse { cipher }) } diff --git a/crates/bitwarden/src/vault/cipher/cipher.rs b/crates/bitwarden/src/vault/cipher/cipher.rs index 2b70a99b0..bc8eef54f 100644 --- a/crates/bitwarden/src/vault/cipher/cipher.rs +++ b/crates/bitwarden/src/vault/cipher/cipher.rs @@ -45,9 +45,9 @@ pub struct Cipher { pub notes: CipherString, pub r#type: CipherType, - pub login: Option, - pub identity: Option, - pub card: Option, + pub login: Option>, + pub identity: Option>, + pub card: Option>, pub secure_note: Option, pub favorite: bool, @@ -78,10 +78,10 @@ pub struct CipherView { pub notes: String, pub r#type: CipherType, - pub login: Option, - pub identity: Option, - pub card: Option, - pub secure_note: Option, + pub login: Option>, + pub identity: Option>, + pub card: Option>, + pub secure_note: Option>, pub favorite: bool, pub reprompt: CipherRepromptType, @@ -136,9 +136,9 @@ impl Encryptable for CipherView { name: self.name.encrypt(enc, org_id)?, notes: self.notes.encrypt(enc, org_id)?, r#type: self.r#type, - login: self.login.encrypt(enc, org_id)?, - identity: self.identity.encrypt(enc, org_id)?, - card: self.card.encrypt(enc, org_id)?, + login: self.login.encrypt(enc, org_id)?.map(Box::new), + identity: self.identity.encrypt(enc, org_id)?.map(Box::new), + card: self.card.encrypt(enc, org_id)?.map(Box::new), secure_note: self.secure_note.encrypt(enc, org_id)?, favorite: self.favorite, reprompt: self.reprompt, @@ -167,10 +167,10 @@ impl Decryptable for Cipher { name: self.name.decrypt(enc, org_id)?, notes: self.notes.decrypt(enc, org_id)?, r#type: self.r#type, - login: self.login.decrypt(enc, org_id)?, - identity: self.identity.decrypt(enc, org_id)?, - card: self.card.decrypt(enc, org_id)?, - secure_note: self.secure_note.decrypt(enc, org_id)?, + login: self.login.decrypt(enc, org_id)?.map(Box::new), + identity: self.identity.decrypt(enc, org_id)?.map(Box::new), + card: self.card.decrypt(enc, org_id)?.map(Box::new), + secure_note: self.secure_note.decrypt(enc, org_id)?.map(Box::new), favorite: self.favorite, reprompt: self.reprompt, organization_use_totp: self.organization_use_totp, diff --git a/crates/bitwarden/src/vault/cipher/mod.rs b/crates/bitwarden/src/vault/cipher/mod.rs index 19729edf4..c891f439d 100644 --- a/crates/bitwarden/src/vault/cipher/mod.rs +++ b/crates/bitwarden/src/vault/cipher/mod.rs @@ -1,5 +1,6 @@ pub(crate) mod attachment; pub(crate) mod card; +#[allow(clippy::module_inception)] pub(crate) mod cipher; pub(crate) mod field; pub(crate) mod identity; diff --git a/crates/bitwarden/src/wordlist.rs b/crates/bitwarden/src/wordlist.rs index 03853ea25..4974969e6 100644 --- a/crates/bitwarden/src/wordlist.rs +++ b/crates/bitwarden/src/wordlist.rs @@ -1,6 +1,6 @@ // EFF's Long Wordlist from https://www.eff.org/dice #[cfg(feature = "internal")] -pub(crate) const EFF_LONG_WORD_LIST: &'static [&str] = &[ +pub(crate) const EFF_LONG_WORD_LIST: &[&str] = &[ "abacus", "abdomen", "abdominal", diff --git a/crates/bws/src/config.rs b/crates/bws/src/config.rs index e6054c035..ecad2f6a5 100644 --- a/crates/bws/src/config.rs +++ b/crates/bws/src/config.rs @@ -88,8 +88,8 @@ pub(crate) fn update_profile( ) -> Result<()> { let mut config = load_config(config_file, false)?; - let mut p = config.profiles.entry(profile).or_default(); - name.update_profile_value(&mut p, value); + let p = config.profiles.entry(profile).or_default(); + name.update_profile_value(p, value); write_config(config, config_file)?; Ok(()) diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index f224ca6d6..e03faae4f 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -225,6 +225,7 @@ const ACCESS_TOKEN_KEY_VAR_NAME: &str = "BWS_ACCESS_TOKEN"; const PROFILE_KEY_VAR_NAME: &str = "BWS_PROFILE"; const SERVER_URL_KEY_VAR_NAME: &str = "BWS_SERVER_URL"; +#[allow(clippy::comparison_chain)] async fn process_commands() -> Result<()> { let cli = Cli::parse(); @@ -305,9 +306,7 @@ async fn process_commands() -> Result<()> { // Load session or return if no session exists let _ = client - .access_token_login(&AccessTokenLoginRequest { - access_token: access_token, - }) + .access_token_login(&AccessTokenLoginRequest { access_token }) .await?; let organization_id = match client.get_access_token_organization() { @@ -328,9 +327,7 @@ async fn process_commands() -> Result<()> { } => { let projects = client .projects() - .list(&ProjectsListRequest { - organization_id: organization_id.clone(), - }) + .list(&ProjectsListRequest { organization_id }) .await? .data; serialize_response(projects, cli.output, color); @@ -418,7 +415,7 @@ async fn process_commands() -> Result<()> { eprintln!("{}: {}", project.0, project.1); } - if projects_failed.len() > 0 { + if !projects_failed.is_empty() { process::exit(1); } } @@ -432,16 +429,12 @@ async fn process_commands() -> Result<()> { let res = if let Some(project_id) = project_id { client .secrets() - .list_by_project(&SecretIdentifiersByProjectRequest { - project_id: project_id, - }) + .list_by_project(&SecretIdentifiersByProjectRequest { project_id }) .await? } else { client .secrets() - .list(&SecretIdentifiersRequest { - organization_id: organization_id.clone(), - }) + .list(&SecretIdentifiersRequest { organization_id }) .await? }; @@ -520,9 +513,7 @@ async fn process_commands() -> Result<()> { } => { let old_secret = client .secrets() - .get(&SecretGetRequest { - id: secret_id.clone(), - }) + .get(&SecretGetRequest { id: secret_id }) .await?; let secret = client @@ -581,7 +572,7 @@ async fn process_commands() -> Result<()> { eprintln!("{}: {}", secret.0, secret.1); } - if secrets_failed.len() > 0 { + if !secrets_failed.is_empty() { process::exit(1); } } @@ -598,7 +589,7 @@ fn get_config_profile( server_url: &Option, profile: &Option, config_file: &Option, - access_token: &String, + access_token: &str, ) -> Result, color_eyre::Report> { let profile = if let Some(server_url) = server_url { Some(config::Profile::from_url(server_url)?) diff --git a/crates/bws/src/render.rs b/crates/bws/src/render.rs index 53306af0d..7a7822113 100644 --- a/crates/bws/src/render.rs +++ b/crates/bws/src/render.rs @@ -5,6 +5,7 @@ use comfy_table::Table; use serde::Serialize; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)] +#[allow(clippy::upper_case_acronyms)] pub(crate) enum Output { JSON, YAML,