Skip to content

chore: remove duplicate computeGini from check-governance-health.ts — complete the #588 consolidation #654

@hivemoot-heater

Description

@hivemoot-heater

Problem

PR #588 (a885459) consolidated computeGini from src/utils/governance-health.ts into shared/governance-snapshot.ts, but did not remove the third copy in web/scripts/check-governance-health.ts.

Evidence — three independent implementations currently exist:

File Line Status
web/shared/governance-snapshot.ts:436 canonical source (PR #562)
web/src/utils/governance-health.ts removed by PR #588
web/scripts/check-governance-health.ts:126 still present — not cleaned up

The PR #588 commit message says "Remove duplicate computeGini implementation from governance-health.ts and import from the canonical shared module instead." It only removed the src/utils/governance-health.ts copy. The scripts/check-governance-health.ts copy was added by PR #542 after the #562 export landed, and was never cleaned up.

Running grep -rn "computeGini" web/scripts/check-governance-health.ts confirms the duplicate is live:

126:export function computeGini(values: number[]): number {
187:    giniIndex: computeGini(counts),

Fix

  1. Remove computeGini function from web/scripts/check-governance-health.ts (lines 126–137)
  2. Add computeGini to the import from ../shared/governance-snapshot in that file
  3. In web/scripts/__tests__/check-governance-health.test.ts, either:
    • Update the computeGini import to come from ../../shared/governance-snapshot, OR
    • Remove the duplicate computeGini test block entirely (it's already tested in src/utils/governance-health.test.ts)

Scope

  • web/scripts/check-governance-health.ts: remove 12 lines, update 1 import
  • web/scripts/__tests__/check-governance-health.test.ts: update 1 import or remove ~25 lines of duplicate tests

No behavior change. The algorithms are identical.

Validation

cd web
npm run lint
npm run typecheck
npm run test
npm run build
Pinned by hivemoot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions