technical-debt-radar 1.3.2 → 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 +24 -21
  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",
@@ -14517,7 +14518,7 @@ var require_perf_pattern_detector = __commonJS({
14517
14518
  return closest;
14518
14519
  }
14519
14520
  var VOLUME_SEVERITY = {
14520
- S: "info",
14521
+ S: "warning",
14521
14522
  M: "warning",
14522
14523
  L: "critical",
14523
14524
  XL: "critical",
@@ -14573,16 +14574,17 @@ var require_perf_pattern_detector = __commonJS({
14573
14574
  candidates.add(origLower + "s");
14574
14575
  candidates.add(origSnaked + "s");
14575
14576
  }
14576
- for (const candidate of candidates) {
14577
+ for (const candidate of [...candidates]) {
14577
14578
  const match = policy.volumes.find((v) => v.entity.toLowerCase() === candidate);
14578
14579
  if (match)
14579
14580
  return match;
14580
14581
  }
14581
- return void 0;
14582
+ const defaultVol = policy.volumes.find((v) => v.entity.toLowerCase() === "default");
14583
+ return defaultVol ?? void 0;
14582
14584
  }
14583
14585
  function severityForVolume(vol) {
14584
14586
  if (!vol)
14585
- return "info";
14587
+ return "warning";
14586
14588
  return VOLUME_SEVERITY[vol.size];
14587
14589
  }
14588
14590
  function gateForVolume(vol) {
@@ -16237,18 +16239,12 @@ var require_reliability_detector = __commonJS({
16237
16239
  }
16238
16240
  return false;
16239
16241
  }
16240
- function isNestJSInjectable(classNode) {
16242
+ function isNestJSController(classNode) {
16241
16243
  return classNode.getDecorators().some((d) => {
16242
16244
  const name = d.getName();
16243
- return name === "Injectable";
16245
+ return name === "Controller" || name === "Resolver";
16244
16246
  });
16245
16247
  }
16246
- function isInsideNestJSInjectable(node) {
16247
- const classDecl = node.getFirstAncestorByKind(ts_morph_1.SyntaxKind.ClassDeclaration);
16248
- if (!classDecl)
16249
- return false;
16250
- return isNestJSInjectable(classDecl);
16251
- }
16252
16248
  function fileImportsNestJS(sourceFile) {
16253
16249
  for (const decl of sourceFile.getImportDeclarations()) {
16254
16250
  const spec = decl.getModuleSpecifierValue();
@@ -16257,10 +16253,13 @@ var require_reliability_detector = __commonJS({
16257
16253
  }
16258
16254
  return false;
16259
16255
  }
16260
- function isNestJSServiceMethod(node, sourceFile) {
16256
+ function isNestJSControllerMethod(node, sourceFile) {
16261
16257
  if (!fileImportsNestJS(sourceFile))
16262
16258
  return false;
16263
- if (!isInsideNestJSInjectable(node))
16259
+ const classDecl = node.getFirstAncestorByKind(ts_morph_1.SyntaxKind.ClassDeclaration);
16260
+ if (!classDecl)
16261
+ return false;
16262
+ if (!isNestJSController(classDecl))
16264
16263
  return false;
16265
16264
  const bgDecorators = /* @__PURE__ */ new Set(["Cron", "Process", "Interval", "Timeout"]);
16266
16265
  if (ts_morph_1.Node.isMethodDeclaration(node)) {
@@ -16268,10 +16267,8 @@ var require_reliability_detector = __commonJS({
16268
16267
  return false;
16269
16268
  }
16270
16269
  const fn = node.getFirstAncestorByKind(ts_morph_1.SyntaxKind.MethodDeclaration);
16271
- if (fn) {
16272
- if (fn.getDecorators().some((d) => bgDecorators.has(d.getName())))
16273
- return false;
16274
- }
16270
+ if (fn && fn.getDecorators().some((d) => bgDecorators.has(d.getName())))
16271
+ return false;
16275
16272
  return true;
16276
16273
  }
16277
16274
  function getSeverity(ruleId, policy) {
@@ -16356,7 +16353,7 @@ var require_reliability_detector = __commonJS({
16356
16353
  return;
16357
16354
  if (isBootstrapFunction(fn))
16358
16355
  return;
16359
- if (isNestJSServiceMethod(node, sourceFile))
16356
+ if (isNestJSControllerMethod(node, sourceFile))
16360
16357
  return;
16361
16358
  if (functionHasTryCatch(fn.node))
16362
16359
  return;
@@ -16544,7 +16541,7 @@ var require_reliability_detector = __commonJS({
16544
16541
  continue;
16545
16542
  if (isBootstrapFunction(fn))
16546
16543
  continue;
16547
- if (isNestJSServiceMethod(fn.node, _sourceFile))
16544
+ if (isNestJSControllerMethod(fn.node, _sourceFile))
16548
16545
  continue;
16549
16546
  let hasAwait = false;
16550
16547
  fn.node.forEachDescendant((child) => {
@@ -16785,6 +16782,12 @@ var require_reliability_detector = __commonJS({
16785
16782
  const hasContinue = /\bcontinue\b/.test(blockText);
16786
16783
  if (hasIncrement || hasPropertyMethodCall || hasAwaitOrDelay || hasContinue)
16787
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
+ }
16788
16791
  const fn = getEnclosingFn(node, fns);
16789
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"));
16790
16793
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "technical-debt-radar",
3
- "version": "1.3.2",
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",