Skip to content

deactivateBlock: redundant field spread (durationMs/createdAt are no-ops) #48

Description

@ranxianglei

Context

v0.0.17, b9f9e99. In src/decompress.ts:58-66, deactivateBlock builds the updated block as:

const updated = state.blocks.map((block) => {
    if (!targets.has(block.blockId) || !block.active) return block;
    return {
        ...block,
        active: false,
        durationMs: block.durationMs,   // redundant: already in ...block
        createdAt: block.createdAt,     // redundant: already in ...block
    };
});

durationMs and createdAt are already covered by ...block. The two explicit lines assign each field to itself — a pure no-op.

Why it matters

It reads as if the code is resetting or preserving those fields deliberately (e.g. clearing durationMs). A maintainer scanning the function would reasonably wonder why those two are singled out. The actual effect is identical to:

return { ...block, active: false };

Suggested fix

Delete the two redundant lines:

return { ...block, active: false };

Severity

Low — noise only. No behavioral change either way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions