@barney-media/cognitive-typescript-core
v0.2.1
Published
Core Cognitive Complexity analyzer for TypeScript projects.
Maintainers
Readme
@barney-media/cognitive-typescript-core
Core analysis engine for computing Cognitive Complexity on TypeScript projects.
Install
npm install --save-dev @barney-media/cognitive-typescript-coreAPI
import {
analyzeProject,
COGNITIVE_COMPLEXITY_THRESHOLD,
formatAnalysisReport,
parseFileMethods
} from "@barney-media/cognitive-typescript-core";
const result = await analyzeProject({
projectRoot: ".",
changedOnly: true,
excludes: ["packages/generated/**"],
threshold: 12
});
console.log(
formatAnalysisReport(result.metrics, {
format: "json",
threshold: result.threshold,
exclusionAudit: result.exclusionAudit
})
);
console.log(result.maxCognitiveComplexity);
console.log(COGNITIVE_COMPLEXITY_THRESHOLD);
console.log(result.exclusionAudit);Key exports:
analyzeProjectrunCli,parseCliArguments,usageparseFileMethodsformatAnalysisReport,formatReport,formatToonReport,formatTextReport,formatJunitReport,sortMetricsCOGNITIVE_COMPLEXITY_THRESHOLD
The core returns structured metrics suitable for CI quality gates and later automation or agent integrations.
analyzeProject(...) supports aligned file-selection and source-exclusion controls:
explicitPathschangedOnlyexcludesexcludeNamesexcludeDecoratorsexcludeCommentsuseDefaultExclusionsthreshold
AnalysisResult.exclusionAudit reports discovered, analyzed, and excluded file/function counts plus per-reason tallies. Full reports and JUnit sidecars can publish that audit data directly, while compact agent primary output omits it by default.
The core stays in the static-analysis lane: it does not execute tests, enable coverage, consume Istanbul or LCOV reports, or compute CRAP scores.
See the main repository for full documentation.
