refactor(code-actions): unify quick fix providers with strategy pattern#46
refactor(code-actions): unify quick fix providers with strategy pattern#46
Conversation
📝 WalkthroughWalkthroughThis PR refactors the code-actions architecture by consolidating separate upgrade and vulnerability code-action providers into a unified QuickFixProvider, centralising extractor entries into a dedicated index module, and removing the upgrade message prefix constant. The changes involve moving Possibly related PRs
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/composables/active-extractor.ts (1)
4-4: Consider using the#extractorsalias for consistency.
src/providers/code-actions/index.ts(added in this same PR) imports via'#extractors', but this file still uses the relative path. Using the alias here would align both consumers.♻️ Suggested change
-import { extractorEntries } from '../extractors' +import { extractorEntries } from '#extractors'tests/code-actions/quick-fix.test.ts (1)
26-59: Consider adding negative/edge-case tests for the guard paths.The three existing scenarios cover all happy-path branches. The early-return guards in
QuickFixProvider(unknown code, no pattern match) are not exercised. Adding a couple of targeted tests would fully document expected no-op behaviour:♻️ Suggested additions
+ it('unknown diagnostic code returns no actions', () => { + const diagnostic = createDiagnostic('unrelated', 'some message') + expect(provideCodeActions([diagnostic])).toHaveLength(0) + }) + + it('known code with non-matching message returns no actions', () => { + const diagnostic = createDiagnostic('upgrade', 'No version info here') + expect(provideCodeActions([diagnostic])).toHaveLength(0) + })src/index.ts (1)
17-41: Optional: consider extracting hover and completion registrations into composables for consistency.The new
useCodeActions()pattern is cleaner than inlinewatchEffectblocks. The hover (lines 17–26) and completion (Lines 28–41) registrations follow the old pattern and could be similarly extracted (e.g.useHover(),useCompletion()) for uniformity. Not blocking — just a thought for a follow-up.
Unify separate providers into a single
QuickFixProviderthat dispatches by diagnostic code.