[Review] computeMoodTrend has a dead/duplicated if/else if branch — both branches are identical except for a tautological condition #179

Closed
opened 2026-09-14 14:07:30 +00:00 by Mark · 1 comment
Owner

Finding

src/lib/intimate-state-engine.ts:223-231:

if (average7Day != null && average30Day != null && last30.length > last7.length) {
  delta = Math.round((average7Day - average30Day) * 10) / 10;
  if (delta > 0.3) direction = "rising";
  else if (delta < -0.3) direction = "declining";
} else if (average7Day != null && average30Day != null) {
  delta = Math.round((average7Day - average30Day) * 10) / 10;
  if (delta > 0.3) direction = "rising";
  else if (delta < -0.3) direction = "declining";
}

The else if branch is byte-for-byte identical to the if branch minus one condition. The extra condition last30.length > last7.length is always true by construction (last7 is filtered from last30), so the dead branch has no effect on behavior.

Suggested fix

Collapse to a single if (average7Day != null && average30Day != null) block. Three lines deleted, no semantic change.

Severity

Trivial. Dead code / readability. No runtime impact.

Discovered by

Manual code review pass over #168, 2026-09-14.

## Finding `src/lib/intimate-state-engine.ts:223-231`: ```ts if (average7Day != null && average30Day != null && last30.length > last7.length) { delta = Math.round((average7Day - average30Day) * 10) / 10; if (delta > 0.3) direction = "rising"; else if (delta < -0.3) direction = "declining"; } else if (average7Day != null && average30Day != null) { delta = Math.round((average7Day - average30Day) * 10) / 10; if (delta > 0.3) direction = "rising"; else if (delta < -0.3) direction = "declining"; } ``` The `else if` branch is byte-for-byte identical to the `if` branch minus one condition. The extra condition `last30.length > last7.length` is always true by construction (`last7` is filtered from `last30`), so the dead branch has no effect on behavior. ## Suggested fix Collapse to a single `if (average7Day != null && average30Day != null)` block. Three lines deleted, no semantic change. ## Severity Trivial. Dead code / readability. No runtime impact. ## Discovered by Manual code review pass over #168, 2026-09-14.
Mark closed this issue 2026-09-14 14:36:59 +00:00
Author
Owner

Closing as already-fixed.

Commit 82835c6 (fix(#179): collapse dead duplicate branch in computeMoodTrend) landed on main at 2026-09-14 (today, before this triage session reviewed the file).

The chat-agent code review read against a stale HEAD and reported this issue as open. The fix was already in place when the review started — the agent failed to re-check HEAD between reads.

No work to do.

Closing as already-fixed. Commit `82835c6` (`fix(#179): collapse dead duplicate branch in computeMoodTrend`) landed on `main` at 2026-09-14 (today, before this triage session reviewed the file). The chat-agent code review read against a stale HEAD and reported this issue as open. The fix was already in place when the review started — the agent failed to re-check HEAD between reads. No work to do.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/kimi_agent_kin_app_sync#179
No description provided.