cognitive-complexity-ts 0.6.0 → 0.6.2

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) {
@@ -33,7 +33,7 @@ function getColumnAndLine(node) {
33
33
  exports.getColumnAndLine = getColumnAndLine;
34
34
  function getIdentifier(node) {
35
35
  for (const child of node.getChildren()) {
36
- if (ts.isIdentifier(child) || ts.isComputedPropertyName(child)) {
36
+ if (ts.isIdentifierOrPrivateIdentifier(child) || ts.isComputedPropertyName(child)) {
37
37
  return child.getText();
38
38
  }
39
39
  }
@@ -65,7 +65,7 @@ exports.isBinaryTypeOperator = isBinaryTypeOperator;
65
65
  function isBreakOrContinueToLabel(node) {
66
66
  if (ts.isBreakOrContinueStatement(node)) {
67
67
  for (const child of node.getChildren()) {
68
- if (ts.isIdentifier(child)) {
68
+ if (ts.isIdentifierOrPrivateIdentifier(child)) {
69
69
  return true;
70
70
  }
71
71
  }
@@ -140,7 +140,7 @@ exports.getExpressionToAccessObjectMember = getExpressionToAccessObjectMember;
140
140
  */
141
141
  function getAccessorIdentifierName(node) {
142
142
  for (const child of node.getChildren()) {
143
- if (ts.isIdentifier(child)) {
143
+ if (ts.isIdentifierOrPrivateIdentifier(child)) {
144
144
  return [child.getText(), true];
145
145
  }
146
146
  if (ts.isComputedPropertyName(child)) {
@@ -150,7 +150,7 @@ function getAccessorIdentifierName(node) {
150
150
  throw new node_util_1.UnreachableNodeState(node, "The accessor was expected to have an identifier or computed property name.");
151
151
  }
152
152
  function getIdentifierDespiteBrackets(node) {
153
- if (ts.isIdentifier(node) || ts.isElementAccessExpression(node)) {
153
+ if (ts.isIdentifierOrPrivateIdentifier(node) || ts.isElementAccessExpression(node)) {
154
154
  return node.getText();
155
155
  }
156
156
  if (ts.isParenthesizedExpression(node)) {
@@ -188,7 +188,7 @@ function getFunctionNodeName(func) {
188
188
  }
189
189
  if (ts.isFunctionExpression(func)) {
190
190
  const maybeIdentifier = func.getChildren()[1];
191
- if (ts.isIdentifier(maybeIdentifier)) {
191
+ if (ts.isIdentifierOrPrivateIdentifier(maybeIdentifier)) {
192
192
  return maybeIdentifier.getText();
193
193
  }
194
194
  else {
@@ -219,7 +219,7 @@ function getModuleDeclarationName(node) {
219
219
  */
220
220
  function getMethodDeclarationName(node) {
221
221
  for (const child of node.getChildren()) {
222
- if (ts.isIdentifier(child)) {
222
+ if (ts.isIdentifierOrPrivateIdentifier(child)) {
223
223
  return [child.getText(), true];
224
224
  }
225
225
  if (ts.isComputedPropertyName(child)) {
@@ -236,7 +236,7 @@ function getTypeAliasName(node) {
236
236
  }
237
237
  function maybeGetFirstIdentifierName(node) {
238
238
  const name = node.getChildren()
239
- .find(child => ts.isIdentifier(child));
239
+ .find(child => ts.isIdentifierOrPrivateIdentifier(child));
240
240
  return name === null || name === void 0 ? void 0 : name.getText();
241
241
  }
242
242
  //# sourceMappingURL=node-naming.js.map
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.2",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "typescript",