technical-debt-radar 1.3.3 → 1.4.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.
Files changed (2) hide show
  1. package/dist/index.js +19 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -89,7 +89,8 @@ var require_constants = __commonJS({
89
89
  TRANSACTION_NO_TIMEOUT: "transaction-no-timeout",
90
90
  MISSING_NULL_GUARD: "missing-null-guard",
91
91
  MISSING_DTO_VALIDATION: "missing-dto-validation",
92
- UNGUARDED_ROUTE_TODO: "unguarded-route-todo"
92
+ UNGUARDED_ROUTE_TODO: "unguarded-route-todo",
93
+ ERROR_LOGGED_AS_INFO: "error-logged-as-info"
93
94
  };
94
95
  exports2.PERFORMANCE_RULES = {
95
96
  UNBOUNDED_FIND_MANY: "unbounded-find-many",
@@ -16238,18 +16239,12 @@ var require_reliability_detector = __commonJS({
16238
16239
  }
16239
16240
  return false;
16240
16241
  }
16241
- function isNestJSInjectable(classNode) {
16242
+ function isNestJSController(classNode) {
16242
16243
  return classNode.getDecorators().some((d) => {
16243
16244
  const name = d.getName();
16244
- return name === "Injectable";
16245
+ return name === "Controller" || name === "Resolver";
16245
16246
  });
16246
16247
  }
16247
- function isInsideNestJSInjectable(node) {
16248
- const classDecl = node.getFirstAncestorByKind(ts_morph_1.SyntaxKind.ClassDeclaration);
16249
- if (!classDecl)
16250
- return false;
16251
- return isNestJSInjectable(classDecl);
16252
- }
16253
16248
  function fileImportsNestJS(sourceFile) {
16254
16249
  for (const decl of sourceFile.getImportDeclarations()) {
16255
16250
  const spec = decl.getModuleSpecifierValue();
@@ -16258,10 +16253,13 @@ var require_reliability_detector = __commonJS({
16258
16253
  }
16259
16254
  return false;
16260
16255
  }
16261
- function isNestJSServiceMethod(node, sourceFile) {
16256
+ function isNestJSControllerMethod(node, sourceFile) {
16262
16257
  if (!fileImportsNestJS(sourceFile))
16263
16258
  return false;
16264
- if (!isInsideNestJSInjectable(node))
16259
+ const classDecl = node.getFirstAncestorByKind(ts_morph_1.SyntaxKind.ClassDeclaration);
16260
+ if (!classDecl)
16261
+ return false;
16262
+ if (!isNestJSController(classDecl))
16265
16263
  return false;
16266
16264
  const bgDecorators = /* @__PURE__ */ new Set(["Cron", "Process", "Interval", "Timeout"]);
16267
16265
  if (ts_morph_1.Node.isMethodDeclaration(node)) {
@@ -16269,10 +16267,8 @@ var require_reliability_detector = __commonJS({
16269
16267
  return false;
16270
16268
  }
16271
16269
  const fn = node.getFirstAncestorByKind(ts_morph_1.SyntaxKind.MethodDeclaration);
16272
- if (fn) {
16273
- if (fn.getDecorators().some((d) => bgDecorators.has(d.getName())))
16274
- return false;
16275
- }
16270
+ if (fn && fn.getDecorators().some((d) => bgDecorators.has(d.getName())))
16271
+ return false;
16276
16272
  return true;
16277
16273
  }
16278
16274
  function getSeverity(ruleId, policy) {
@@ -16357,7 +16353,7 @@ var require_reliability_detector = __commonJS({
16357
16353
  return;
16358
16354
  if (isBootstrapFunction(fn))
16359
16355
  return;
16360
- if (isNestJSServiceMethod(node, sourceFile))
16356
+ if (isNestJSControllerMethod(node, sourceFile))
16361
16357
  return;
16362
16358
  if (functionHasTryCatch(fn.node))
16363
16359
  return;
@@ -16545,7 +16541,7 @@ var require_reliability_detector = __commonJS({
16545
16541
  continue;
16546
16542
  if (isBootstrapFunction(fn))
16547
16543
  continue;
16548
- if (isNestJSServiceMethod(fn.node, _sourceFile))
16544
+ if (isNestJSControllerMethod(fn.node, _sourceFile))
16549
16545
  continue;
16550
16546
  let hasAwait = false;
16551
16547
  fn.node.forEachDescendant((child) => {
@@ -16786,6 +16782,12 @@ var require_reliability_detector = __commonJS({
16786
16782
  const hasContinue = /\bcontinue\b/.test(blockText);
16787
16783
  if (hasIncrement || hasPropertyMethodCall || hasAwaitOrDelay || hasContinue)
16788
16784
  return;
16785
+ const hasConsoleLog = /\bconsole\.log\b/.test(blockText);
16786
+ if (hasConsoleLog) {
16787
+ const fn2 = getEnclosingFn(node, fns);
16788
+ violations.push(makeViolation(shared_1.RELIABILITY_RULES.ERROR_LOGGED_AS_INFO, filePath, node.getStartLineNumber(), "Error logged with console.log instead of console.error \u2014 errors should route to stderr", policy, fn2?.name, "Replace console.log with console.error or use a proper logger (winston, pino)"));
16789
+ return;
16790
+ }
16789
16791
  const fn = getEnclosingFn(node, fns);
16790
16792
  violations.push(makeViolation(shared_1.RELIABILITY_RULES.MISSING_ERROR_LOGGING, filePath, node.getStartLineNumber(), "catch block has no error logging or reporting", policy, fn?.name, "Add logger.error(err) or re-throw the error"));
16791
16793
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "technical-debt-radar",
3
- "version": "1.3.3",
3
+ "version": "1.4.0",
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",