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

remove normalize_comments rustfmt rule #316

Merged
merged 3 commits into from
Sep 10, 2023
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: 0 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
tab_spaces = 4
hard_tabs = true
normalize_comments = true
15 changes: 7 additions & 8 deletions src/accountmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ mod tests {
let tmp_dir = TempDir::new("steamguard-cli-test").unwrap();
let manifest_path = tmp_dir.path().join("manifest.json");
let manager = AccountManager::new(manifest_path.as_path());
assert!(matches!(manager.save(), Ok(_)));
assert!(manager.save().is_ok());
}

#[test]
Expand Down Expand Up @@ -529,7 +529,7 @@ mod tests {
manager.add_account(account);
manager.manifest.entries[0].encryption = Some(EncryptionScheme::generate());
manager.submit_passkey(passkey.clone());
assert!(matches!(manager.save(), Ok(_)));
assert!(manager.save().is_ok());

let mut loaded_manager = AccountManager::load(manifest_path.as_path()).unwrap();
loaded_manager.submit_passkey(passkey);
Expand All @@ -542,7 +542,7 @@ mod tests {
if _r.is_err() {
eprintln!("{:?}", _r);
}
assert!(matches!(_r, Ok(_)));
assert!(_r.is_ok());
assert_eq!(
loaded_manager.manifest.entries.len(),
loaded_manager.accounts.len()
Expand Down Expand Up @@ -628,17 +628,16 @@ mod tests {
std::fs::remove_file(&manifest_path)?;

let mut loaded_manager = AccountManager::new(manifest_path.as_path());
assert!(matches!(
loaded_manager.import_account(
assert!(loaded_manager
.import_account(
&tmp_dir
.path()
.join("asdf1234.maFile")
.into_os_string()
.into_string()
.unwrap()
),
Ok(_)
));
)
.is_ok());
assert_eq!(
loaded_manager.manifest.entries.len(),
loaded_manager.accounts.len()
Expand Down
5 changes: 4 additions & 1 deletion src/commands/qr_login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ where

loop {
let Some(tokens) = account.tokens.as_ref() else {
error!("No tokens found for {}. Can't approve login if we aren't logged in ourselves.", account.account_name);
error!(
"No tokens found for {}. Can't approve login if we aren't logged in ourselves.",
account.account_name
);
return Err(anyhow!("No tokens found for {}", account.account_name));
};

Expand Down
4 changes: 2 additions & 2 deletions src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ mod prompt_char_tests {
#[test]
fn test_should_not_give_invalid() {
let answer = prompt_char_impl("g", "yn");
assert!(matches!(answer, Err(_)));
assert!(answer.is_err());
let answer = prompt_char_impl("n", "yn").unwrap();
assert_eq!(answer, 'n');
}

#[test]
fn test_should_not_give_multichar() {
let answer = prompt_char_impl("yy", "yn");
assert!(matches!(answer, Err(_)));
assert!(answer.is_err());
}
}
6 changes: 4 additions & 2 deletions steamguard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ impl SteamGuardAccount {
client: &TwoFactorClient<T>,
revocation_code: Option<&String>,
) -> Result<(), RemoveAuthenticatorError> {
if !matches!(revocation_code, Some(_)) && self.revocation_code.expose_secret().is_empty() {
if revocation_code.is_none() && self.revocation_code.expose_secret().is_empty() {
return Err(RemoveAuthenticatorError::MissingRevocationCode);
}
let Some(tokens) = &self.tokens else {
return Err(RemoveAuthenticatorError::TransportError(TransportError::Unauthorized));
return Err(RemoveAuthenticatorError::TransportError(
TransportError::Unauthorized,
));
};
let mut req = CTwoFactor_RemoveAuthenticator_Request::new();
req.set_revocation_code(
Expand Down