Repository navigation
fix: remove always-false conditions flagged by SonarCloud - #1604
Merged
Merged
Conversation
Drop redundant null checks that the analyzer reports as constantly false: - MemoizingMRUCache.InvalidateAll: oldEntries is guaranteed assigned on the only path that exits the lock without returning, so `oldEntries is null` is always false. Declare it non-nullable (satisfying nullable flow) and remove the dead disjunct. - NinjectDependencyResolver UnregisterCurrent/UnregisterAll (x4): the result of kernel.GetBindings(...).ToArray() is never null, so `bindings is null` is always false. Check only the length. Behaviour is unchanged; both projects build clean under -warnaserror.
ChrisPulman
approved these changes
Jun 12, 2026
glennawatson
enabled auto-merge (squash)
June 12, 2026 11:12
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1604 +/- ##
==========================================
- Coverage 82.30% 82.23% -0.08%
==========================================
Files 124 124
Lines 7036 7036
Branches 1080 1080
==========================================
- Hits 5791 5786 -5
- Misses 937 940 +3
- Partials 308 310 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.



What kind of change does this PR introduce?
Bug fix / code-smell cleanup (no behavioural change).
What is the new behavior?
Removes redundant conditions that SonarCloud reports as always evaluating to
False:Splat.Logging/MemoizingMRUCache.cs(InvalidateAll) —oldEntriesis guaranteed to be assigned on the only path that leaves the lock without returning, sooldEntries is nullwas always false. The local is now declared non-nullable (which also satisfies nullable flow analysis) and the dead disjunct is gone, leaving the meaningful_releaseFunction is nullguard.Splat.Ninject/NinjectDependencyResolver.cs(UnregisterCurrent/UnregisterAll, 4 sites) —kernel.GetBindings(serviceType).ToArray()never returns null, sobindings is nullwas always false. The guards now check onlybindings.Length < 1.What is the current behavior?
The code carried redundant
x is nullchecks that the analyzer flagged as always-false (MemoizingMRUCache.csL268;NinjectDependencyResolver.csL361, L383, L413, L438) — five Major "Code Smell" maintainability issues.What might this PR break?
None. Every removed sub-condition was provably unreachable, so behaviour is identical. Public API is unchanged.
Checklist
mainbranchAdditional information
No tests added — the changes are behaviour-preserving removals of dead conditions. Existing suites pass (Ninject 83, MemoizingMRUCache 27/27) and both projects build clean under
-warnaserror.