/** * Half-open line+column range in original source coordinates. * startLine is 1-based inclusive, endLine is exclusive. * Columns are 0-based (matches typescript-eslint and Istanbul conventions). * * IMPORTANT: Both typescript-eslint (ESTree loc) and Istanbul use INCLUSIVE endLine. * Adapters MUST convert to exclusive: domainEndLine = sourceEndLine + 1. */ interface SourceSpan { readonly startLine: number; readonly startColumn: number; readonly endLine: number; readonly endColumn: number; } type ContributorKind = "if-branch" | "ternary" | "for-loop" | "while-loop" | "do-while-loop" | "catch" | "case-branch" | "logical-operator" | "optional-chain"; interface ComplexityContributor { readonly kind: ContributorKind; readonly line: number; readonly column: number; readonly operator?: string; } type BreakdownMode = "all" | "exceeding" | "off"; interface FunctionIdentity { readonly filePath: string; readonly qualifiedName: string; readonly span: SourceSpan; readonly signature?: string; } interface FunctionComplexity { readonly identity: FunctionIdentity; readonly cyclomaticComplexity: number; readonly contributors: ReadonlyArray; } interface CoverageRatio { readonly covered: number; readonly total: number; readonly percent: number; } interface FunctionCoverage { readonly filePath: string; readonly name: string; readonly span: SourceSpan; readonly lineCoverage: CoverageRatio; readonly branchCoverage: CoverageRatio | null; } declare enum RiskLevel { Low = "low", Acceptable = "acceptable", Moderate = "moderate", High = "high" } interface CrapScore { readonly value: number; readonly riskLevel: RiskLevel; } interface ScoredFunction { readonly identity: FunctionIdentity; readonly cyclomaticComplexity: number; readonly coveragePercent: number; readonly crap: CrapScore; readonly contributors: ReadonlyArray; } interface FunctionVerdict { readonly scored: ScoredFunction; readonly threshold: number; readonly exceeds: boolean; } type UnmatchedFunction = { readonly kind: "no-coverage"; readonly complexity: FunctionComplexity; readonly worstCaseCrap: CrapScore; } | { readonly kind: "no-ast"; readonly coverage: FunctionCoverage; }; type WarningCode = "unmatched-no-coverage" | "unmatched-no-ast" | "approximate-span" | "missing-coverage-file" | "filter-excluded-all"; interface Warning { readonly code: WarningCode; readonly message: string; readonly file?: string; readonly function?: string; } interface RiskDistribution { readonly [RiskLevel.Low]: number; readonly [RiskLevel.Acceptable]: number; readonly [RiskLevel.Moderate]: number; readonly [RiskLevel.High]: number; } interface AnalysisSummary { /** * Count of entries in `AnalysisResult.functions`. * Includes unmatched complexity entries scored at 0% coverage. */ readonly totalFunctions: number; readonly totalFiles: number; readonly exceedingThreshold: number; readonly exceedingPercent: number; readonly averageCrap: number; readonly medianCrap: number; readonly maxCrap: CrapScore; readonly worstFunction: FunctionIdentity | null; readonly distribution: RiskDistribution; readonly crapLoad: number; } interface ThresholdConfig { readonly defaultThreshold: number; readonly overrides: readonly ThresholdOverride[]; } interface ThresholdOverride { readonly glob: string; readonly threshold: number; } type ThresholdPreset = "strict" | "default" | "lenient"; interface AnalysisResult { /** * Canonical scored verdicts used for pass/fail and summary calculations. * Includes unmatched complexity entries scored at 0% coverage. */ readonly functions: ReadonlyArray; /** * Diagnostic mismatch details preserved for reporting and tooling. * Do not add these to `functions` or `summary` totals; no-coverage entries may * already be represented in `functions` as worst-case verdicts. */ readonly unmatched: ReadonlyArray; readonly warnings: ReadonlyArray; readonly summary: AnalysisSummary; readonly thresholdConfig: ThresholdConfig; readonly passed: boolean; } interface FunctionFilter { readonly description: string; readonly changedFiles: ReadonlyMap | null>; } interface MatchResult { readonly matched: ReadonlyArray<{ readonly complexity: FunctionComplexity; readonly coverage: FunctionCoverage; }>; readonly unmatchedComplexity: ReadonlyArray; readonly unmatchedCoverage: ReadonlyArray; } type MatchFunctions = (complexities: ReadonlyArray, coverages: ReadonlyArray) => MatchResult; interface AnalyzeOptions { src?: string | string[]; coverage?: string; threshold?: number; thresholds?: Record; coverageMetric?: "line" | "branch"; include?: string[]; exclude?: string[]; filter?: FunctionFilter; cwd?: string; } export { type AnalyzeOptions as A, type BreakdownMode as B, type CrapScore as C, type FunctionComplexity as F, type MatchFunctions as M, RiskLevel as R, type ScoredFunction as S, type ThresholdPreset as T, type UnmatchedFunction as U, type Warning as W, type FunctionCoverage as a, type ThresholdOverride as b, type ThresholdConfig as c, type AnalysisResult as d, type FunctionVerdict as e, type ComplexityContributor as f, type AnalysisSummary as g, type ContributorKind as h, type CoverageRatio as i, type FunctionFilter as j, type FunctionIdentity as k, type MatchResult as l, type RiskDistribution as m, type SourceSpan as n, type WarningCode as o };