technical-debt-radar 1.6.1 → 1.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.
Files changed (2) hide show
  1. package/dist/index.js +26 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16597,39 +16597,39 @@ var require_reliability_detector = __commonJS({
16597
16597
  continue;
16598
16598
  if (isNestJSControllerMethod(fn.node, _sourceFile))
16599
16599
  continue;
16600
- let hasAwait = false;
16601
- fn.node.forEachDescendant((child) => {
16602
- if (ts_morph_1.Node.isAwaitExpression(child))
16603
- hasAwait = true;
16604
- });
16605
- if (!hasAwait)
16606
- continue;
16607
16600
  const body = fn.node.getBody();
16608
16601
  if (!body || !ts_morph_1.Node.isBlock(body))
16609
16602
  continue;
16610
- const hasTryAtTop = body.getStatements().some((s) => ts_morph_1.Node.isTryStatement(s));
16611
- if (hasTryAtTop)
16612
- continue;
16613
- let hasTryNested = false;
16614
- body.forEachDescendant((child) => {
16615
- if (hasTryNested)
16616
- return;
16603
+ let unhandledAwaitCount = 0;
16604
+ let totalAwaitCount = 0;
16605
+ fn.node.forEachDescendant((child) => {
16617
16606
  if (child !== fn.node && (ts_morph_1.Node.isFunctionDeclaration(child) || ts_morph_1.Node.isMethodDeclaration(child) || ts_morph_1.Node.isArrowFunction(child) || ts_morph_1.Node.isFunctionExpression(child)))
16618
16607
  return;
16619
- if (ts_morph_1.Node.isTryStatement(child))
16620
- hasTryNested = true;
16621
- });
16622
- if (hasTryNested)
16623
- continue;
16624
- let awaitCount = 0;
16625
- fn.node.forEachDescendant((child) => {
16626
- if (ts_morph_1.Node.isFunctionDeclaration(child) || ts_morph_1.Node.isMethodDeclaration(child) || ts_morph_1.Node.isArrowFunction(child) || ts_morph_1.Node.isFunctionExpression(child)) {
16627
- if (child !== fn.node)
16628
- return;
16608
+ if (!ts_morph_1.Node.isAwaitExpression(child))
16609
+ return;
16610
+ totalAwaitCount++;
16611
+ let current = child.getParent();
16612
+ let isHandled = false;
16613
+ while (current && current !== fn.node) {
16614
+ if (ts_morph_1.Node.isTryStatement(current)) {
16615
+ const tryBlock = current.getTryBlock();
16616
+ if (tryBlock && child.getPos() >= tryBlock.getPos() && child.getEnd() <= tryBlock.getEnd()) {
16617
+ isHandled = true;
16618
+ }
16619
+ break;
16620
+ }
16621
+ if (ts_morph_1.Node.isFunctionDeclaration(current) || ts_morph_1.Node.isMethodDeclaration(current) || ts_morph_1.Node.isArrowFunction(current) || ts_morph_1.Node.isFunctionExpression(current))
16622
+ break;
16623
+ current = current.getParent();
16629
16624
  }
16630
- if (ts_morph_1.Node.isAwaitExpression(child))
16631
- awaitCount++;
16625
+ if (!isHandled)
16626
+ unhandledAwaitCount++;
16632
16627
  });
16628
+ if (totalAwaitCount === 0)
16629
+ continue;
16630
+ if (unhandledAwaitCount === 0)
16631
+ continue;
16632
+ const awaitCount = unhandledAwaitCount;
16633
16633
  if (awaitCount < 2)
16634
16634
  continue;
16635
16635
  violations.push(makeViolation(shared_1.RELIABILITY_RULES.MISSING_TRY_CATCH, filePath, fn.node.getStartLineNumber(), `Async function '${fn.name}' has multiple awaits but no try/catch`, policy, fn.name, "Add try/catch around the async operations or use an error-handling wrapper"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "technical-debt-radar",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Stop Node.js production crashes before merge. 47 detection patterns across 5 categories.",
5
5
  "bin": {
6
6
  "radar": "dist/index.js",