Skip to content

Conversation

@KatherineInCode
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-26060

📔 Objective

This moves the Alert to BitwardenKit, along with attendant objects, as part of an effort to migrate shared objects to BitwardenKit. Future PRs will bring some other core objects over, which will enable bringing the Select Language UI over.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@github-actions
Copy link
Contributor

github-actions bot commented Oct 29, 2025

Logo
Checkmarx One – Scan Summary & Details8e765be1-9660-4dab-9a3f-32d7a1cbb60a

Great job! No new security vulnerabilities introduced in this pull request

@github-actions
Copy link
Contributor

Warning

@KatherineInCode Uploading code coverage report failed. Please check the "Upload to codecov.io" step of Process Test Reports job for more details.

@github-actions
Copy link
Contributor

Warning

@KatherineInCode Uploading code coverage report failed. Please check the "Upload to codecov.io" step of Process Test Reports job for more details.

@KatherineInCode KatherineInCode marked this pull request as ready for review October 29, 2025 15:43
@claude
Copy link

claude bot commented Oct 29, 2025

Claude finished @KatherineInCode's task —— View job


Code Review: Alert Consolidation to BitwardenKit

  • Review PR changes and recent commits
  • Check architecture compliance
  • Verify test coverage and documentation
  • Compile comprehensive review findings
  • Post final review feedback

Summary of Changes Since Last Review

The PR author has addressed previous review feedback:

  • Removed unused method: The setKeyWindowRoot(view:) method was removed from BitwardenTestCase (commit 23369d6) as identified by @matt-livefront
  • Documentation added: All public APIs in MockUIViewController.swift now have proper DocC documentation
  • Method ordering: Methods are correctly ordered (public before private)
  • Pluralization corrected: "Mocks" directory naming fixed (commit 65f39ad)

Architecture & Design Review

Excellent: Follows Target Architecture

The consolidation properly moves Alert and related types to BitwardenKit, which aligns with the project's goal of migrating shared objects to the shared framework. This is the correct architectural direction per the repository structure documented in Docs/Architecture.md.

Key architectural decisions that are correct:

  1. Proper module structure: Alert moved from app-specific modules to BitwardenKit/UI/Platform/Application/Utilities/Alert/
  2. Type disambiguation: Uses BitwardenKit.Alert in places where both modules are imported (e.g., Coordinator.swift)
  3. Test infrastructure: Properly moved to BitwardenKit with appropriate test helpers
  4. Mock objects: MockUIViewController correctly placed in BitwardenKit/UI/Platform/Application/Utilities/Mocks/

Good Practices Observed

  • Comprehensive DocC documentation on all public APIs
  • Proper use of Swift protocols (AlertPresentable, Equatable, Hashable)
  • Test fixtures properly gated with #if DEBUG
  • Consistent code style throughout

Critical Issues

None Found ✅

All previously identified issues have been resolved.

Suggested Improvements

⛏️ Minor: AlertTextField initialization parameter documentation

In AlertTextField.swift:44, the initializer has a parameter text: String? = nil but the DocC comment says "An optional initial value to pre-fill the text field with."

Current (line 42):

///   - text: An optional initial value to pre-fill the text field with.

Consider clarifying:

///   - text: An optional initial value to pre-fill the text field with. Defaults to `nil`, which results in an empty string.

This makes it clearer that nil becomes an empty string internally (line 59).

Impact: Documentation clarity
File: BitwardenKit/UI/Platform/Application/Utilities/Alert/AlertTextField.swift:42

ℹ️ Info: Test Coverage Gaps

Per codecov report, the following have missing coverage:

  1. MockUIViewController.swift: 32 lines missing coverage (66.66% covered)

    • Many mock tracking properties and methods aren't exercised by current tests
    • Recommendation: This is acceptable for mock objects as they're utilities for testing
  2. BitwardenTestCase.swift: 6 lines missing (66.66% covered)

    • Base test infrastructure - acceptable
  3. Several Processor files: 1 line missing each

    • These appear to be the updated showAlert() calls with the new type
    • Recommendation: Verify existing processor tests cover the alert display paths

Impact: Test coverage is at 82.91% (within acceptable range)
Action: Consider adding tests that exercise MockUIViewController methods if this mock is intended to be heavily used

🤔 Question: OSLog import in AlertPresentable

AlertPresentable.swift:1 imports OSLog but only uses Logger.application on line 48.

Question: Is Logger.application defined elsewhere in BitwardenKit, or does this require a specific logger setup?

File: BitwardenKit/UI/Platform/Application/Utilities/Alert/AlertPresentable.swift:1

Security Considerations

✅ No Security Issues Identified

The Alert system properly:

  • Handles user input through AlertTextField
  • Uses standard UIKit presentation mechanisms
  • Doesn't store sensitive data
  • Properly cleans up references in MockUIViewController.reset()

Testing Assessment

Comprehensive Test Coverage

  1. AlertTests.swift: Tests alert creation, controller generation, dismissal callbacks, equality
  2. AlertPresentableTests.swift: Tests presentation logic and dismissal callbacks
  3. AlertErrorTests.swift: Tests error alert creation helpers
  4. Test infrastructure: Properly uses BaseBitwardenTestCase.setKeyWindowRoot(viewController:) method

All critical paths are tested. The 82.91% coverage is acceptable for this type of consolidation work.

Action Items for Author

✅ All Previous Items Completed

No blocking issues remain. The PR is ready for merge pending:

  1. CI completion: Test and scan workflows are currently in progress
  2. 📝 Optional: Consider addressing the suggestions above (all are minor/informational)

Files Reviewed

Key files examined (click to expand)

Core Alert Implementation:

  • BitwardenKit/UI/Platform/Application/Utilities/Alert/Alert.swift
  • BitwardenKit/UI/Platform/Application/Utilities/Alert/AlertAction.swift
  • BitwardenKit/UI/Platform/Application/Utilities/Alert/AlertTextField.swift
  • BitwardenKit/UI/Platform/Application/Utilities/Alert/AlertPresentable.swift
  • BitwardenKit/UI/Platform/Application/Utilities/Alert/Alert+Error.swift

Test Infrastructure:

  • BitwardenKit/UI/Platform/Application/Utilities/Mocks/MockUIViewController.swift
  • BitwardenKit/Application/TestHelpers/Support/BitwardenTestCase.swift
  • BitwardenKit/UI/Platform/Application/Utilities/Alert/AlertTests.swift
  • BitwardenKit/UI/Platform/Application/Utilities/Alert/AlertPresentableTests.swift

Integration Points:

  • BitwardenShared/UI/Platform/Application/Utilities/Coordinator.swift
  • AuthenticatorShared/UI/Platform/Application/Utilities/Coordinator.swift
  • Multiple mock navigators and coordinators

Final Assessment

Status: ✅ Approved - Ready for Merge (pending CI completion)

This is a well-executed consolidation that properly moves shared Alert infrastructure to BitwardenKit. The code follows project guidelines, has comprehensive documentation, and maintains good test coverage. All previous review feedback has been addressed.

Great work on this consolidation effort! 👍


Copy link
Member

@fedemkr fedemkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just missing some ⛏️ docs

@github-actions
Copy link
Contributor

Warning

@KatherineInCode Uploading code coverage report failed. Please check the "Upload to codecov.io" step of Process Test Reports job for more details.

@KatherineInCode
Copy link
Contributor Author

Looks good, just missing some ⛏️ docs

Good catches. Though now I wonder if there's a way we could change the Claude configuration so that in its review it generates text that points out the missing docs as well 🤔

@github-actions
Copy link
Contributor

Warning

@KatherineInCode Uploading code coverage report failed. Please check the "Upload to codecov.io" step of Process Test Reports job for more details.

@github-actions
Copy link
Contributor

Warning

@KatherineInCode Uploading code coverage report failed. Please check the "Upload to codecov.io" step of Process Test Reports job for more details.

@github-actions
Copy link
Contributor

Warning

@KatherineInCode Uploading code coverage report failed. Please check the "Upload to codecov.io" step of Process Test Reports job for more details.

@github-actions
Copy link
Contributor

Warning

@KatherineInCode Uploading code coverage report failed. Please check the "Upload to codecov.io" step of Process Test Reports job for more details.

@github-actions
Copy link
Contributor

Warning

@KatherineInCode Uploading code coverage report failed. Please check the "Upload to codecov.io" step of Process Test Reports job for more details.

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 84.23237% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.93%. Comparing base (87e3a22) to head (23369d6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ication/Utilities/Mocks/MockUIViewController.swift 66.66% 32 Missing ⚠️
...I/Platform/Application/Utilities/Alert/Alert.swift 83.33% 1 Missing ⚠️
...ardenShared/UI/Auth/Landing/LandingProcessor.swift 0.00% 1 Missing ⚠️
...red/UI/Auth/VaultUnlock/VaultUnlockProcessor.swift 0.00% 1 Missing ⚠️
...tem/AddEditSendItem/AddEditSendItemProcessor.swift 0.00% 1 Missing ⚠️
.../UI/Vault/Vault/VaultList/VaultListProcessor.swift 0.00% 1 Missing ⚠️
GlobalTestHelpers/MockStackNavigator.swift 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2081      +/-   ##
==========================================
- Coverage   85.31%   82.93%   -2.39%     
==========================================
  Files        1693     1981     +288     
  Lines      144450   160987   +16537     
==========================================
+ Hits       123238   133512   +10274     
- Misses      21212    27475    +6263     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KatherineInCode
Copy link
Contributor Author

@claude The setKeyWindowRoot(viewController: UIViewController) function is in BitwardenBaseTestCase.

@claude
Copy link

claude bot commented Oct 29, 2025

Claude finished @KatherineInCode's task —— View job


Correction to Previous Review

  • Locate and read BitwardenBaseTestCase.swift
  • Verify setKeyWindowRoot(viewController:) method exists
  • Check inheritance relationship between BitwardenTestCase and BaseBitwardenTestCase
  • Update review with corrected information

Apology and Correction

You're absolutely correct, and I apologize for the error in my previous review.

The setKeyWindowRoot(viewController: UIViewController) method does exist and is located in:

  • File: TestHelpers/Support/BaseBitwardenTestCase.swift:122

Inheritance Chain Confirmed:

BitwardenTestCase (in BitwardenKit) 
  ↓ extends
BaseBitwardenTestCase (in TestHelpers)
  ↓ contains
setKeyWindowRoot(viewController: UIViewController) at line 122

The tests in AlertTests.swift and AlertPresentableTests.swift correctly call this method and will compile without issues.

Corrected Assessment

Previous Review Status: ❌ Critical Issue - INCORRECT
Updated Status: ✅ No compilation issues

The "critical issue" I flagged in my previous review was incorrect. The method exists in the parent class BaseBitwardenTestCase, which BitwardenTestCase properly inherits from. All test files have appropriate access to this method.

Updated PR Assessment

With this correction, the PR has:

  • ✅ No critical issues
  • ✅ Proper test infrastructure with correct inheritance
  • ✅ All required methods available through the inheritance chain
  • ⛏️ Minor documentation suggestions (as noted by @fedemkr)

The code consolidation work is sound and ready for merge pending any stylistic preferences from the team.


@KatherineInCode
Copy link
Contributor Author

@claude Regarding action item 1, those three things already have DocC comments.

Regarding action item 2, they are now in the correct order.

@claude
Copy link

claude bot commented Oct 29, 2025

Claude finished @KatherineInCode's task —— View job


Verifying Action Items

  • Read current state of MockUIViewController.swift
  • Verify DocC documentation for the three items
  • Verify method ordering
  • Provide updated assessment

Verification Results

You're absolutely correct on both points! I apologize for the confusion in my previous review. After reading the current state of MockUIViewController.swift, I can confirm:

✅ Action Item 1: DocC Documentation

All three items now have proper DocC comments:

  1. view property (lines 76-85): ✅ Has DocC

    /// Returns the mock view or the default view if no mock view is set.
    override public var view: UIView! {
  2. isViewLoaded property (lines 87-90): ✅ Has DocC

    /// Returns whether the mock view or default view is loaded.
    override public var isViewLoaded: Bool {
  3. loadView() method (lines 131-138): ✅ Has DocC

    /// Creates the view controller's view programmatically.
    /// Sets up a mock view with the predefined mock window size.
    override public func loadView() {

✅ Action Item 2: Method Ordering

The methods are now in the correct order per Swift style conventions:

  • reset() (public method) at line 190
  • setUpMockHierarchy() (private method) at line 208

Public methods correctly appear before private methods.


Updated Assessment

Both action items from my previous review have been properly addressed. The file now follows all project guidelines:

  • ✅ All public APIs have DocC documentation
  • ✅ Methods are ordered according to Swift conventions (public before private)
  • ✅ Code follows Bitwarden project standards

Thank you for addressing the feedback, and I apologize for any confusion caused by my initial review comments!


View job

@KatherineInCode KatherineInCode merged commit f90ffd8 into main Oct 30, 2025
16 checks passed
@KatherineInCode KatherineInCode deleted the pm-26060/consolidate-alert branch October 30, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants