Repository navigation
test(analyzer): exercise using insertion in NE0010 code fix - #230
Merged
Merged
Conversation
The NE0010 code-fix tests named AddsUsing / UsingInsertedAtNamespaceLevel already contained 'using System.Threading;' in their input, so the fix returned early and never ran EnsureSystemThreadingUsing's insertion branches (11 NoCoverage and 13 Survived mutants in the mutation report). Drop the directive from the input of those three tests (the helper now uses the fully qualified CancellationToken) so the using is really inserted at compilation-unit, file-scoped and block-scoped namespace level, before an existing using. Add a block-scoped case where the new using sorts last, covering the indentation carried over from the first existing using.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #230 +/- ##
==========================================
+ Coverage 94.72% 95.54% +0.82%
==========================================
Files 48 48
Lines 2557 2557
Branches 449 449
==========================================
+ Hits 2422 2443 +21
+ Misses 58 41 -17
+ Partials 77 73 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Mutation report for
Usage/RequireCancellationTokenParameterCodeFixProvider.cs, lines 236-312 (EnsureSystemThreadingUsing,InsertAlphabetically,RemoveLeadingBlankLines): 11 NoCoverage and 13 Survived mutants (29 Killed, 23 Survived, 11 NoCoverage in the file, excluding CompileError and Ignored). The testsNoParameters_AppendsTokenAndAddsUsing,FileScopedNamespace_UsingInsertedAtNamespaceLevelandBlockScopedNamespaceWithExistingUsings_UsingInsertedAtNamespaceLevelclaim to test using insertion.Root cause
All three tests have
using System.Threading;already in their input, so the fix returns atif (hasUsing) return rootand never runs the insertion code. The only real insertion tests reach just the append-at-end branch.Change
using System.Threading;from the input of the three tests and fully qualifySystem.Threading.CancellationTokenin the helper (input and expected output). The using is now inserted at compilation-unit, file-scoped and block-scoped namespace level, before an existingusing System.Threading.Tasks;(insert-before branch, leading-blank-line removal).BlockScopedNamespaceNewUsingSortsAfterAllExisting_AppendedWithIndentation: the new using sorts last inside an indented block namespace, covering the append branch that copies the first using's leading trivia.Test-only change; no product code touched.
Before / After
Measured with the mutation workflow dispatched on this branch: https://github.com/dailydevops/analyzer/actions/runs/40815375432 (before: latest successful run on main, 2026-10-27). The per-file score is not printed in the log, so the comparison is on whole-run totals.
Result: 9 NoCoverage mutants are now covered and 8 more are killed, but the Survived count did not change. The gain (+0.68 points) is below the estimated 1.0-1.4 points; the 13 survivors in lines 236-301 (trailing-trivia fallback,
existingUsinglogic) are not affected by these tests.Risk / what this does not change
No product code changes. Not addressed: line 270 (dead ternary,
Usings.Countis always 0 there, equivalent mutants) and lines 246-247 (CRLF versus LF trailing trivia fallback, would need brittle CRLF input). Realistic expectation is roughly 14-19 fewer survivors/NoCoverage, not the full 24.