Skip to content

diagram: remove dead non-cloud branch and isCloud param from adjustFlows (Flow.tsx) #822

Closed

Description

@bpowers

Problem

The private function adjustFlows(origStock, stock, flows, isCloud?) in src/diagram/drawing/Flow.tsx (defined at line 507) has two valve-fraction branches: an isCloud branch and a non-cloud (else) branch, selected by the optional isCloud?: boolean parameter (line 511).

The non-cloud branch and the isCloud parameter are unreachable dead code. adjustFlows has exactly one caller -- inside UpdateCloudAndFlow's straight-flow parallel-drag path in the same file:

flow = first(adjustFlows(origCloud, cloud, [flow], true));  // Flow.tsx:882

That caller always passes isCloud=true, so the else branch (the general signed formula) never executes. An in-code NOTE already documents this (Flow.tsx:642-644).

Deferred cleanup

Remove the dead non-cloud branch and the isCloud parameter, inlining the cloud formula, since the sole caller always passes true. This is behavior-preserving:

  • The full diagram jest suite passes.
  • New characterization tests pin the isCloud valve output for centered / off-center / zero-delta drags.

Why it matters

Maintainability: the function currently carries two deliberately-different valve formulas plus a branch that can never run, which is a hazard for future edits (a reader can't tell which branch is live without tracing the single caller). Removing it shrinks the surface and eliminates a misleading general-purpose signature.

Component

src/diagram -- src/diagram/drawing/Flow.tsx (adjustFlows, UpdateCloudAndFlow).

Context

Identified during a behavior-preserving dedup pass on flow-editing code (branch flow-editing-hardening). The current PR's scope explicitly kept both branches and only documented their difference -- replacing an old // FIXME: reduce this duplication comment with a precise explanation of how the two formulas differ, plus the unreachable-branch NOTE. This cleanup is the deferred follow-up.

Priority

Low (dead-code / tech-debt cleanup).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions