Skip to content

refactor: audit zero-coverage and unreachable code #10866

Description

@ReubenBond

Goal

Classify zero-coverage source and unsupported-code paths, then remove dead code, simplify unreachable branches, or add focused contract tests. Denominator reductions must represent real maintenance reduction rather than metric gaming.

Coverage report: https://github.com/dotnet/orleans/runs/98679059570

Evidence

The merged report contains approximately:

  • 155 entirely uncovered files with more than 4,300 executable line entries in the method-level report.
  • 458 methods with CRAP scores above 30.
  • 7,197 methods below the 90% line / 80% branch analysis thresholds.
  • 127 explicit NotImplementedException or NotSupportedException sites, many uncovered.

Strong investigation candidates include:

  • MessagingEvents.cs: conditionally compiled emitters with no discovered MESSAGING_TRACE definition.
  • IJournaledState.DeepCopy() implementations which throw and have no discovered production caller.
  • Orleans.TestingHost/Utils/StorageEmulator.cs: legacy Windows Azure Storage Emulator integration while CI uses Azurite.
  • Unreferenced compiler helpers such as MethodSignatureComparer and unused instance/stream hashing APIs.
  • Shared/linked source whose repeated assembly entries distort method-level coverage.

Known reachable/intentional paths must not be removed solely because they are uncovered, including stream producer callbacks, codec rejection contracts, public compatibility APIs, and extension-point virtual methods.

Work

  • Inventory every entirely uncovered maintained source file.
  • Inventory explicit throw sites and non-API [ExcludeFromCodeCoverage] uses.
  • Classify each item as dead, generated/reference-only, platform-specific, intentional unsupported behavior, shipped test support, or missing tests.
  • Require call-site, reflection/source-generation, public API, and package compatibility evidence before removal.
  • Remove dead private/internal code and obsolete infrastructure.
  • Add negative tests and clear contracts for intentional unsupported paths.
  • Narrowly exclude only mechanically generated or structurally untestable code, with rationale and configuration tests.
  • Report removed/excluded lines separately from newly covered lines.

Acceptance criteria

  • Every zero-coverage maintained file and explicit throw site has a recorded classification.
  • Confirmed dead code is removed with build/API validation.
  • Intentional unsupported behavior has focused tests.
  • Coverage exclusions remain narrow, reviewable, and protected against broadening.
  • The resulting coverage increase can be decomposed into test gains, code removal, and approved scope corrections.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions