Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@matt-livefront
Copy link
Collaborator

@matt-livefront matt-livefront commented Nov 13, 2025

🎟️ Tracking

PM-27216

📔 Objective

Sets up support for Sourcery in BitwardenKit.

⏰ 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

@matt-livefront matt-livefront requested a review from a team as a code owner November 13, 2025 22:00
@claude
Copy link

claude bot commented Nov 13, 2025

Claude finished @matt-livefront's task —— View job


Code Review Complete

PR Title and Description Quality

The PR title and description are clear and well-structured. The objective clearly explains what is being added (Sourcery support for BitwardenKit) and why. The PR references the appropriate Jira ticket.

Summary of Changes

This PR adds Sourcery support to BitwardenKit, enabling automatic mock generation for protocols marked with // sourcery: AutoMockable. The implementation follows the same pattern already established in BitwardenShared and AuthenticatorShared.

Key changes:

  • Added Sourcery configuration (sourcery.yml) for BitwardenKit
  • Added .gitignore for generated mock files
  • Integrated Sourcery into the build process via project-bwk.yml
  • Removed manual MockActiveAccountStateProvider in favor of auto-generated mock
  • Updated ErrorReportBuilderTests.swift to use the auto-generated mock from BitwardenKitMocks
  • Minor whitespace fix in FeatureFlag.swift (trailing whitespace removal)

Findings

Finding 1: BitwardenKit Sourcery configuration lacks consistency with sibling projects (🎨)

The sourcery.yml for BitwardenKit specifies different imports than BitwardenShared and AuthenticatorShared:

BitwardenKit (BitwardenKit/Sourcery/sourcery.yml:16-18):

args:
  autoMockableImports: ["Combine"]
  autoMockableTestableImports: ["BitwardenKit"]

BitwardenShared (BitwardenShared/Sourcery/sourcery.yml:16-18):

args:
  autoMockableImports: ["BitwardenKit", "BitwardenSdk", "Combine"]
  autoMockableTestableImports: ["BitwardenShared"]

Analysis: BitwardenKit's configuration is correct for its current needs since it only depends on Combine and doesn't use BitwardenSdk. However, the pattern suggests BitwardenKit is a lower-level framework that other modules depend on. The configuration appropriately reflects this dependency hierarchy.

Recommendation: Consider documenting in the sourcery.yml file why the imports differ from sibling projects (e.g., "BitwardenKit is a foundational framework with minimal dependencies"). This would help future maintainers understand the intentional difference.


Finding 2: Generated mocks directory structure could benefit from documentation (💭)

The PR adds BitwardenKit/Sourcery/Generated/.gitignore to exclude generated Swift files from version control. While this follows the existing pattern, the build configuration in project-bwk.yml:169-170 includes the generated file as optional:

- path: BitwardenKit/Sourcery/Generated/AutoMockable.generated.swift
  optional: true

Question: Is there a reason the generated mock file is marked as optional: true rather than being a required build input? This differs from how the file is treated in the output files specification (project-bwk.yml:155-156), where it's listed as a build output but not marked optional.

Observation: The optional: true marking appears intentional to allow builds to succeed even if Sourcery hasn't run yet (e.g., fresh checkout), but this should be verified.


Good Practices Observed

  • ✅ Follows established Sourcery patterns from BitwardenShared and AuthenticatorShared
  • ✅ Properly configures build phase with basedOnDependencyAnalysis: false to ensure Sourcery runs every build
  • ✅ Correctly specifies output file location for Xcode's dependency tracking
  • ✅ Uses .gitignore to exclude generated files from version control
  • ✅ Updates test to import from BitwardenKitMocks instead of using manual mock
  • ✅ Maintains consistent file structure with sibling projects
  • ✅ The manual mock deletion demonstrates proper migration to auto-generated mocks

Action Items

  1. [Optional] Add a comment to BitwardenKit/Sourcery/sourcery.yml explaining the minimal import configuration
  2. [Optional] Verify CI passes to ensure Sourcery integration works correctly in CI environment
  3. [Verification] Confirm that the optional: true marking for the generated mock file is intentional and appropriate for the build workflow

Technical Notes

Architecture Compliance: ✅ This change aligns with the project's testing architecture (see Docs/Testing.md:389-394), which explicitly mentions using Sourcery's AutoMockable annotation for mock generation.

Pattern Consistency: ✅ The implementation exactly mirrors the approach in BitwardenShared and AuthenticatorShared, demonstrating excellent consistency across the codebase.

Security Considerations: ✅ No security implications—this is a testing infrastructure change only.


Overall Assessment: This is a clean, well-executed PR that properly sets up Sourcery for BitwardenKit following established patterns. The findings above are minor improvement suggestions rather than blocking issues. The code is ready for merge pending CI verification.

@github-actions
Copy link
Contributor

Logo
Checkmarx One – Scan Summary & Detailsd9188d81-94bb-49c9-8cb0-63f923205758

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

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.77%. Comparing base (e8d7c67) to head (fa17853).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2136      +/-   ##
==========================================
- Coverage   85.23%   83.77%   -1.47%     
==========================================
  Files        1715     1969     +254     
  Lines      145524   160759   +15235     
==========================================
+ Hits       124042   134678   +10636     
- Misses      21482    26081    +4599     

☔ 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.

@matt-livefront matt-livefront merged commit ab5216a into main Nov 14, 2025
18 checks passed
@matt-livefront matt-livefront deleted the matt/PM-27216-bwk-sourcery branch November 14, 2025 16:41
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.

3 participants