Skip to content

Commit

Permalink
Fixed autofill to use new method on userVerificationService (#6029)
Browse files Browse the repository at this point in the history
  • Loading branch information
trmartin4 authored Aug 14, 2023
1 parent 93e3307 commit 39ecad3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ describe("CipherContextMenuHandler", () => {
it("adds ciphers with master password reprompt if the user does not have a master password", async () => {
authService.getAuthStatus.mockResolvedValue(AuthenticationStatus.Unlocked);

// User does not have a master password (key connector user or TDE user)
userVerificationService.hasMasterPassword.mockResolvedValue(false);
// User does not have a master password, or has one but hasn't logged in with it (key connector user or TDE user)
userVerificationService.hasMasterPasswordAndMasterKeyHash.mockResolvedValue(false);

mainContextMenuHandler.init.mockResolvedValue(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class CipherContextMenuHandler {
cipher == null ||
cipher.type !== CipherType.Login ||
(cipher.reprompt !== CipherRepromptType.None &&

Check warning on line 187 in apps/browser/src/autofill/browser/cipher-context-menu-handler.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

❌ Getting worse: Complex Conditional

CipherContextMenuHandler.updateForCipher increases from 1 complex conditionals with 2 branches to 1 complex conditionals with 3 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
(await this.userVerificationService.hasMasterPassword()))
(await this.userVerificationService.hasMasterPasswordAndMasterKeyHash()))
) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/browser/src/autofill/services/autofill.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export default class AutofillService implements AutofillServiceInterface {
if (
cipher == null ||
(cipher.reprompt !== CipherRepromptType.None &&

Check warning on line 241 in apps/browser/src/autofill/services/autofill.service.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

❌ New issue: Complex Conditional

AutofillService.doAutoFillOnTab has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
(await this.userVerificationService.hasMasterPassword()))
(await this.userVerificationService.hasMasterPasswordAndMasterKeyHash()))
) {

Check notice on line 243 in apps/browser/src/autofill/services/autofill.service.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

ℹ Getting worse: Complex Method

AutofillService.doAutoFillOnTab increases in cyclomatic complexity from 9 to 10, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
return null;
}
Expand Down

0 comments on commit 39ecad3

Please sign in to comment.