"use strict";
/**
 * Testing dimension — declarative scoring spec.
 *
 * Methodology: additive checklist over test-discipline signals (test
 * ratio, coverage-config presence, runner exit code, line-coverage
 * thresholds) gated on test-file presence, plus a hygiene penalty
 * for source that's predominantly commented-out code.
 *
 * Industry-conventional coverage thresholds: 60% (adequate), 80%
 * (excellent). Sources: CodeClimate default config, SonarQube's
 * Coverage on New Code quality-gate condition (default 80%), Google
 * Testing on the Toilet recommendations. These thresholds are the
 * de-facto convention; dxkit adopts them.
 *
 * Cap rule encodes the Label Contract: when coverage data is absent
 * the dimension can't honestly claim a top-tier rating regardless of
 * how many test files exist — file presence + a green exit code
 * without line-coverage measurement is failing the most basic
 * testing-discipline check.
 *
 *   unmeasured (35)   no coverage data available
 *
 * Source signal flow: the adapter (`src/analyzers/tests/shallow.ts`)
 * builds `TestingScoreInput` from the health-side ScoreInput
 * (HealthMetrics + CapabilityReport) and dispatches through
 * `evaluateSpec`. The standalone test-gaps subcommand uses its own
 * separate analyzer; this dimension only feeds the health rollup.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TESTING_SCORING_SPEC = void 0;
exports.TESTING_SCORING_SPEC = {
    dimension: 'testing',
    methodology: 'industry-coverage-thresholds',
    // Additive baseline: every positive-delta signal contributes
    // points; the zero-tests deduction surfaces the most-actionable
    // customer case (no tests at all) with a real Top Action.
    baseline: 0,
    penalties: [
        {
            id: 'no-tests-found',
            describe: (i) => `no test files found across ${i.sourceFiles} source files (start with the highest-risk untested files — see test-gaps)`,
            applies: (i) => i.testFiles === 0,
            // -60 mirrors the max bonus the test-ratio rule could grant at
            // a healthy ratio. The score floors at 0 (E) either way, but
            // surfacing the deduction makes the dimension actionable: the
            // renderer shows "+60 — would lift rating E → C" and the
            // severe-debt disclosure fires.
            delta: () => -60,
        },
        {
            id: 'test-ratio',
            describe: (i) => `${i.testFiles} test files for ${i.sourceFiles} source files ` +
                `(${((i.testFiles / Math.max(i.sourceFiles, 1)) * 100).toFixed(1)}% ratio)`,
            applies: (i) => i.testFiles > 0,
            delta: (i) => Math.min((i.testFiles / Math.max(i.sourceFiles, 1)) * 200, 60),
        },
        {
            id: 'coverage-config-present',
            describe: () => `coverage config detected`,
            applies: (i) => i.testFiles > 0 && i.coverageConfigExists,
            delta: () => 10,
        },
        {
            id: 'tests-passing',
            describe: () => `test runner reports green`,
            applies: (i) => i.testFiles > 0 && i.testsPass === true,
            delta: () => 15,
        },
        {
            id: 'coverage-adequate',
            describe: (i) => `line coverage ${i.coveragePercent}% (≥ 60% threshold met)`,
            applies: (i) => i.testFiles > 0 && i.coveragePercent !== null && i.coveragePercent >= 60, // scoring-spec-ok: industry coverage threshold, not a rating boundary
            delta: () => 10,
        },
        {
            id: 'coverage-excellent',
            describe: (i) => `line coverage ${i.coveragePercent}% (≥ 80% threshold met)`,
            applies: (i) => i.testFiles > 0 && i.coveragePercent !== null && i.coveragePercent >= 80, // scoring-spec-ok: industry coverage threshold, not a rating boundary
            delta: () => 5,
        },
        {
            id: 'commented-code-density',
            describe: (i) => `${((i.commentedCodeRatio ?? 0) * 100).toFixed(0)}% of source is commented-out code`,
            applies: (i) => i.commentedCodeRatio !== null && i.commentedCodeRatio > 0.5,
            delta: () => -15,
        },
    ],
    caps: [
        {
            id: 'coverage-unmeasured',
            tier: 'unmeasured',
            describe: () => `no coverage data available — test runner did not produce a coverage artifact`,
            applies: (i) => i.coveragePercent === null,
        },
    ],
};
//# sourceMappingURL=testing.js.map