mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
Remove two refusals that could not refuse anything
The recipe boundary opened with an early return for a missing date and another for a date it could not read. Deleting either one changed no answer any test or any caller could observe: both cases parse to NaN, and every comparison against NaN is already false, so the refusal was falling out of the arithmetic underneath them. An if that cannot change an outcome is a comment wearing a keyword, and it invites the next reader to trust a lock that is not attached to anything. The behaviour is unchanged and now has one statement instead of three, with the reason written where the next person will look for it. The seam had the same shape in miniature: a day naming no recipe was already broken away from a day that named one, by plain inequality, so the arm only ever mattered when two consecutive days both named none. That case is now covered, and removing the arm makes it fail.
This commit is contained in:
1 parent
3406ed6946
commit
98eb609eb1
2 files changed
+24
-10
No files matched your search
@@ -403,11 +403,23 @@ describe("the seam", () => {
|
||||
});
|
||||
|
||||
it("treats a day that names no recipe as a break rather than a link", () => {
|
||||
const points = scoreSeriesSeams([
|
||||
day("2026-08-19", null),
|
||||
day("2026-08-20", 1),
|
||||
]);
|
||||
expect(points[1].seamBreak).toBe(true);
|
||||
// Both directions, including two unknowns in a row. Without the
|
||||
// second case the arm would be doing nothing that plain inequality
|
||||
// does not already do: `null !== 1` breaks on its own, while
|
||||
// `null !== null` would quietly claim two rows share a basis that
|
||||
// neither of them names.
|
||||
expect(
|
||||
scoreSeriesSeams([day("2026-08-19", null), day("2026-08-20", 1)])[1]
|
||||
.seamBreak,
|
||||
).toBe(true);
|
||||
expect(
|
||||
scoreSeriesSeams([day("2026-08-19", 1), day("2026-08-20", null)])[1]
|
||||
.seamBreak,
|
||||
).toBe(true);
|
||||
expect(
|
||||
scoreSeriesSeams([day("2026-08-19", null), day("2026-08-20", null)])[1]
|
||||
.seamBreak,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("breaks the composite line and never rejoins it", () => {
|
||||
|
||||
@@ -235,17 +235,19 @@ function comparableDynamicPillars(
|
||||
*
|
||||
* No date means nothing to compare, and that does not suppress:
|
||||
* refusing every delta forever over an unreadable timestamp would trade
|
||||
* one silent lie for a permanent silence.
|
||||
* one silent lie for a permanent silence. Both cases — an account that
|
||||
* never chose, and a stored date this build cannot read — parse to NaN,
|
||||
* and every comparison against NaN is false, so the refusal falls out
|
||||
* of the arithmetic. Two early returns stood here and neither could
|
||||
* change an answer, which makes them a comment wearing an `if`.
|
||||
*/
|
||||
export function crossesConfigBoundary(
|
||||
boundary: ScoreConfigBoundary,
|
||||
previousAt: Date,
|
||||
asOf: Date,
|
||||
): boolean {
|
||||
if (boundary.changedAt === null) return false;
|
||||
const changedAt = new Date(boundary.changedAt);
|
||||
if (Number.isNaN(changedAt.getTime())) return false;
|
||||
return asOf >= changedAt && previousAt < changedAt;
|
||||
const changedAt = Date.parse(boundary.changedAt ?? "");
|
||||
return asOf.getTime() >= changedAt && previousAt.getTime() < changedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user