@mocoto/mahoraga 0.14.1 → 0.14.3

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 (306) hide show
  1. package/README.md +0 -34
  2. package/dist/analysts/architects/analyst-structure.js +20 -20
  3. package/dist/analysts/architects/archetypes-custom.js +16 -19
  4. package/dist/analysts/architects/detector-archetypes.js +43 -36
  5. package/dist/analysts/architects/orchestrator-archetypes.js +3 -3
  6. package/dist/analysts/architects/signals-project-advanced.js +26 -28
  7. package/dist/analysts/architects/signals-project.js +2 -2
  8. package/dist/analysts/architects/strategist-structure.js +47 -66
  9. package/dist/analysts/azure-pipelines/analysts/analyst-azure.js +41 -35
  10. package/dist/analysts/azure-pipelines/corrections/correction-azure.js +22 -19
  11. package/dist/analysts/azure-pipelines/detectors/detector-azure-performance.js +21 -18
  12. package/dist/analysts/azure-pipelines/detectors/detector-azure-security.js +25 -20
  13. package/dist/analysts/azure-pipelines/detectors/detector-azure-structure.js +39 -40
  14. package/dist/analysts/azure-pipelines/scorers/scorer-azure.js +10 -7
  15. package/dist/analysts/circleci/analysts/analyst-circleci.js +33 -27
  16. package/dist/analysts/circleci/corrections/correction-circleci.js +22 -20
  17. package/dist/analysts/circleci/detectors/detector-circleci-performance.js +23 -19
  18. package/dist/analysts/circleci/detectors/detector-circleci-security.js +78 -82
  19. package/dist/analysts/circleci/detectors/detector-circleci-structure.js +22 -22
  20. package/dist/analysts/converters/convert-registry.js +1 -1
  21. package/dist/analysts/converters/engines/converter-gha-to-gitlab.js +17 -15
  22. package/dist/analysts/converters/index.js +1 -1
  23. package/dist/analysts/corrections/analyst-quick-fixes.js +25 -28
  24. package/dist/analysts/corrections/analyst-scoring.js +24 -21
  25. package/dist/analysts/corrections/auto-fix-engine.js +1 -1
  26. package/dist/analysts/corrections/corrector-structure.js +43 -42
  27. package/dist/analysts/corrections/fix-alias-imports.js +10 -6
  28. package/dist/analysts/corrections/fix-md-fences.js +23 -23
  29. package/dist/analysts/corrections/map-reversion.js +56 -53
  30. package/dist/analysts/corrections/pruning.js +19 -16
  31. package/dist/analysts/corrections/quick-fixes/fix-any-to-proper-type.js +57 -61
  32. package/dist/analysts/corrections/quick-fixes/fix-unknown-to-specific-type.js +30 -30
  33. package/dist/analysts/corrections/reorganize-barrels.js +13 -13
  34. package/dist/analysts/corrections/rewrite-testes-aliases.js +23 -22
  35. package/dist/analysts/corrections/scoring-shared.js +19 -18
  36. package/dist/analysts/corrections/type-safety/context-analyzer.js +15 -10
  37. package/dist/analysts/corrections/type-safety/type-analyzer.js +3 -3
  38. package/dist/analysts/corrections/type-safety/type-validator.js +4 -3
  39. package/dist/analysts/corrections/type-safety/usage-analyzer.js +39 -42
  40. package/dist/analysts/css/analysts/analyst-css.js +42 -42
  41. package/dist/analysts/css/corrections/correction-css.js +19 -11
  42. package/dist/analysts/css/detectors/detector-css-best-practices.js +129 -118
  43. package/dist/analysts/css/scorers/scorer-css.js +23 -18
  44. package/dist/analysts/css-in-js/analysts/analyst-css-in-js.js +24 -17
  45. package/dist/analysts/css-in-js/corrections/correction-css-in-js.js +31 -16
  46. package/dist/analysts/css-in-js/detectors/detector-css-in-js-best-practices.js +28 -30
  47. package/dist/analysts/css-in-js/scorers/scorer-css-in-js.js +79 -54
  48. package/dist/analysts/css-in-js/shared.js +7 -0
  49. package/dist/analysts/detectors/detector-architecture.js +91 -85
  50. package/dist/analysts/detectors/detector-bugs-ml.js +29 -27
  51. package/dist/analysts/detectors/detector-code-fragile.js +41 -36
  52. package/dist/analysts/detectors/detector-dependencies.js +5 -5
  53. package/dist/analysts/detectors/detector-duplications.js +26 -26
  54. package/dist/analysts/detectors/detector-monorepo.js +51 -45
  55. package/dist/analysts/detectors/detector-performance.js +24 -17
  56. package/dist/analysts/detectors/detector-recommendation-architecture.js +40 -36
  57. package/dist/analysts/detectors/detector-security.js +43 -42
  58. package/dist/analysts/detectors/detector-structure.js +31 -28
  59. package/dist/analysts/github-actions/analysts/analyst-github-actions.js +5 -8
  60. package/dist/analysts/github-actions/detectors/detector-workflow-accessibility.js +1 -9
  61. package/dist/analysts/github-actions/detectors/detector-workflow-structure.js +1 -4
  62. package/dist/analysts/github-actions/detectors/detector-workflow-trigger-unsafe.js +6 -5
  63. package/dist/analysts/gitlab-ci/analysts/analyst-gitlab-ci.js +2 -2
  64. package/dist/analysts/gitlab-ci/detectors/detector-gitlab-ci-structure.js +0 -3
  65. package/dist/analysts/go/analysts/analyst-best-practices.js +2 -2
  66. package/dist/analysts/go/analysts/analyst-concurrency.js +1 -1
  67. package/dist/analysts/go/analysts/analyst-security.js +1 -1
  68. package/dist/analysts/go/detectors/detector-conventions.js +1 -1
  69. package/dist/analysts/html/analysts/analyst-html.js +10 -12
  70. package/dist/analysts/html/detectors/detector-html.js +3 -3
  71. package/dist/analysts/js-ts/analysts/analyst-commands-cli.js +22 -22
  72. package/dist/analysts/js-ts/analysts/analyst-functions-long.js +5 -5
  73. package/dist/analysts/js-ts/analysts/analyst-patterns-usage.js +6 -2
  74. package/dist/analysts/js-ts/detectors/detector-anti-patterns-async.js +84 -9
  75. package/dist/analysts/js-ts/detectors/detector-constructions-syntactic.js +33 -10
  76. package/dist/analysts/js-ts/detectors/detector-context-smart.js +6 -6
  77. package/dist/analysts/js-ts/detectors/detector-leaks-memory.js +1 -1
  78. package/dist/analysts/js-ts/detectors/detector-types-unsafe.js +33 -2
  79. package/dist/analysts/php/analysts/analyst-php.js +3 -3
  80. package/dist/analysts/php/detectors/detector-php-best-practices.js +5 -5
  81. package/dist/analysts/php/detectors/detector-php-security.js +5 -5
  82. package/dist/analysts/php/scorers/scorer-php.js +2 -2
  83. package/dist/analysts/plugins/detector-documentation.js +6 -6
  84. package/dist/analysts/plugins/detector-markdown.js +7 -7
  85. package/dist/analysts/python/analysts/analyst-python.js +2 -5
  86. package/dist/analysts/react/analysts/analyst-react-hooks.js +66 -9
  87. package/dist/analysts/react/analysts/analyst-react.js +46 -2
  88. package/dist/analysts/react/corrections/correction-react.js +41 -1
  89. package/dist/analysts/react/detectors/detector-react-best-practices.js +5 -5
  90. package/dist/analysts/react/scorers/scorer-react.js +36 -1
  91. package/dist/analysts/registry/autodiscovery.js +2 -2
  92. package/dist/analysts/rust/analysts/analyst-best-practices.js +42 -3
  93. package/dist/analysts/rust/analysts/analyst-memory.js +2 -2
  94. package/dist/analysts/rust/analysts/analyst-rust.js +52 -5
  95. package/dist/analysts/rust/analysts/analyst-security.js +29 -1
  96. package/dist/analysts/scorers/scorer.js +5 -5
  97. package/dist/analysts/shell/analysts/analyst-shell.js +81 -5
  98. package/dist/analysts/shell/corrections/correction-shell.js +34 -1
  99. package/dist/analysts/shell/detectors/detector-shell-security.js +88 -0
  100. package/dist/analysts/shell/scorers/scorer-shell.js +58 -1
  101. package/dist/analysts/strategists/operator-structure.js +5 -7
  102. package/dist/analysts/strategists/suggestions-contextuais.js +5 -2
  103. package/dist/analysts/svg/analysts/analyst-svg.js +1 -0
  104. package/dist/analysts/tailwind/analysts/analyst-tailwind.js +79 -55
  105. package/dist/analysts/tailwind/corrections/correction-tailwind.js +108 -9
  106. package/dist/analysts/tailwind/detectors/detector-tailwind-best-practices.js +122 -7
  107. package/dist/analysts/tailwind/scorers/scorer-tailwind.js +62 -11
  108. package/dist/analysts/xml/analysts/analyst-xml.js +2 -2
  109. package/dist/app/index.js +1 -0
  110. package/dist/bin/cli-bootstrap.js +6 -4
  111. package/dist/bin/index.js +6 -4
  112. package/dist/caretakers/scoring.js +1 -0
  113. package/dist/cli/commands/command-analysts.js +4 -3
  114. package/dist/cli/commands/command-azure.js +1 -1
  115. package/dist/cli/commands/command-circleci.js +1 -1
  116. package/dist/cli/commands/command-compliance.js +1 -1
  117. package/dist/cli/commands/command-diagnose.js +10 -13
  118. package/dist/cli/commands/command-fix-types.js +9 -32
  119. package/dist/cli/commands/command-formatters.js +2 -2
  120. package/dist/cli/commands/command-github-actions.js +1 -1
  121. package/dist/cli/commands/command-gitlab-ci.js +1 -1
  122. package/dist/cli/commands/command-guardian.js +1 -1
  123. package/dist/cli/commands/command-imports.js +6 -6
  124. package/dist/cli/commands/command-jenkins.js +1 -1
  125. package/dist/cli/commands/command-licenses.js +1 -1
  126. package/dist/cli/commands/command-marketplace.js +7 -7
  127. package/dist/cli/commands/command-names.js +3 -8
  128. package/dist/cli/commands/command-perf.js +7 -9
  129. package/dist/cli/commands/command-plugins.js +4 -4
  130. package/dist/cli/diagnostic/auto-fix.js +2 -2
  131. package/dist/cli/diagnostic/exporters/json-exporter.js +1 -1
  132. package/dist/cli/diagnostic/exporters/sharded-exporter.js +0 -3
  133. package/dist/cli/diagnostic/exporters/svg-optimization-exporter.js +1 -1
  134. package/dist/cli/diagnostic/filters.js +9 -9
  135. package/dist/cli/diagnostic/handlers/archetype-handler.js +3 -6
  136. package/dist/cli/diagnostic/handlers/auto-fix-handler.js +4 -4
  137. package/dist/cli/diagnostic/handlers/guardian-handler.js +1 -1
  138. package/dist/cli/diagnostic/processing-diagnostic.js +31 -35
  139. package/dist/cli/diagnostic/processing-helpers.js +2 -2
  140. package/dist/cli/handlers/fix-types-exporter.js +1 -4
  141. package/dist/cli/helpers/display-frame.js +5 -5
  142. package/dist/core/config/auto/auto-fix-config.js +0 -6
  143. package/dist/core/config/chalk-safe.js +6 -6
  144. package/dist/core/config/config.js +11 -13
  145. package/dist/core/config/conventions.js +1 -1
  146. package/dist/core/config/security.js +2 -2
  147. package/dist/core/execution/analysis-cache.js +5 -8
  148. package/dist/core/execution/ast-cache.js +1 -3
  149. package/dist/core/execution/executor.js +8 -21
  150. package/dist/core/execution/inquisitor.js +24 -21
  151. package/dist/core/execution/results.js +1 -0
  152. package/dist/core/execution/scanner.js +4 -4
  153. package/dist/core/messages/en/analysts/analyst-github-actions-messages.js +1 -1
  154. package/dist/core/messages/en/analysts/analyst-patterns-usage-messages.js +1 -0
  155. package/dist/core/messages/en/analysts/analyst-shell-messages.js +15 -0
  156. package/dist/core/messages/en/analysts/detector-constructions-syntactic-messages.js +6 -0
  157. package/dist/core/messages/en/analysts/detector-js-ts-messages.js +27 -0
  158. package/dist/core/messages/en/analysts/detector-react-messages.js +8 -0
  159. package/dist/core/messages/en/analysts/detector-shell-messages.js +17 -0
  160. package/dist/core/messages/en/analysts/detector-tailwind-messages.js +3 -3
  161. package/dist/core/messages/en/analysts/report-circleci-messages.js +7 -7
  162. package/dist/core/messages/en/caretakers/caretaker-messages.js +1 -7
  163. package/dist/core/messages/en/core/plugin-messages.js +31 -3
  164. package/dist/core/messages/en/log/log.js +4 -4
  165. package/dist/core/messages/en/ui/filter-config.js +1 -5
  166. package/dist/core/messages/i18n-system.js +3 -3
  167. package/dist/core/messages/index.js +3 -3
  168. package/dist/core/messages/ja/analysts/analyst-github-actions-messages.js +1 -1
  169. package/dist/core/messages/ja/analysts/analyst-patterns-usage-messages.js +1 -0
  170. package/dist/core/messages/ja/analysts/analyst-shell-messages.js +15 -0
  171. package/dist/core/messages/ja/analysts/detector-constructions-syntactic-messages.js +6 -0
  172. package/dist/core/messages/ja/analysts/detector-js-ts-messages.js +27 -0
  173. package/dist/core/messages/ja/analysts/detector-react-messages.js +8 -0
  174. package/dist/core/messages/ja/analysts/detector-shell-messages.js +17 -0
  175. package/dist/core/messages/ja/analysts/detector-tailwind-messages.js +3 -3
  176. package/dist/core/messages/ja/analysts/report-circleci-messages.js +7 -7
  177. package/dist/core/messages/ja/caretakers/caretaker-messages.js +1 -7
  178. package/dist/core/messages/ja/core/plugin-messages.js +31 -3
  179. package/dist/core/messages/ja/log/log.js +4 -4
  180. package/dist/core/messages/ja/ui/filter-config.js +1 -1
  181. package/dist/core/messages/pt/analysts/analyst-github-actions-messages.js +1 -1
  182. package/dist/core/messages/pt/analysts/analyst-patterns-usage-messages.js +1 -0
  183. package/dist/core/messages/pt/analysts/analyst-shell-messages.js +15 -0
  184. package/dist/core/messages/pt/analysts/detector-constructions-syntactic-messages.js +6 -0
  185. package/dist/core/messages/pt/analysts/detector-js-ts-messages.js +27 -0
  186. package/dist/core/messages/pt/analysts/detector-react-messages.js +8 -0
  187. package/dist/core/messages/pt/analysts/detector-shell-messages.js +17 -0
  188. package/dist/core/messages/pt/analysts/detector-tailwind-messages.js +3 -3
  189. package/dist/core/messages/pt/analysts/report-circleci-messages.js +7 -7
  190. package/dist/core/messages/pt/caretakers/caretaker-messages.js +1 -7
  191. package/dist/core/messages/pt/core/plugin-messages.js +31 -3
  192. package/dist/core/messages/pt/log/log-engine.js +6 -6
  193. package/dist/core/messages/pt/log/log.js +3 -3
  194. package/dist/core/messages/pt/ui/filter-config.js +1 -1
  195. package/dist/core/messages/shared/icons.js +3 -3
  196. package/dist/core/messages/zh/analysts/analyst-github-actions-messages.js +1 -1
  197. package/dist/core/messages/zh/analysts/analyst-patterns-usage-messages.js +1 -0
  198. package/dist/core/messages/zh/analysts/analyst-shell-messages.js +15 -0
  199. package/dist/core/messages/zh/analysts/detector-constructions-syntactic-messages.js +6 -0
  200. package/dist/core/messages/zh/analysts/detector-js-ts-messages.js +27 -0
  201. package/dist/core/messages/zh/analysts/detector-react-messages.js +8 -0
  202. package/dist/core/messages/zh/analysts/detector-shell-messages.js +17 -0
  203. package/dist/core/messages/zh/analysts/detector-tailwind-messages.js +3 -3
  204. package/dist/core/messages/zh/analysts/report-circleci-messages.js +7 -7
  205. package/dist/core/messages/zh/caretakers/caretaker-messages.js +1 -7
  206. package/dist/core/messages/zh/core/plugin-messages.js +31 -3
  207. package/dist/core/messages/zh/log/log.js +3 -3
  208. package/dist/core/messages/zh/ui/filter-config.js +1 -5
  209. package/dist/core/parsing/filters.js +3 -3
  210. package/dist/core/parsing/langs/json.js +1 -1
  211. package/dist/core/parsing/langs/python.js +1 -1
  212. package/dist/core/parsing/langs/typescript.js +1 -1
  213. package/dist/core/parsing/parser.js +3 -4
  214. package/dist/core/parsing/utils.js +1 -0
  215. package/dist/core/registry/file-registry.js +3 -2
  216. package/dist/core/registry/paths.js +3 -3
  217. package/dist/core/reporting/default-reporter.js +2 -2
  218. package/dist/core/schema/version.js +6 -6
  219. package/dist/core/workers/worker-executor.js +3 -3
  220. package/dist/core/workers/worker-pool.js +0 -0
  221. package/dist/guardian/baseline.js +1 -1
  222. package/dist/guardian/gpg.js +3 -1
  223. package/dist/guardian/integrity.js +2 -7
  224. package/dist/guardian/records.js +7 -1
  225. package/dist/guardian/result.js +1 -1
  226. package/dist/guardian/sentinel.js +7 -1
  227. package/dist/guardian/watcher-hidden.js +6 -1
  228. package/dist/licenses/fs-utils.js +5 -1
  229. package/dist/licenses/generate-notices.js +1 -1
  230. package/dist/licenses/index.js +1 -0
  231. package/dist/licenses/normalizer.js +10 -9
  232. package/dist/node.loader.js +224 -4
  233. package/dist/reports/analise-async-patterns.js +1 -1
  234. package/dist/reports/filter-smart.js +2 -5
  235. package/dist/reports/generator-report.js +7 -7
  236. package/dist/reports/report-archetypes.js +10 -10
  237. package/dist/reports/report-caretaker-health.js +2 -1
  238. package/dist/reports/report-patterns-usage.js +1 -1
  239. package/dist/sdk/analyzer.js +1 -1
  240. package/dist/shared/data-processing/fragment-report.js +11 -11
  241. package/dist/shared/data-processing/json.js +1 -1
  242. package/dist/shared/data-processing/occurrences.js +3 -2
  243. package/dist/shared/formatters/code-min-formatter.js +1 -1
  244. package/dist/shared/formatters/engines/prettier.js +1 -1
  245. package/dist/shared/formatters/engines/stylelint.js +43 -40
  246. package/dist/shared/formatters/formatter.js +8 -8
  247. package/dist/shared/formatters/formatters/code.js +3 -3
  248. package/dist/shared/formatters/formatters/css.js +2 -10
  249. package/dist/shared/formatters/formatters/dotfiles.js +1 -1
  250. package/dist/shared/formatters/formatters/html.js +1 -5
  251. package/dist/shared/formatters/formatters/json.js +0 -3
  252. package/dist/shared/formatters/formatters/markdown.js +19 -24
  253. package/dist/shared/formatters/formatters/properties.js +2 -2
  254. package/dist/shared/formatters/formatters/shell.js +1 -4
  255. package/dist/shared/formatters/formatters/sql.js +0 -3
  256. package/dist/shared/formatters/formatters/xml.js +5 -7
  257. package/dist/shared/formatters/formatters/yaml.js +2 -7
  258. package/dist/shared/formatters/index.js +1 -1
  259. package/dist/shared/helpers/framework-detector.js +6 -2
  260. package/dist/shared/helpers/json.js +1 -1
  261. package/dist/shared/helpers/magic-constants-whitelist.js +1 -1
  262. package/dist/shared/helpers/masking.js +17 -17
  263. package/dist/shared/helpers/reader-report.js +0 -12
  264. package/dist/shared/helpers/structural-hash.js +3 -2
  265. package/dist/shared/helpers/structure.js +1 -1
  266. package/dist/shared/marketplace/registry.js +1 -1
  267. package/dist/shared/marketplace/remote.js +4 -4
  268. package/dist/shared/persistence/persistence.js +13 -6
  269. package/dist/shared/plugins/core-plugin.js +5 -1
  270. package/dist/shared/plugins/registry.js +3 -2
  271. package/dist/types/analysts/tailwind-correction.js +2 -0
  272. package/dist/types/caretakers/imports-barrel.js +1 -0
  273. package/dist/types/caretakers/index.js +4 -0
  274. package/dist/types/caretakers/map-reversion.js +1 -0
  275. package/dist/types/caretakers/pruning.js +1 -0
  276. package/dist/types/caretakers/scoring.js +1 -0
  277. package/dist/types/common/analysts.js +1 -1
  278. package/dist/types/core/config/filters.js +1 -0
  279. package/dist/types/core/config/index.js +2 -0
  280. package/dist/types/core/execution/ambiente.js +1 -0
  281. package/dist/types/core/execution/linguagens.js +1 -0
  282. package/dist/types/core/execution/parse-errors.js +1 -0
  283. package/dist/types/core/execution/results.js +1 -0
  284. package/dist/types/core/execution/structure-json.js +1 -0
  285. package/dist/types/core/index.js +1 -0
  286. package/dist/types/core/messages/index.js +1 -0
  287. package/dist/types/core/messages/log.js +1 -0
  288. package/dist/types/core/parsing/babel-narrow.js +1 -0
  289. package/dist/types/core/parsing/index.js +1 -0
  290. package/dist/types/core/runtime.js +1 -0
  291. package/dist/types/guardian/index.js +2 -0
  292. package/dist/types/guardian/integrity.js +7 -0
  293. package/dist/types/guardian/snapshot.js +1 -0
  294. package/dist/types/index.js +4 -4
  295. package/dist/types/licenses/index.js +2 -0
  296. package/dist/types/processing/display.js +16 -13
  297. package/dist/types/processing/filters.js +8 -11
  298. package/dist/types/reports/compliance.js +1 -0
  299. package/dist/types/reports/streaming.js +1 -0
  300. package/dist/types/scripts/index.js +1 -0
  301. package/dist/types/scripts/migrar-aliases.js +1 -0
  302. package/dist/types/sdk/index.js +1 -0
  303. package/dist/types/shared/index.js +2 -0
  304. package/dist/types/vulnerabilities/index.js +2 -0
  305. package/dist/vulnerabilities/scanner.js +3 -2
  306. package/package.json +14 -20
@@ -23,7 +23,7 @@ export function maskKeepingNewlines(src, start, end) {
23
23
  export function maskJsComments(src) {
24
24
  let out = src;
25
25
  for (const metrica of out.matchAll(/\/\*[\s\S]*?\*\//g)) {
26
- const start = metrica.index ?? -1;
26
+ const start = metrica.index;
27
27
  if (start < 0) {
28
28
  continue;
29
29
  }
@@ -31,11 +31,11 @@ export function maskJsComments(src) {
31
31
  }
32
32
  // Usa negative lookbehind para evitar match em URLs (://)
33
33
  for (const metrica of out.matchAll(/(?<![\\:])\/\/.*$/gm)) {
34
- const start = metrica.index ?? -1;
34
+ const start = metrica.index;
35
35
  if (start < 0) {
36
36
  continue;
37
37
  }
38
- out = maskKeepingNewlines(out, start, start + (metrica[0].length ?? 0));
38
+ out = maskKeepingNewlines(out, start, start + metrica[0].length);
39
39
  }
40
40
  return out;
41
41
  }
@@ -47,7 +47,7 @@ export function maskJsComments(src) {
47
47
  export function maskHtmlComments(src) {
48
48
  let out = src;
49
49
  for (const metrica of out.matchAll(/<!--([\s\S]*?)-->/g)) {
50
- const start = metrica.index ?? -1;
50
+ const start = metrica.index;
51
51
  if (start < 0) {
52
52
  continue;
53
53
  }
@@ -66,7 +66,7 @@ export function maskTagBlocks(src, tag) {
66
66
  let out = src;
67
67
  const re = new RegExp(`<${tag}\\b[^>]*>[\\s\\S]*?<\\/${tag}>`, 'gi');
68
68
  for (const metrica of out.matchAll(re)) {
69
- const start = metrica.index ?? -1;
69
+ const start = metrica.index;
70
70
  if (start < 0) {
71
71
  continue;
72
72
  }
@@ -83,14 +83,14 @@ export function maskTagBlocks(src, tag) {
83
83
  export function maskXmlNonCode(src) {
84
84
  let out = src;
85
85
  for (const metrica of out.matchAll(/<!--[\s\S]*?-->/g)) {
86
- const start = metrica.index ?? -1;
86
+ const start = metrica.index;
87
87
  if (start < 0) {
88
88
  continue;
89
89
  }
90
90
  out = maskKeepingNewlines(out, start, start + metrica[0].length);
91
91
  }
92
92
  for (const metrica of out.matchAll(/<!\[CDATA\[[\s\S]*?\]\]>/g)) {
93
- const start = metrica.index ?? -1;
93
+ const start = metrica.index;
94
94
  if (start < 0) {
95
95
  continue;
96
96
  }
@@ -107,14 +107,14 @@ export function maskXmlNonCode(src) {
107
107
  export function maskPythonStringsAndComments(src) {
108
108
  let out = maskPythonComments(src);
109
109
  for (const metrica of out.matchAll(/([ruRUfFbB]{0,3})("""|''')[\s\S]*?\2/g)) {
110
- const start = metrica.index ?? -1;
110
+ const start = metrica.index;
111
111
  if (start < 0) {
112
112
  continue;
113
113
  }
114
114
  out = maskKeepingNewlines(out, start, start + metrica[0].length);
115
115
  }
116
116
  for (const metrica of out.matchAll(/([ruRUfFbB]{0,3})("([^"\\\n]|\\.)*"|'([^'\\\n]|\\.)*')/g)) {
117
- const start = metrica.index ?? -1;
117
+ const start = metrica.index;
118
118
  if (start < 0) {
119
119
  continue;
120
120
  }
@@ -130,11 +130,11 @@ export function maskPythonStringsAndComments(src) {
130
130
  export function maskPythonComments(src) {
131
131
  let out = src;
132
132
  for (const metrica of out.matchAll(/(^|[^\\])#.*$/gm)) {
133
- const start = (metrica.index ?? -1) + (metrica[1] ? metrica[1].length : 0);
133
+ const start = metrica.index + (metrica[1] ? metrica[1].length : 0);
134
134
  if (start < 0) {
135
135
  continue;
136
136
  }
137
- out = maskKeepingNewlines(out, start, start + (metrica[0].length ?? 0) - (metrica[1] ? metrica[1].length : 0));
137
+ out = maskKeepingNewlines(out, start, start + (metrica[0].length) - (metrica[1] ? metrica[1].length : 0));
138
138
  }
139
139
  return out;
140
140
  }
@@ -146,14 +146,14 @@ export function maskPythonComments(src) {
146
146
  export function maskGoComments(src) {
147
147
  let out = src;
148
148
  for (const metrica of out.matchAll(/\/\*[\s\S]*?\*\//g)) {
149
- const start = metrica.index ?? -1;
149
+ const start = metrica.index;
150
150
  if (start < 0) {
151
151
  continue;
152
152
  }
153
153
  out = maskKeepingNewlines(out, start, start + metrica[0].length);
154
154
  }
155
155
  for (const metrica of out.matchAll(/\/\/.*$/gm)) {
156
- const start = metrica.index ?? -1;
156
+ const start = metrica.index;
157
157
  if (start < 0) {
158
158
  continue;
159
159
  }
@@ -178,14 +178,14 @@ export function maskRustComments(src) {
178
178
  export function maskJavaComments(src) {
179
179
  let out = src;
180
180
  for (const metrica of out.matchAll(/\/\*[\s\S]*?\*\//g)) {
181
- const start = metrica.index ?? -1;
181
+ const start = metrica.index;
182
182
  if (start < 0) {
183
183
  continue;
184
184
  }
185
185
  out = maskKeepingNewlines(out, start, start + metrica[0].length);
186
186
  }
187
187
  for (const metrica of out.matchAll(/\/\/.*$/gm)) {
188
- const start = metrica.index ?? -1;
188
+ const start = metrica.index;
189
189
  if (start < 0) {
190
190
  continue;
191
191
  }
@@ -202,14 +202,14 @@ export function maskJavaComments(src) {
202
202
  export function maskPhpComments(src) {
203
203
  let out = src;
204
204
  for (const metrica of out.matchAll(/\/\*[\s\S]*?\*\//g)) {
205
- const start = metrica.index ?? -1;
205
+ const start = metrica.index;
206
206
  if (start < 0) {
207
207
  continue;
208
208
  }
209
209
  out = maskKeepingNewlines(out, start, start + metrica[0].length);
210
210
  }
211
211
  for (const metrica of out.matchAll(/(\/\/|#).*$/gm)) {
212
- const start = metrica.index ?? -1;
212
+ const start = metrica.index;
213
213
  if (start < 0) {
214
214
  continue;
215
215
  }
@@ -12,12 +12,6 @@ export async function lerRelatorioVersionado(options) {
12
12
  try {
13
13
  // Ler arquivo
14
14
  const conteudo = await lerEstado(caminho);
15
- if (!conteudo) {
16
- return {
17
- sucesso: false,
18
- erro: 'Arquivo não encontrado ou vazio',
19
- };
20
- }
21
15
  let relatorioFinal = conteudo;
22
16
  let migrado = false;
23
17
  // Validar schema se solicitado
@@ -97,12 +91,6 @@ export async function lerDadosRelatorio(caminho) {
97
91
  export async function verificarSchemaRelatorio(caminho) {
98
92
  try {
99
93
  const conteudo = await lerEstado(caminho);
100
- if (!conteudo) {
101
- return {
102
- valido: false,
103
- erros: ['Arquivo não encontrado ou vazio'],
104
- };
105
- }
106
94
  const validacao = validarSchema(conteudo);
107
95
  return {
108
96
  valido: validacao.valido,
@@ -34,7 +34,7 @@ function extrairEstrutura(ast) {
34
34
  return elementos;
35
35
  }
36
36
  const node = isNodePath(ast) ? ast.node : ast;
37
- if (!node || typeof node !== 'object') {
37
+ if (typeof node !== 'object') {
38
38
  return elementos;
39
39
  }
40
40
  const nodeRecord = toRecord(node);
@@ -47,7 +47,8 @@ function extrairEstrutura(ast) {
47
47
  }
48
48
  const body = Array.isArray(program.body) ? program.body : [];
49
49
  for (const stmt of body) {
50
- const tipo = String(stmt.type ?? '');
50
+ const rawTipo = stmt.type;
51
+ const tipo = typeof rawTipo === 'string' ? rawTipo : '';
51
52
  const stmtRecord = toRecord(stmt);
52
53
  if (!stmtRecord) {
53
54
  continue;
@@ -268,7 +268,7 @@ export function normalizarRel(relPath) {
268
268
  export async function carregarConfigEstrategia(baseDir, overrides) {
269
269
  const caminho = path.join(baseDir, '.mahoraga', 'estrutura.json');
270
270
  const lido = await lerEstado(caminho);
271
- const cfgObj = lido && !Array.isArray(lido) && typeof lido === 'object' ? lido : {};
271
+ const cfgObj = !Array.isArray(lido) && typeof lido === 'object' ? lido : {};
272
272
  const nomePreset = overrides?.preset ?? cfgObj['preset'];
273
273
  const preset = nomePreset && PRESETS[nomePreset].nome ? PRESETS[nomePreset] : undefined;
274
274
  const base = {
@@ -26,7 +26,7 @@ export async function salvarPacotesInstalados(pacotes) {
26
26
  }
27
27
  export async function pacoteEstaInstalado(nome) {
28
28
  const pacotes = await listarPacotesInstalados();
29
- return pacotes.find(p => p.nome === nome) ?? null;
29
+ return pacotes?.find(p => p.nome === nome) ?? null;
30
30
  }
31
31
  export async function instalarPacote(analista, versao, _conteudo) {
32
32
  const pacotes = await listarPacotesInstalados();
@@ -15,7 +15,7 @@ const CONFIG_PATH = '.mahoraga/marketplace/registries.json';
15
15
  async function carregarRegistries() {
16
16
  try {
17
17
  const configs = await lerEstado(CONFIG_PATH);
18
- if (!configs || configs.length === 0) {
18
+ if (configs.length === 0) {
19
19
  return DEFAULT_REGISTRIES;
20
20
  }
21
21
  return configs;
@@ -55,7 +55,7 @@ export async function obterAnalistaDoRegistry(nome, registry) {
55
55
  }
56
56
  try {
57
57
  const analistas = await fetchRegistry(reg);
58
- const encontrado = analistas.find(a => a.nome === nome);
58
+ const encontrado = analistas?.find(a => a.nome === nome);
59
59
  if (encontrado) {
60
60
  return encontrado;
61
61
  }
@@ -74,7 +74,7 @@ async function fetchRegistry(reg) {
74
74
  throw new Error(MarketplaceRemoteMensagens.httpStatus(res.status));
75
75
  }
76
76
  const data = await res.json();
77
- return data.analistas || [];
77
+ return data.analistas;
78
78
  }
79
79
  case 'github': {
80
80
  const apiUrl = `https://api.github.com/repos/${reg.url}/contents/index.json`;
@@ -85,7 +85,7 @@ async function fetchRegistry(reg) {
85
85
  throw new Error(MarketplaceRemoteMensagens.githubApiHttpStatus(res.status));
86
86
  }
87
87
  const data = await res.json();
88
- return data.analistas || [];
88
+ return data.analistas;
89
89
  }
90
90
  case "npm": {
91
91
  throw new Error('Not implemented yet: "npm" case');
@@ -6,7 +6,6 @@ import * as fsCb from 'node:fs';
6
6
  import { promises as fs } from 'node:fs';
7
7
  import path from 'node:path';
8
8
  import { messages } from '../../core/messages/index.js';
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
9
  const getLog = () => messages.log;
11
10
  const RAIZ = process.cwd();
12
11
  const IS_TEST = (process.env.VITEST ?? '') !== '';
@@ -110,11 +109,18 @@ async function salvarEstadoImpl(caminho, dados) {
110
109
  /**
111
110
  * Encapsula função com spy do Vitest quando em ambiente de teste,
112
111
  * permitindo assertions sem modificar a implementação original.
113
- * @template T - Tipo da função
114
- * @param fn - Função original
115
- * @returns Função com spy ou a original
112
+ *
113
+ * @template T - Tipo da função que será envolvida. Deve ser uma função com qualquer número de argumentos
114
+ * @param fn - Função original a ser envolvida com spy
115
+ * @returns Função com spy do Vitest (se em ambiente de teste) ou a função original sem modificações
116
+ * @throws Não lança erros; erros internos são logados como debug
117
+ *
118
+ * @example
119
+ * const originalFn = (x: number) => x * 2;
120
+ * const spyedFn = wrapVitestSpy(originalFn);
121
+ * // Se em teste: spyedFn pode ser usado para assertions (vi.fn())
122
+ * // Se em produção: spyedFn é idêntico a originalFn
116
123
  */
117
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
118
124
  function wrapVitestSpy(fn) {
119
125
  try {
120
126
  const maybeVi = globalThis.vi;
@@ -123,7 +129,8 @@ function wrapVitestSpy(fn) {
123
129
  }
124
130
  }
125
131
  catch (err) {
126
- getLog().debug(`Erro ao configurar spy (Vitest): ${err instanceof Error ? err.message : String(err)}`);
132
+ const errorMessage = err instanceof Error ? err.message : String(err);
133
+ getLog().debug(`Erro ao configurar spy (Vitest): ${errorMessage}`);
127
134
  }
128
135
  return fn;
129
136
  }
@@ -1,3 +1,4 @@
1
+ // SPDX-License-Identifier: MIT
1
2
  import { getMessages } from '../../core/messages/index.js';
2
3
  import { parseComBabel, parseComCss, parseComHtmlFunc, parseComPhp, parseComPython, parseComTypeScript, parseComXml, } from '../../core/parsing/langs/index.js';
3
4
  const { logCore } = getMessages();
@@ -58,7 +59,10 @@ export class CorePlugin {
58
59
  }
59
60
  inferExtension(codigo, opts) {
60
61
  if (opts?.pluginConfig?.extension) {
61
- return String(opts.pluginConfig.extension);
62
+ const ext = opts.pluginConfig.extension;
63
+ if (typeof ext === 'string') {
64
+ return ext;
65
+ }
62
66
  }
63
67
  if (/^<\?php/.test(codigo.trim())) {
64
68
  return '.php';
@@ -91,7 +91,8 @@ export class PluginRegistry {
91
91
  // Usa import dinâmico mockável (globalThis.import pode ser substituído nos testes)
92
92
  const dynImport = globalThis.import ?? ((caminho) => import(caminho));
93
93
  const pluginModule = await dynImport(pluginCaminho);
94
- const plugin = pluginModule.default || pluginModule;
94
+ const pluginModuleDefault = pluginModule.default;
95
+ const plugin = (pluginModuleDefault ?? pluginModule);
95
96
  // Valida e registra
96
97
  this.validatePlugin(plugin);
97
98
  this.registerPlugin(plugin);
@@ -134,7 +135,7 @@ export class PluginRegistry {
134
135
  // Verifica suporte da linguagem
135
136
  const langChave = extension.substring(1); // remove o ponto
136
137
  const langSuporte = this.languageSupport[langChave];
137
- if (langSuporte && !langSuporte.enabled) {
138
+ if (!langSuporte.enabled) {
138
139
  const msgLinguagem = messages.PluginRegistryMensagens.linguagemDesabilitada;
139
140
  log.debug(msgLinguagem.replace('{linguagem}', langChave));
140
141
  return null;
@@ -0,0 +1,2 @@
1
+ // SPDX-License-Identifier: MIT
2
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './imports-barrel.js';
2
+ export * from './map-reversion.js';
3
+ export * from './pruning.js';
4
+ export * from './scoring.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -4,7 +4,7 @@ import { messages } from '../../core/messages/index.js';
4
4
  * Fábrica para criar analista com validação mínima
5
5
  */
6
6
  export function criarAnalista(def) {
7
- if (!def || typeof def !== 'object') {
7
+ if (typeof def !== 'object') {
8
8
  throw new Error(messages.ExcecoesMensagens.definicaoAnalistaInvalida);
9
9
  }
10
10
  if (!def.nome || /\s/.test(def.nome)) {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './filters.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './runtime.js';
@@ -0,0 +1 @@
1
+ export * from './log.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './babel-narrow.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './integrity.js';
2
+ export * from './snapshot.js';
@@ -0,0 +1,7 @@
1
+ export var IntegridadeStatus;
2
+ (function (IntegridadeStatus) {
3
+ IntegridadeStatus["Criado"] = "baseline-criado";
4
+ IntegridadeStatus["Aceito"] = "baseline-aceito";
5
+ IntegridadeStatus["Ok"] = "ok";
6
+ IntegridadeStatus["AlteracoesDetectadas"] = "alteracoes-detectadas";
7
+ })(IntegridadeStatus || (IntegridadeStatus = {}));
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,9 @@
1
- export { IntegridadeStatus } from '../guardian/integrity.js';
2
- export { converterResultadoGuardian } from '../guardian/result.js';
3
- export { extrairMensagemErro } from '../shared/validation.js';
4
1
  export * from './analysts/index.js';
5
2
  export * from './common/index.js';
3
+ export { IntegridadeStatus } from './guardian/integrity.js';
6
4
  export * from './processing/index.js';
7
5
  export * from './project/index.js';
8
6
  export * from './structure/index.js';
9
- export { GuardianError } from '../guardian/integrity.js';
7
+ export { converterResultadoGuardian } from '../guardian/index.js';
8
+ export { extrairMensagemErro } from '../shared/index.js';
9
+ export { GuardianError } from '../guardian/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './header-options.js';
2
+ export * from './licenses.js';
@@ -26,10 +26,13 @@ export function exibirBlocoFiltros(includeGroupsExpanded, includeListFlat, exclu
26
26
  linhas.push('(node_modules incluído: ignorado dos padrões de exclusão)');
27
27
  }
28
28
  const titulo = 'Filtros ativos:';
29
- const l = getLog();
30
- const largura = l.calcularLargura ? l.calcularLargura(titulo, linhas, config.COMPACT_MODE ? 84 : 96) : undefined;
31
- const logBloco = (l).imprimirBloco;
32
- const logInfo = l;
29
+ const log = getLog();
30
+ const logComLargura = log;
31
+ const largura = logComLargura.calcularLargura
32
+ ? logComLargura.calcularLargura(titulo, linhas, config.COMPACT_MODE ? 84 : 96)
33
+ : undefined;
34
+ const logBloco = (log).imprimirBloco;
35
+ const logInfo = log;
33
36
  if (typeof logInfo.info === 'function') {
34
37
  if (linhas.length) {
35
38
  logInfo.info(`${titulo} ${linhas.join(' ')}`);
@@ -40,7 +43,7 @@ export function exibirBlocoFiltros(includeGroupsExpanded, includeListFlat, exclu
40
43
  }
41
44
  // Imprime bloco moldurado se disponível
42
45
  if (typeof logBloco === 'function') {
43
- logBloco(titulo, linhas, chalk.cyan.bold, typeof largura === 'number' ? largura : config.COMPACT_MODE ? 84 : 96);
46
+ logBloco(titulo, linhas, chalk.cyan.bold ?? ((text) => text), typeof largura === 'number' ? largura : config.COMPACT_MODE ? 84 : 96);
44
47
  }
45
48
  }
46
49
  // Função para listar analistas registrados
@@ -53,12 +56,12 @@ export async function listarAnalistas() {
53
56
  }
54
57
  catch (err) {
55
58
  listaAnalistas = [];
56
- const l2 = getLog();
57
- if (config.DEV_MODE && typeof l2.debug === 'function') {
58
- l2.debug(`Falha ao listar analistas: ${String(err)}`);
59
+ const log2 = getLog();
60
+ if (config.DEV_MODE && typeof log2.debug === 'function') {
61
+ log2.debug(`Falha ao listar analistas: ${String(err)}`);
59
62
  }
60
- if (process.env.VITEST && typeof l2.debug === 'function') {
61
- l2.debug('Falha ao listar analistas');
63
+ if (process.env.VITEST && typeof log2.debug === 'function') {
64
+ log2.debug('Falha ao listar analistas');
62
65
  }
63
66
  }
64
67
  // Prepara linhas do bloco
@@ -78,9 +81,9 @@ export async function listarAnalistas() {
78
81
  const titulo = 'Técnicas ativas (registro de analistas)';
79
82
  // Largura definida dinamicamente com fallback para modo compacto/padrão
80
83
  let largura;
81
- const l3 = getLog();
82
- if (typeof (l3).calcularLargura === 'function') {
83
- largura = l3.calcularLargura(titulo, linhas, config.COMPACT_MODE ? 84 : 96);
84
+ const log3 = getLog();
85
+ if (typeof (log3).calcularLargura === 'function') {
86
+ largura = log3.calcularLargura(titulo, linhas, config.COMPACT_MODE ? 84 : 96);
84
87
  // Se calcularLargura retornar undefined, usar fallback 96
85
88
  if (typeof largura !== 'number' || isNaN(largura)) {
86
89
  largura = config.COMPACT_MODE ? 84 : 96;
@@ -37,13 +37,9 @@ export function expandIncludes(list) {
37
37
  export function getDefaultExcludes() {
38
38
  // Primeiro tenta obter do mahoraga.config.json do usuário
39
39
  const configIncluirExcluir = config.INCLUDE_EXCLUDE_RULES;
40
- if (configIncluirExcluir) {
41
- // Prioriza `globalExcludeGlob` (configuração moderna). Se não existir,
42
- // usa `defaultExcludes` para compatibilidade com formas antigas.
43
- if (Array.isArray(configIncluirExcluir.globalExcludeGlob) && configIncluirExcluir.globalExcludeGlob.length > 0) {
44
- return Array.from(new Set(configIncluirExcluir.globalExcludeGlob));
45
- }
46
- // Se não houver globalExcludeGlob, cairá no fallback abaixo que mescla padrões do sistema
40
+ const globalExclude = configIncluirExcluir.globalExcludeGlob;
41
+ if (Array.isArray(globalExclude) && globalExclude.length > 0) {
42
+ return Array.from(new Set(configIncluirExcluir.globalExcludeGlob));
47
43
  }
48
44
  // Se não há configuração do usuário, usa os padrões recomendados do sistema
49
45
  // Por enquanto usa 'generico', mas poderia detectar o tipo de projeto
@@ -78,13 +74,14 @@ function detectarTipoProjeto() {
78
74
  // Função principal para configurar filtros CLI
79
75
  export function configurarFiltros(includeGroupsRaw, includeListFlat, excludeList, incluiNodeModules) {
80
76
  // Configurar includes
77
+ const cfg = config;
81
78
  if (includeListFlat.length) {
82
- config.CLI_INCLUDE_GROUPS = includeGroupsRaw;
83
- config.CLI_INCLUDE_PATTERNS = includeListFlat;
79
+ cfg.CLI_INCLUDE_GROUPS = includeGroupsRaw;
80
+ cfg.CLI_INCLUDE_PATTERNS = includeListFlat;
84
81
  }
85
82
  else {
86
- config.CLI_INCLUDE_GROUPS = [];
87
- config.CLI_INCLUDE_PATTERNS = [];
83
+ cfg.CLI_INCLUDE_GROUPS = [];
84
+ cfg.CLI_INCLUDE_PATTERNS = [];
88
85
  }
89
86
  // Configurar excludes com precedência clara:
90
87
  // 1. CLI --exclude (prioridade máxima)
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './migrar-aliases.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './analyzer.js';
@@ -0,0 +1,2 @@
1
+ export * from './memory.js';
2
+ export * from './persistence.js';
@@ -0,0 +1,2 @@
1
+ export * from './npm-audit.js';
2
+ export * from './vulnerabilities.js';
@@ -5,7 +5,8 @@ function execFileAsync(cmd, args, opts) {
5
5
  return new Promise((resolve, reject) => {
6
6
  execFile(cmd, args, opts, (err, stdout) => {
7
7
  if (err) {
8
- reject(Object.assign(err, { stdout }));
8
+ const npmErr = Object.assign(err, { stdout });
9
+ reject(npmErr);
9
10
  }
10
11
  else {
11
12
  resolve({ stdout });
@@ -54,7 +55,7 @@ function normalizeAuditResult(raw) {
54
55
  name: vuln.name,
55
56
  severity: vuln.severity,
56
57
  isDirect: vuln.isDirect,
57
- via: vuln.via.map(v => (typeof v === 'string' ? v : ((v.title ?? v.url) ?? v.name) ?? '')),
58
+ via: vuln.via.map(v => (typeof v === 'string' ? v : (v.title || v.url || v.name || ''))),
58
59
  effects: vuln.effects,
59
60
  range: vuln.range,
60
61
  fixAvailable: vuln.fixAvailable === false ? null : {