Skip to content

Conversation

@michaelversus
Copy link
Owner

🏗️ Improve Architecture & Add Comprehensive Test Coverage

Summary

This MR refactors the IndexStore module with protocol-based abstractions, enabling full testability while maintaining the same runtime behavior. Adds 800+ lines of new tests covering the core symbol search functionality.

Changes

🎯 Architecture Improvements

New File Purpose
IndexStoreProviding.swift Protocol abstractions for IndexStore, UnitReader, RecordReader, and SymbolOccurrence
IndexStore+Providing.swift Conformance of Apple's IndexStore types to the new protocols
RecordIndex.swift Encapsulates record name → source file path mapping
SymbolQuery.swift Encapsulates symbol search criteria with matching logic
SymbolKind+Parsing.swift Extracts SymbolKind parsing into a clean extension
SymbolMatching.swift Protocol for symbol comparison, enabling mock injection

✅ Test Coverage Added

Test File Tests
IndexStoreFinderTests.swift +324 lines – Mock-based tests for parallel search, filtering, edge cases
RecordIndexTests.swift +297 lines – Building index, source path resolution, deduplication
SymbolQueryTests.swift +183 lines – Name matching, kind filtering, all symbol types

🔧 Other Changes

  • Updated README to highlight parallel scanning capability
  • Bumped version: 0.1.50.2.1
  • Introduced ThreadSafeSet for cleaner concurrent result collection
  • Added @preconcurrency import IndexStore for Swift 6 compatibility

Why This Matters

  • Testability: Core search logic is now fully testable without hitting the filesystem
  • Separation of Concerns: Each struct has a single responsibility
  • Maintainability: Protocol boundaries make it easy to swap implementations or extend functionality
  • Confidence: 800+ lines of tests ensure refactoring didn't break existing behavior

@michaelversus michaelversus self-assigned this Jan 14, 2026
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 97.40260% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.50%. Comparing base (e84774f) to head (242a716).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...wiftFindRefs/IndexStore/IndexStore+Providing.swift 0.00% 13 Missing ⚠️
...ts/SwiftFindRefs/IndexStore/RecordIndexTests.swift 98.94% 2 Missing ⚠️
...es/SwiftFindRefs/IndexStore/IndexStoreFinder.swift 96.87% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master       #2      +/-   ##
==========================================
+ Coverage   87.64%   95.50%   +7.85%     
==========================================
  Files          14       20       +6     
  Lines         502     1089     +587     
==========================================
+ Hits          440     1040     +600     
+ Misses         62       49      -13     

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

@michaelversus michaelversus merged commit 54f5ed5 into master Jan 14, 2026
1 check passed
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