cognitive-complexity-ts 0.6.0 → 0.6.1

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
@@ -110,7 +110,6 @@ npm i
110
110
  # All builds are incremental.
111
111
  # These scripts also build dependencies incrementally.
112
112
  npm run build # The main complexity analysis program and UI back-end server.
113
- npm run build-test
114
113
  npm run build-tools
115
114
  npm run build-ui # The in-browser UI code only.
116
115
  ```
@@ -24,6 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.whereAreChildren = void 0;
26
26
  const ts = __importStar(require("typescript"));
27
+ const node_util_1 = require("../util/node-util");
27
28
  const node_inspection_1 = require("./node-inspection");
28
29
  ;
29
30
  /**
@@ -85,11 +86,13 @@ function arrowFunction(node) {
85
86
  }
86
87
  function catchClause(node) {
87
88
  const children = node.getChildren();
88
- const variableDefinition = children[2];
89
- const catchCode = children[4];
89
+ const variableDeclaration = children.find(child => ts.isVariableDeclaration(child));
90
+ const block = children.find(child => ts.isBlock(child));
91
+ if (block === undefined)
92
+ throw new node_util_1.UnreachableNodeState(node, "catch clause has no block");
90
93
  return {
91
- same: [variableDefinition],
92
- below: [catchCode]
94
+ same: variableDeclaration ? [variableDeclaration] : [],
95
+ below: [block],
93
96
  };
94
97
  }
95
98
  function conditionalExpression(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognitive-complexity-ts",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "typescript",