@barney-media/cognitive-typescript 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,6 +15,8 @@ npx cognitive-typescript
15
15
  npx cognitive-typescript --changed
16
16
  npx cognitive-typescript src/sample.ts
17
17
  npx cognitive-typescript packages/api packages/web
18
+ npx cognitive-typescript --agent
19
+ npx cognitive-typescript --format json --output reports/cognitive.json --junit-report reports/cognitive-junit.xml
18
20
  ```
19
21
 
20
22
  ## Options
@@ -25,13 +27,43 @@ npx cognitive-typescript packages/api packages/web
25
27
  --changed Analyze changed TypeScript files under src/
26
28
  <file ...> Analyze explicit TypeScript files
27
29
  <directory ...> Analyze TypeScript files under each directory's nested src/ tree
30
+ --format <format> Emit toon, json, text, junit, or none (default: toon)
31
+ --exclude <glob> Exclude normalized project-relative paths from analysis (repeatable)
32
+ --exclude-name <regex> Exclude matching function or method names from analysis (repeatable)
33
+ --exclude-decorator <name> Exclude matching decorators by simple or dotted source name (repeatable)
34
+ --exclude-comment <marker> Exclude generated code with leading file/function comment markers (repeatable)
35
+ --use-default-exclusions Enable conservative generated-code exclusions (default: true)
36
+ --failures-only[=true|false] Emit failed functions only in the primary report
37
+ --omit-redundancy[=true|false]
38
+ Omit redundant per-method status in the primary report
39
+ --output <path> Write the primary report to a file instead of stdout
40
+ --junit-report <path> Also write a full JUnit XML report for CI test-report UIs
41
+ --threshold <integer> Override the Cognitive Complexity threshold (default: 15)
42
+ --agent Compact the primary report to actionable failures by default
28
43
  ```
29
44
 
45
+ Default exclusions cover declaration files, generated/build directories, generated file-name suffixes, existing test-file defaults, and the leading generated-code markers `@generated` and `<auto-generated`.
46
+
47
+ Primary formats:
48
+
49
+ - `toon` default CLI format
50
+ - `json`
51
+ - `text`
52
+ - `junit`
53
+ - `none`
54
+
55
+ `--agent` defaults the primary report to `toon` and turns on `--failures-only` plus `--omit-redundancy`.
56
+
57
+ The CLI is pure static analysis. It does not execute tests, collect coverage, or compute CRAP scores.
58
+
59
+ `--junit-report` is opt-in on the CLI. Both `--output` and `--junit-report` must stay inside the project root and must target files rather than the project root, filesystem roots, or existing directories.
60
+
30
61
  ## Exit Codes
31
62
 
32
63
  - `0` success, threshold respected
33
64
  - `1` invalid CLI usage or execution failure
34
- - `2` Cognitive Complexity threshold exceeded (`> 15`)
65
+ - `2` Cognitive Complexity threshold exceeded (`> threshold`)
66
+ - `3` unexpected internal error
35
67
 
36
68
  See the [main repository](https://github.com/fabian-barney/cognitive-typescript) for full details.
37
69
 
package/dist/bin.js CHANGED
@@ -2,7 +2,12 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const cognitive_typescript_core_1 = require("@barney-media/cognitive-typescript-core");
5
- void (0, cognitive_typescript_core_1.runCli)(process.argv.slice(2)).then((exitCode) => {
5
+ void (0, cognitive_typescript_core_1.runCli)(process.argv.slice(2))
6
+ .then((exitCode) => {
6
7
  process.exitCode = exitCode;
8
+ })
9
+ .catch((error) => {
10
+ console.error(error);
11
+ process.exitCode = 3;
7
12
  });
8
13
  //# sourceMappingURL=bin.js.map
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;AACA,uFAAiE;AAEjE,KAAK,IAAA,kCAAM,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACnD,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC9B,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;AACA,uFAAiE;AAEjE,KAAK,IAAA,kCAAM,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC/B,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACjB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC9B,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACxB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barney-media/cognitive-typescript",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "CLI for Cognitive Complexity analysis in TypeScript projects.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Fabian Barney (https://github.com/fabian-barney)",
@@ -39,9 +39,9 @@
39
39
  },
40
40
  "sideEffects": false,
41
41
  "engines": {
42
- "node": ">=18"
42
+ "node": ">=22.13.0"
43
43
  },
44
44
  "dependencies": {
45
- "@barney-media/cognitive-typescript-core": "^0.1.1"
45
+ "@barney-media/cognitive-typescript-core": "^0.2.0"
46
46
  }
47
47
  }