Repository navigation
refactor: make ScopeHandler a sealed class to drop untestable equality members - #443
Merged
samtrion merged 1 commit intoOct 29, 2026
Merged
Conversation
…y members ScopeHandler was a readonly struct implementing IEquatable<T> with Equals, GetHashCode and ==/!= operators that no test can reach, since Scope() and ScopeLine() only expose IDisposable. They showed up as NoCoverage mutants in Stryker. A private sealed class needs none of them.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #443 +/- ##
==========================================
+ Coverage 91.76% 93.15% +1.39%
==========================================
Files 15 15
Lines 340 336 -4
Branches 100 99 -1
==========================================
+ Hits 312 313 +1
+ Misses 17 12 -5
Partials 11 11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
samtrion
deleted the
fix/stryker-scopehandler-untested-equality-members
branch
October 29, 2026 15:07
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
The latest Stryker run on
codebuilderreports 20 NoCoverage mutants ("Not covered by any test") out of 503 created. The private nestedScopeHandlerstruct inCSharpCodeBuilder.Scope.csdefinesEquals(object),Equals(ScopeHandler),GetHashCode()and==/!=. No test touches them and they are unreachable from outside:Scope()/ScopeLine()returnIDisposableand the type is private.Root cause
The struct implements
IEquatable<ScopeHandler>and the operators, most likely to satisfy analyzer rules for structs (not proven, there are no suppressions in the repo). The members are dead code.Change
private readonly struct ScopeHandler : IDisposable, IEquatable<ScopeHandler>becomesprivate sealed class ScopeHandler : IDisposablewith only the constructor andDispose. The five equality members and their docs are removed (4 lines added, 40 removed).Before / After
After run (single run, branch): https://github.com/dailydevops/codebuilder/actions/runs/40805882274. About 5 of the original 20 NoCoverage mutants sat in the removed members; the remaining 15 are elsewhere.
Risk / what this does not change
Behaviour is unchanged: the type is private and always returned as
IDisposable. The struct was already boxed on return, so there is no extra allocation in practice. Locally, the unit tests pass (395/395, net10.0) and the library compiles with 0 warnings.