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.
- package/dist/index.js +26 -26
- 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
|
-
|
|
16611
|
-
|
|
16612
|
-
|
|
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.
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16628
|
-
|
|
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 (
|
|
16631
|
-
|
|
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"));
|