Skip to content

Fix generateMock fixit insertion order#230

Merged
dfed merged 3 commits into
mainfrom
dfed--fix-generateMock-fixit-insertion-order
Apr 9, 2026
Merged

Fix generateMock fixit insertion order#230
dfed merged 3 commits into
mainfrom
dfed--fix-generateMock-fixit-insertion-order

Conversation

@dfed
Copy link
Copy Markdown
Owner

@dfed dfed commented Apr 8, 2026

Summary

  • The addGenerateMockArgument fixit was appending generateMock: true to the end of the @Instantiable argument list, placing it after customMockName and producing invalid parameter ordering
  • Now inserts generateMock: true directly before the customMockName argument to match the declared parameter order

Test plan

  • Added fixedSource verification to producesDiagnostic_whenCustomMockNameIsSetWithoutGenerateMock (struct path)
  • Added fixedSource verification to extension_producesDiagnostic_whenCustomMockNameIsSetWithoutGenerateMock (extension path)
  • Added fixItInsertsGenerateMockBeforeCustomMockName_whenOtherArgumentsArePresent to test with preceding arguments like isRoot: true
  • Full test suite passes (768 tests)

🤖 Generated with Claude Code

The addGenerateMockArgument fixit was appending `generateMock: true`
to the end of the argument list, placing it after `customMockName`.
This produced invalid parameter ordering like
`@Instantiable(customMockName: "x", generateMock: true)` instead of
`@Instantiable(generateMock: true, customMockName: "x")`.

Insert `generateMock: true` directly before the `customMockName`
argument to preserve the declared parameter order.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 8, 2026

Codecov Report

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

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #230   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           39        39           
  Lines         6015      6020    +5     
=========================================
+ Hits          6015      6020    +5     
Files with missing lines Coverage Δ
...ources/SafeDIMacros/Macros/InstantiableMacro.swift 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dfed and others added 2 commits April 8, 2026 15:44
The preceding argument in a parsed argument list always has a trailing
comma, so the guard was unreachable. Add the extension-path test with
preceding arguments for full coverage of both code paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move argument list and customMockName index extraction to the call
sites, which already validate these values exist. The method now takes
the pre-validated LabeledExprListSyntax and integer offset directly,
eliminating all force unwraps and unreachable guard branches.

Also adds the extension-path test with preceding arguments for
complete coverage of both struct and extension code paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dfed dfed merged commit 3233c57 into main Apr 9, 2026
19 checks passed
@dfed dfed deleted the dfed--fix-generateMock-fixit-insertion-order branch April 9, 2026 01:12
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.

1 participant