Skip to content

test(review): cover the src/ linked-issue-hard-rules-config normalizer branches (62.50% branch coverage) #5845

Description

@JSONbored

Context

src/review/linked-issue-hard-rules-config.ts is a byte-identical "twin" of the canonical
packages/loopover-engine/src/review/linked-issue-hard-rules-config.ts (they differ only in the
types import path — a deliberate directory-scanned parity pair, same pattern as the recent
#5779/#4879 engine extractions). The engine copy has full branch coverage via
test/unit/linked-issue-hard-rules-config-engine.test.ts, but the src/ twin's own test
(test/unit/linked-issue-hard-rules.test.ts) only exercises a subset of its normalizer branches,
leaving several src/-side branches never taken by any test that imports from ../../src/review/linked-issue-hard-rules-config. A local unsharded npm run test:coverage run confirms the file sits at
62.50% branch coverage (20/32).

Specifically untested branches in the src/ copy (functions normalizeMode, normalizeBoolean,
normalizeCloseDelaySeconds, normalizeStringList, normalizeLinkedIssueHardRulesConfig):

  • normalizeMode (line 44-49): the value === undefined branch (return the field default) and the
    invalid-string branch (push a warning, fall back to default) are never hit — the existing test only
    passes a valid mode ("block") for one field.
  • normalizeBoolean (line 51-56): both the undefined branch and the wrong-type branch (e.g. a
    string/number instead of boolean) are untested.
  • normalizeCloseDelaySeconds (line 58-65): the undefined branch, the invalid-value branch
    (negative / NaN / non-number → warning + DEFAULT_CLOSE_DELAY_SECONDS), and the valid-but-clamped
    branch (Math.min(MAX_CLOSE_DELAY_SECONDS, Math.floor(value))) are all untested against the src/
    export.
  • normalizeLinkedIssueHardRulesConfig (line 67-68): the top-level input === undefined branch is
    untested.

Because this is a scored src/** file, any future PR that legitimately touches one of these
functions inherits the 99% Codecov patch gate on lines it didn't even mean to change — closing this
gap now removes that latent trap.

Requirements

Add test cases to test/unit/linked-issue-hard-rules.test.ts (import stays
from "../../src/review/linked-issue-hard-rules-config") that exercise, for the src/ export
specifically:

  1. normalizeLinkedIssueHardRulesConfig(undefined, warnings) returns the all-off default.
  2. A mode field given an invalid string (e.g. "sometimes") falls back to its default and pushes a
    warning naming the field.
  3. A mode field omitted (undefined) resolves to its own default (not just tested implicitly via the
    top-level default case).
  4. defaultLabelRepo / verifyBeforeClose each get a non-boolean value (falls back + warns) and an
    omitted value (falls back to default silently).
  5. closeDelaySeconds: omitted (default 30), negative (warns, falls back to 30), NaN (warns, falls
    back to 30), a fractional value under the cap (floors it), and a value above
    MAX_CLOSE_DELAY_SECONDS (clamps to 300).

Deliverables

  • New/expanded it(...) blocks in test/unit/linked-issue-hard-rules.test.ts covering the five
    requirement groups above, each asserting both the returned value and the pushed warning text
    where applicable.

Test Coverage Requirements

This repo's Codecov codecov/patch gate is 99%+ branch-counted and hard on every changed line. Since
this issue's fix only adds test file lines (not src/** lines), it owes no new patch coverage
itself — but it should bring src/review/linked-issue-hard-rules-config.ts's own branch coverage from
62.50% to 100%, matching its engine twin.

Expected Outcome

src/review/linked-issue-hard-rules-config.ts reaches (or is verified to already effectively reach,
once these cases are added) 100% branch coverage, so the src/ twin's test suite is no longer
silently thinner than its packages/loopover-engine counterpart.

Links & Resources

  • src/review/linked-issue-hard-rules-config.ts
  • packages/loopover-engine/src/review/linked-issue-hard-rules-config.ts (fully-covered twin, use its
    test file test/unit/linked-issue-hard-rules-config-engine.test.ts as the pattern to mirror)
  • test/unit/linked-issue-hard-rules.test.ts (file to extend)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions