Repository navigation
refactor: remove unreachable default-value branches - #612
Merged
Merged
Conversation
A boxed Nullable<T> reports T from GetType(), so GetDefault never returns null for a value type and the '?? false' fallbacks in DefaultConstraint and NotDefaultConstraint cannot be reached. Activator.CreateInstance already returns null for Nullable<T>, which makes the explicit Nullable block in TypeExtensions.GetDefault redundant. No test can kill mutants in this code, so remove it. Also rename the misnamed GetDefault test.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #612 +/- ##
===========================================
+ Coverage 98.54% 100.00% +1.45%
===========================================
Files 22 22
Lines 274 261 -13
Branches 43 38 -5
===========================================
- Hits 270 261 -9
+ Misses 1 0 -1
+ Partials 3 0 -3 ☔ 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
Latest mutation run (40488172984): 193 mutants created,
36 mutants got status CompileError,37 mutants got status Ignored, score 78.33 %. According to the report, most of the compile errors (31 of 36) are "Linq method mutation (Append() to Prepend())" onStringBuilder.Appendchains inXUnitLogger.cs(not independently re-verified; the report JSON was not available when preparing this PR).src/has noSystem.Linqusage.Root cause
The Linq mutator matches by method name only, so
StringBuilder.Append()is treated asEnumerable.Append()and rewritten toPrepend(), which does not compile. The mutator is Standard level, so it is active under"mutation-level": "Advanced".Change
Add
"ignore-mutations": ["linq"]tostryker-config.json. Revisit this ifSystem.Linqis ever used insrc/.ignore-methodsforAppendwas deliberately not used because it would also drop real mutants on those lines.Before / After
Run: https://github.com/dailydevops/fluentvalue/actions/runs/40804569084 (success).
Result: 3 non-killed mutants removed (2 NoCoverage, 1 survivor), as predicted; killed dropped by 3 because equivalent mutants in the removed code disappeared. The score gain is modest (+1.25 points). The remaining 28 non-killed mutants (3 NoCoverage, 25 survived) are not addressed here.
Risk / what this does not change
Score should be unchanged: neither CompileError nor Ignored mutants count toward it. Success is measured by the CompileError and Ignored counts, not the total. Saves failed compile attempts, since ignored mutants are not compiled. No source or test changes.