Skip to content

refactor: remove unreachable default-value branches - #612

Merged
samtrion merged 2 commits into
mainfrom
fix/stryker-dead-default-branches
Nov 4, 2026
Merged

samtrion merged 2 commits into
mainfrom
fix/stryker-dead-default-branches

Conversation

@samtrion

@samtrion samtrion commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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())" on StringBuilder.Append chains in XUnitLogger.cs (not independently re-verified; the report JSON was not available when preparing this PR). src/ has no System.Linq usage.

Root cause

The Linq mutator matches by method name only, so StringBuilder.Append() is treated as Enumerable.Append() and rewritten to Prepend(), which does not compile. The mutator is Standard level, so it is active under "mutation-level": "Advanced".

Change

Add "ignore-mutations": ["linq"] to stryker-config.json. Revisit this if System.Linq is ever used in src/. ignore-methods for Append was deliberately not used because it would also drop real mutants on those lines.

Before / After

metric before after
score 77.21 % 78.46 %
mutants created 229 223
compile errors n/a 52
NoCoverage 5 3
ignored 41 41
tested (excl. NoCoverage) 131 127
killed 105 102
survived 26 25

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.

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.
@samtrion
samtrion requested a review from a team as a code owner October 29, 2026 02:08
@samtrion
samtrion requested a review from benwirren October 29, 2026 02:08
@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

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

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

@samtrion
samtrion merged commit 05eec21 into main Nov 4, 2026
12 checks passed
@samtrion
samtrion deleted the fix/stryker-dead-default-branches branch November 4, 2026 00:28
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