@mocoto/mahoraga 0.14.1 → 0.14.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 (268) hide show
  1. package/dist/analysts/architects/analyst-structure.js +1 -1
  2. package/dist/analysts/architects/archetypes-custom.js +8 -13
  3. package/dist/analysts/architects/detector-archetypes.js +39 -35
  4. package/dist/analysts/architects/orchestrator-archetypes.js +3 -3
  5. package/dist/analysts/architects/signals-project-advanced.js +2 -2
  6. package/dist/analysts/architects/signals-project.js +1 -1
  7. package/dist/analysts/azure-pipelines/analysts/analyst-azure.js +20 -21
  8. package/dist/analysts/azure-pipelines/detectors/detector-azure-structure.js +0 -3
  9. package/dist/analysts/circleci/analysts/analyst-circleci.js +22 -24
  10. package/dist/analysts/circleci/detectors/detector-circleci-structure.js +4 -7
  11. package/dist/analysts/converters/convert-registry.js +1 -1
  12. package/dist/analysts/converters/index.js +1 -1
  13. package/dist/analysts/corrections/auto-fix-engine.js +1 -1
  14. package/dist/analysts/corrections/corrector-structure.js +8 -7
  15. package/dist/analysts/corrections/map-reversion.js +2 -2
  16. package/dist/analysts/corrections/reorganize-barrels.js +3 -3
  17. package/dist/analysts/corrections/rewrite-testes-aliases.js +23 -22
  18. package/dist/analysts/corrections/type-safety/type-analyzer.js +3 -3
  19. package/dist/analysts/corrections/type-safety/type-validator.js +2 -2
  20. package/dist/analysts/corrections/type-safety/usage-analyzer.js +3 -3
  21. package/dist/analysts/css/analysts/analyst-css.js +27 -28
  22. package/dist/analysts/css-in-js/detectors/detector-css-in-js-best-practices.js +8 -15
  23. package/dist/analysts/detectors/detector-architecture.js +2 -2
  24. package/dist/analysts/detectors/detector-bugs-ml.js +8 -8
  25. package/dist/analysts/detectors/detector-code-fragile.js +11 -10
  26. package/dist/analysts/detectors/detector-dependencies.js +5 -5
  27. package/dist/analysts/detectors/detector-duplications.js +5 -8
  28. package/dist/analysts/detectors/detector-monorepo.js +10 -9
  29. package/dist/analysts/detectors/detector-performance.js +2 -1
  30. package/dist/analysts/detectors/detector-recommendation-architecture.js +1 -1
  31. package/dist/analysts/detectors/detector-security.js +1 -1
  32. package/dist/analysts/detectors/detector-structure.js +3 -3
  33. package/dist/analysts/github-actions/analysts/analyst-github-actions.js +5 -8
  34. package/dist/analysts/github-actions/detectors/detector-workflow-accessibility.js +1 -9
  35. package/dist/analysts/github-actions/detectors/detector-workflow-structure.js +1 -4
  36. package/dist/analysts/github-actions/detectors/detector-workflow-trigger-unsafe.js +6 -5
  37. package/dist/analysts/gitlab-ci/analysts/analyst-gitlab-ci.js +2 -2
  38. package/dist/analysts/gitlab-ci/detectors/detector-gitlab-ci-structure.js +0 -3
  39. package/dist/analysts/go/analysts/analyst-best-practices.js +2 -2
  40. package/dist/analysts/go/analysts/analyst-concurrency.js +1 -1
  41. package/dist/analysts/go/analysts/analyst-security.js +1 -1
  42. package/dist/analysts/go/detectors/detector-conventions.js +1 -1
  43. package/dist/analysts/html/analysts/analyst-html.js +10 -12
  44. package/dist/analysts/html/detectors/detector-html.js +3 -3
  45. package/dist/analysts/js-ts/analysts/analyst-commands-cli.js +22 -22
  46. package/dist/analysts/js-ts/analysts/analyst-functions-long.js +5 -5
  47. package/dist/analysts/js-ts/analysts/analyst-patterns-usage.js +6 -2
  48. package/dist/analysts/js-ts/detectors/detector-anti-patterns-async.js +81 -9
  49. package/dist/analysts/js-ts/detectors/detector-constructions-syntactic.js +35 -6
  50. package/dist/analysts/js-ts/detectors/detector-context-smart.js +6 -6
  51. package/dist/analysts/js-ts/detectors/detector-leaks-memory.js +1 -1
  52. package/dist/analysts/js-ts/detectors/detector-types-unsafe.js +33 -2
  53. package/dist/analysts/php/analysts/analyst-php.js +3 -3
  54. package/dist/analysts/php/detectors/detector-php-best-practices.js +5 -5
  55. package/dist/analysts/php/detectors/detector-php-security.js +5 -5
  56. package/dist/analysts/php/scorers/scorer-php.js +2 -2
  57. package/dist/analysts/plugins/detector-documentation.js +5 -6
  58. package/dist/analysts/plugins/detector-markdown.js +7 -7
  59. package/dist/analysts/python/analysts/analyst-python.js +2 -5
  60. package/dist/analysts/react/analysts/analyst-react-hooks.js +63 -8
  61. package/dist/analysts/react/analysts/analyst-react.js +45 -1
  62. package/dist/analysts/react/corrections/correction-react.js +40 -0
  63. package/dist/analysts/react/detectors/detector-react-best-practices.js +4 -4
  64. package/dist/analysts/react/scorers/scorer-react.js +36 -1
  65. package/dist/analysts/rust/analysts/analyst-best-practices.js +42 -3
  66. package/dist/analysts/rust/analysts/analyst-memory.js +2 -2
  67. package/dist/analysts/rust/analysts/analyst-rust.js +52 -5
  68. package/dist/analysts/rust/analysts/analyst-security.js +29 -1
  69. package/dist/analysts/scorers/scorer.js +5 -5
  70. package/dist/analysts/shell/analysts/analyst-shell.js +81 -5
  71. package/dist/analysts/shell/corrections/correction-shell.js +34 -1
  72. package/dist/analysts/shell/detectors/detector-shell-security.js +88 -0
  73. package/dist/analysts/shell/scorers/scorer-shell.js +58 -1
  74. package/dist/analysts/strategists/operator-structure.js +5 -7
  75. package/dist/analysts/strategists/suggestions-contextuais.js +5 -2
  76. package/dist/analysts/svg/analysts/analyst-svg.js +1 -0
  77. package/dist/analysts/tailwind/analysts/analyst-tailwind.js +79 -55
  78. package/dist/analysts/tailwind/corrections/correction-tailwind.js +116 -9
  79. package/dist/analysts/tailwind/detectors/detector-tailwind-best-practices.js +122 -7
  80. package/dist/analysts/tailwind/scorers/scorer-tailwind.js +62 -10
  81. package/dist/analysts/xml/analysts/analyst-xml.js +2 -2
  82. package/dist/app/index.js +1 -0
  83. package/dist/bin/cli-bootstrap.js +6 -4
  84. package/dist/bin/index.js +6 -4
  85. package/dist/caretakers/scoring.js +1 -0
  86. package/dist/cli/commands/command-analysts.js +1 -1
  87. package/dist/cli/commands/command-azure.js +1 -1
  88. package/dist/cli/commands/command-circleci.js +1 -1
  89. package/dist/cli/commands/command-compliance.js +1 -1
  90. package/dist/cli/commands/command-diagnose.js +10 -13
  91. package/dist/cli/commands/command-fix-types.js +9 -32
  92. package/dist/cli/commands/command-formatters.js +2 -2
  93. package/dist/cli/commands/command-gitlab-ci.js +1 -1
  94. package/dist/cli/commands/command-guardian.js +1 -1
  95. package/dist/cli/commands/command-imports.js +6 -6
  96. package/dist/cli/commands/command-jenkins.js +1 -1
  97. package/dist/cli/commands/command-licenses.js +1 -1
  98. package/dist/cli/commands/command-marketplace.js +3 -3
  99. package/dist/cli/commands/command-names.js +3 -8
  100. package/dist/cli/commands/command-perf.js +7 -9
  101. package/dist/cli/commands/command-plugins.js +4 -4
  102. package/dist/cli/diagnostic/auto-fix.js +2 -2
  103. package/dist/cli/diagnostic/exporters/json-exporter.js +1 -1
  104. package/dist/cli/diagnostic/exporters/sharded-exporter.js +0 -3
  105. package/dist/cli/diagnostic/exporters/svg-optimization-exporter.js +1 -1
  106. package/dist/cli/diagnostic/handlers/archetype-handler.js +3 -6
  107. package/dist/cli/diagnostic/handlers/auto-fix-handler.js +4 -4
  108. package/dist/cli/diagnostic/handlers/guardian-handler.js +1 -1
  109. package/dist/cli/diagnostic/processing-diagnostic.js +31 -35
  110. package/dist/cli/diagnostic/processing-helpers.js +2 -2
  111. package/dist/cli/handlers/fix-types-exporter.js +1 -4
  112. package/dist/cli/helpers/display-frame.js +5 -5
  113. package/dist/core/config/auto/auto-fix-config.js +0 -6
  114. package/dist/core/config/chalk-safe.js +2 -2
  115. package/dist/core/config/config.js +6 -8
  116. package/dist/core/config/conventions.js +1 -1
  117. package/dist/core/config/security.js +2 -2
  118. package/dist/core/execution/analysis-cache.js +5 -8
  119. package/dist/core/execution/executor.js +8 -19
  120. package/dist/core/execution/inquisitor.js +24 -21
  121. package/dist/core/execution/results.js +1 -0
  122. package/dist/core/execution/scanner.js +3 -3
  123. package/dist/core/messages/en/analysts/analyst-github-actions-messages.js +1 -1
  124. package/dist/core/messages/en/analysts/analyst-patterns-usage-messages.js +1 -0
  125. package/dist/core/messages/en/analysts/analyst-shell-messages.js +15 -0
  126. package/dist/core/messages/en/analysts/detector-constructions-syntactic-messages.js +6 -0
  127. package/dist/core/messages/en/analysts/detector-js-ts-messages.js +27 -0
  128. package/dist/core/messages/en/analysts/detector-react-messages.js +8 -0
  129. package/dist/core/messages/en/analysts/detector-shell-messages.js +17 -0
  130. package/dist/core/messages/en/analysts/detector-tailwind-messages.js +3 -3
  131. package/dist/core/messages/en/core/plugin-messages.js +31 -3
  132. package/dist/core/messages/en/log/log.js +4 -4
  133. package/dist/core/messages/en/ui/filter-config.js +1 -5
  134. package/dist/core/messages/i18n-system.js +3 -3
  135. package/dist/core/messages/index.js +3 -3
  136. package/dist/core/messages/ja/analysts/analyst-github-actions-messages.js +1 -1
  137. package/dist/core/messages/ja/analysts/analyst-patterns-usage-messages.js +1 -0
  138. package/dist/core/messages/ja/analysts/analyst-shell-messages.js +15 -0
  139. package/dist/core/messages/ja/analysts/detector-constructions-syntactic-messages.js +6 -0
  140. package/dist/core/messages/ja/analysts/detector-js-ts-messages.js +27 -0
  141. package/dist/core/messages/ja/analysts/detector-react-messages.js +8 -0
  142. package/dist/core/messages/ja/analysts/detector-shell-messages.js +17 -0
  143. package/dist/core/messages/ja/analysts/detector-tailwind-messages.js +3 -3
  144. package/dist/core/messages/ja/core/plugin-messages.js +31 -3
  145. package/dist/core/messages/ja/log/log.js +4 -4
  146. package/dist/core/messages/ja/ui/filter-config.js +1 -1
  147. package/dist/core/messages/pt/analysts/analyst-github-actions-messages.js +1 -1
  148. package/dist/core/messages/pt/analysts/analyst-patterns-usage-messages.js +1 -0
  149. package/dist/core/messages/pt/analysts/analyst-shell-messages.js +15 -0
  150. package/dist/core/messages/pt/analysts/detector-constructions-syntactic-messages.js +6 -0
  151. package/dist/core/messages/pt/analysts/detector-js-ts-messages.js +27 -0
  152. package/dist/core/messages/pt/analysts/detector-react-messages.js +8 -0
  153. package/dist/core/messages/pt/analysts/detector-shell-messages.js +17 -0
  154. package/dist/core/messages/pt/analysts/detector-tailwind-messages.js +3 -3
  155. package/dist/core/messages/pt/core/plugin-messages.js +31 -3
  156. package/dist/core/messages/pt/log/log-engine.js +6 -6
  157. package/dist/core/messages/pt/log/log.js +3 -3
  158. package/dist/core/messages/pt/ui/filter-config.js +1 -1
  159. package/dist/core/messages/shared/icons.js +3 -3
  160. package/dist/core/messages/zh/analysts/analyst-github-actions-messages.js +1 -1
  161. package/dist/core/messages/zh/analysts/analyst-patterns-usage-messages.js +1 -0
  162. package/dist/core/messages/zh/analysts/analyst-shell-messages.js +15 -0
  163. package/dist/core/messages/zh/analysts/detector-constructions-syntactic-messages.js +6 -0
  164. package/dist/core/messages/zh/analysts/detector-js-ts-messages.js +27 -0
  165. package/dist/core/messages/zh/analysts/detector-react-messages.js +8 -0
  166. package/dist/core/messages/zh/analysts/detector-shell-messages.js +17 -0
  167. package/dist/core/messages/zh/analysts/detector-tailwind-messages.js +3 -3
  168. package/dist/core/messages/zh/core/plugin-messages.js +31 -3
  169. package/dist/core/messages/zh/log/log.js +3 -3
  170. package/dist/core/messages/zh/ui/filter-config.js +1 -5
  171. package/dist/core/parsing/filters.js +3 -3
  172. package/dist/core/parsing/langs/json.js +1 -1
  173. package/dist/core/parsing/langs/python.js +1 -1
  174. package/dist/core/parsing/langs/typescript.js +1 -1
  175. package/dist/core/parsing/parser.js +2 -2
  176. package/dist/core/registry/file-registry.js +3 -2
  177. package/dist/core/registry/paths.js +3 -3
  178. package/dist/core/reporting/default-reporter.js +2 -2
  179. package/dist/core/schema/version.js +6 -6
  180. package/dist/core/workers/worker-executor.js +3 -3
  181. package/dist/core/workers/worker-pool.js +0 -0
  182. package/dist/guardian/baseline.js +1 -1
  183. package/dist/guardian/gpg.js +3 -1
  184. package/dist/guardian/integrity.js +2 -7
  185. package/dist/guardian/records.js +6 -1
  186. package/dist/guardian/result.js +1 -1
  187. package/dist/guardian/sentinel.js +6 -1
  188. package/dist/guardian/watcher-hidden.js +5 -1
  189. package/dist/licenses/fs-utils.js +4 -1
  190. package/dist/licenses/generate-notices.js +1 -1
  191. package/dist/licenses/header-options.js +0 -1
  192. package/dist/licenses/index.js +1 -0
  193. package/dist/licenses/normalizer.js +10 -9
  194. package/dist/node.loader.js +224 -4
  195. package/dist/reports/analise-async-patterns.js +1 -1
  196. package/dist/reports/filter-smart.js +2 -5
  197. package/dist/reports/generator-report.js +4 -4
  198. package/dist/reports/report-archetypes.js +10 -10
  199. package/dist/reports/report-caretaker-health.js +2 -1
  200. package/dist/sdk/analyzer.js +1 -1
  201. package/dist/shared/data-processing/fragment-report.js +10 -10
  202. package/dist/shared/data-processing/json.js +1 -1
  203. package/dist/shared/data-processing/occurrences.js +3 -2
  204. package/dist/shared/formatters/code-min-formatter.js +1 -1
  205. package/dist/shared/formatters/engines/prettier.js +1 -1
  206. package/dist/shared/formatters/engines/stylelint.js +6 -9
  207. package/dist/shared/formatters/formatter.js +8 -8
  208. package/dist/shared/formatters/formatters/code.js +3 -3
  209. package/dist/shared/formatters/formatters/css.js +2 -10
  210. package/dist/shared/formatters/formatters/dotfiles.js +1 -1
  211. package/dist/shared/formatters/formatters/html.js +1 -5
  212. package/dist/shared/formatters/formatters/json.js +0 -3
  213. package/dist/shared/formatters/formatters/markdown.js +18 -23
  214. package/dist/shared/formatters/formatters/properties.js +2 -2
  215. package/dist/shared/formatters/formatters/shell.js +1 -4
  216. package/dist/shared/formatters/formatters/sql.js +0 -3
  217. package/dist/shared/formatters/formatters/xml.js +5 -7
  218. package/dist/shared/formatters/formatters/yaml.js +2 -7
  219. package/dist/shared/formatters/index.js +1 -1
  220. package/dist/shared/helpers/framework-detector.js +1 -1
  221. package/dist/shared/helpers/json.js +1 -1
  222. package/dist/shared/helpers/magic-constants-whitelist.js +1 -1
  223. package/dist/shared/helpers/masking.js +17 -17
  224. package/dist/shared/helpers/reader-report.js +0 -12
  225. package/dist/shared/helpers/structural-hash.js +3 -2
  226. package/dist/shared/helpers/structure.js +1 -1
  227. package/dist/shared/marketplace/registry.js +1 -1
  228. package/dist/shared/marketplace/remote.js +4 -4
  229. package/dist/shared/persistence/persistence.js +0 -1
  230. package/dist/shared/plugins/core-plugin.js +3 -1
  231. package/dist/shared/plugins/registry.js +3 -2
  232. package/dist/types/caretakers/imports-barrel.js +1 -0
  233. package/dist/types/caretakers/index.js +4 -0
  234. package/dist/types/caretakers/map-reversion.js +1 -0
  235. package/dist/types/caretakers/pruning.js +1 -0
  236. package/dist/types/caretakers/scoring.js +1 -0
  237. package/dist/types/common/analysts.js +1 -1
  238. package/dist/types/core/config/filters.js +1 -0
  239. package/dist/types/core/config/index.js +2 -0
  240. package/dist/types/core/execution/ambiente.js +1 -0
  241. package/dist/types/core/execution/linguagens.js +1 -0
  242. package/dist/types/core/execution/parse-errors.js +1 -0
  243. package/dist/types/core/execution/results.js +1 -0
  244. package/dist/types/core/execution/structure-json.js +1 -0
  245. package/dist/types/core/index.js +1 -0
  246. package/dist/types/core/messages/index.js +1 -0
  247. package/dist/types/core/messages/log.js +1 -0
  248. package/dist/types/core/parsing/babel-narrow.js +1 -0
  249. package/dist/types/core/parsing/index.js +1 -0
  250. package/dist/types/core/runtime.js +1 -0
  251. package/dist/types/guardian/index.js +2 -0
  252. package/dist/types/guardian/integrity.js +7 -0
  253. package/dist/types/guardian/snapshot.js +1 -0
  254. package/dist/types/index.js +4 -4
  255. package/dist/types/licenses/index.js +2 -0
  256. package/dist/types/processing/display.js +16 -13
  257. package/dist/types/processing/filters.js +3 -7
  258. package/dist/types/reports/compliance.js +1 -0
  259. package/dist/types/reports/streaming.js +1 -0
  260. package/dist/types/scripts/index.js +1 -0
  261. package/dist/types/scripts/migrar-aliases.js +1 -0
  262. package/dist/types/sdk/index.js +1 -0
  263. package/dist/types/shared/index.js +2 -0
  264. package/dist/types/vulnerabilities/index.js +2 -0
  265. package/dist/vulnerabilities/npm-audit.js +0 -1
  266. package/dist/vulnerabilities/scanner.js +2 -1
  267. package/dist/vulnerabilities/vulnerabilities.js +0 -1
  268. package/package.json +11 -12
@@ -156,13 +156,13 @@ function analisarDiferencas(pathsAtuais, pathsPropostos) {
156
156
  const entradasPropostas = analisarTsconfigPaths(pathsPropostos);
157
157
  const entradasRemovidas = [];
158
158
  for (const entrada of entradasAtuais) {
159
- if (!pathsPropostos[entrada.alias]) {
159
+ if (!(entrada.alias in pathsPropostos)) {
160
160
  entradasRemovidas.push(entrada);
161
161
  }
162
162
  }
163
163
  const entradasNovas = [];
164
164
  for (const [alias, targets] of Object.entries(pathsPropostos)) {
165
- if (!pathsAtuais[alias]) {
165
+ if (!(alias in pathsAtuais)) {
166
166
  entradasNovas.push({
167
167
  alias,
168
168
  targets,
@@ -253,14 +253,14 @@ async function aplicarImports(projectRoot, srcDir, paths) {
253
253
  }
254
254
  if (importPath.startsWith('@')) {
255
255
  let barrelAlias = importToRewrite;
256
- if (paths[importToRewrite]) {
256
+ if (importToRewrite in paths) {
257
257
  barrelAlias = importToRewrite;
258
258
  }
259
259
  else {
260
260
  const lastSlash = importToRewrite.lastIndexOf('/');
261
261
  if (lastSlash > 0) {
262
262
  const potentialBarrel = importToRewrite.substring(0, lastSlash);
263
- if (paths[potentialBarrel]) {
263
+ if (potentialBarrel in paths) {
264
264
  barrelAlias = potentialBarrel;
265
265
  }
266
266
  }
@@ -304,7 +304,7 @@ async function aplicarImports(projectRoot, srcDir, paths) {
304
304
  if (mesmoModuloPai(srcDir, arquivo, importToRewrite)) {
305
305
  break;
306
306
  }
307
- if (paths[novoImport] && novoImport !== importPath) {
307
+ if (novoImport !== importPath && paths[novoImport]) {
308
308
  const regexResult = criarRegexImport(importPath, importToRewrite, line);
309
309
  if (regexResult) {
310
310
  lines[indice] = line.replace(regexResult, `$1$2${novoImport}$2`);
@@ -312,7 +312,7 @@ async function aplicarImports(projectRoot, srcDir, paths) {
312
312
  modified = true;
313
313
  }
314
314
  }
315
- else if (!paths[novoImport]) {
315
+ else {
316
316
  const aliasDoPai = obterAliasPaiComBarrel(srcDir, relativeToSrc, aliasMap);
317
317
  if (aliasDoPai && aliasDoPai !== importPath) {
318
318
  const regexResult = criarRegexImport(importPath, importToRewrite, line);
@@ -64,7 +64,7 @@ export function comandoJenkins() {
64
64
  console.log('');
65
65
  ocorrencias.forEach((ocorrencia) => {
66
66
  const prefix = ocorrencia.nivel === 'erro' ? '[RED]' : ocorrencia.nivel === 'aviso' ? '[YELLOW]' : '[BLUE]';
67
- log.info(msgs.ocorrencia(prefix, ocorrencia.tipo ?? '', ocorrencia.linha ?? 0, ocorrencia.mensagem ?? ''));
67
+ log.info(msgs.ocorrencia(prefix, ocorrencia.tipo ?? '', ocorrencia.linha ?? 0, ocorrencia.mensagem));
68
68
  if (ocorrencia.sugestao) {
69
69
  log.info(msgs.sugestao(ocorrencia.sugestao));
70
70
  }
@@ -21,7 +21,7 @@ export function comandoLicencas() {
21
21
  root
22
22
  });
23
23
  console.log(JSON.stringify(result, null, 2));
24
- process.exitCode = result.problematic && result.problematic.length > 0 ? 2 : 0;
24
+ process.exitCode = result.problematic.length > 0 ? 2 : 0;
25
25
  }
26
26
  catch (err) {
27
27
  log.erro(msgs.falhaScan(err instanceof Error ? err.message : String(err)));
@@ -26,8 +26,8 @@ export function comandoMarketplace() {
26
26
  }
27
27
  log.info(msgs.tituloBusca);
28
28
  for (const r of resultados) {
29
- const desc = r.descricao || msgs.semDescricao;
30
- const tags = r.tags || [];
29
+ const desc = r.descricao;
30
+ const tags = r.tags;
31
31
  log.info(msgs.itemBusca(r.nome, desc, tags));
32
32
  }
33
33
  log.info(msgs.totalResultados(total));
@@ -148,7 +148,7 @@ export function comandoMarketplace() {
148
148
  }
149
149
  if (analista) {
150
150
  const versoes = analista.versoes.map((v) => v.version).join(', ');
151
- const tags = analista.tags || [];
151
+ const tags = analista.tags;
152
152
  log.info(msgs.infoTitulo(nome));
153
153
  log.info(msgs.infoDescricaoDetalhada(analista.descricao));
154
154
  log.info(msgs.infoCategoria(analista.categoria));
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
- import generateModule from '@babel/generator';
2
+ import generate from '@babel/generator';
3
3
  import { parse } from '@babel/parser';
4
- import traverseModule from '@babel/traverse';
4
+ import traverse from '@babel/traverse';
5
5
  import { Command } from 'commander';
6
6
  import * as fs from 'fs';
7
7
  import * as path from 'path';
@@ -9,12 +9,6 @@ import { chalk, config } from '../../core/config/index.js';
9
9
  import { getMessages } from '../../core/messages/index.js';
10
10
  import { ExitCode, getFilesWithExtension, getSourceFiles, sair } from '../helpers/index.js';
11
11
  const { log, CliComandoNamesMensagens } = getMessages();
12
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- CJS default interop
13
- // @ts-ignore
14
- const traverse = traverseModule.default ?? traverseModule;
15
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- CJS default interop
16
- // @ts-ignore
17
- const generate = generateModule.default ?? generateModule;
18
12
  function parseMappingLine(line) {
19
13
  const parts = line.split('=');
20
14
  if (parts.length < 2) {
@@ -174,6 +168,7 @@ function doApply(raizDir, srcDir, namesDir, mappingFile) {
174
168
  }
175
169
  }
176
170
  });
171
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
177
172
  if (changed) {
178
173
  const output = generate(ast, {
179
174
  retainLines: false,
@@ -63,9 +63,7 @@ async function carregarSnapshots(dir) {
63
63
  for (const arquivo of jsons) {
64
64
  try {
65
65
  const parsed = await lerEstado(path.join(dir, arquivo));
66
- if (parsed.tipo === 'baseline') {
67
- out.push(parsed);
68
- }
66
+ out.push(parsed);
69
67
  }
70
68
  catch {
71
69
  /* ignore */
@@ -108,8 +106,8 @@ function compararSnapshots(base, atual) {
108
106
  export function comandoPerf() {
109
107
  return new Command('perf').description(messages.CliComandoDesempMensagens.descricao).option('-d, --dir <dir>', 'Diretório de snapshots', config.PERF_SNAPSHOT_DIR).option('-j, --json', 'Saída JSON').option('-l, --limite <n>', 'Limite para regressão (%)', valor => Number(valor), 30).addCommand(new Command('baseline').description(messages.CliComandoDesempMensagens.descricaoBaseline).action(async (opts, cmd) => {
110
108
  try {
111
- const parent = cmd.parent?.opts?.() ?? {};
112
- const dir = parent.dir ? String(parent.dir) : config.PERF_SNAPSHOT_DIR;
109
+ const parent = cmd.parent?.opts() ?? {};
110
+ const dir = typeof parent.dir === 'string' ? parent.dir : config.PERF_SNAPSHOT_DIR;
113
111
  const globalMetrics = globalThis;
114
112
  const metricas = globalMetrics.__ULTIMAS_METRICAS_SUKUNA__;
115
113
  const snap = await gerarBaseline(dir, metricas ?? undefined);
@@ -128,8 +126,8 @@ export function comandoPerf() {
128
126
  sair(ExitCode.Failure);
129
127
  }
130
128
  })).addCommand(new Command('compare').description(messages.CliComandoDesempMensagens.descricaoCompare).action(async (opts, cmd) => {
131
- const parent = cmd.parent?.opts?.() ?? {};
132
- const dir = parent.dir ? String(parent.dir) : config.PERF_SNAPSHOT_DIR;
129
+ const parent = cmd.parent?.opts() ?? {};
130
+ const dir = typeof parent.dir === 'string' ? parent.dir : config.PERF_SNAPSHOT_DIR;
133
131
  const limite = parent.limite;
134
132
  let snaps;
135
133
  try {
@@ -155,7 +153,7 @@ export function comandoPerf() {
155
153
  const anterior = snaps[snaps.length - 2];
156
154
  const atual = snaps[snaps.length - 1];
157
155
  const diffs = compararSnapshots(anterior, atual);
158
- const regressao = diffs.filter(diretorio => diretorio.campo === 'tempoAnaliseMs' || diretorio.campo === 'tempoParsingMs').some(diretorio => diretorio.variacaoPct > limite);
156
+ const regressao = diffs.filter(diretorio => diretorio.campo === 'tempoAnaliseMs' || diretorio.campo === 'tempoParsingMs').some(diretorio => diretorio.variacaoPct > (limite ?? 0));
159
157
  if (parent.json) {
160
158
  console.log(JSON.stringify({
161
159
  base: anterior.hashConteudo,
@@ -171,7 +169,7 @@ export function comandoPerf() {
171
169
  log.info(` ${diretorio.campo}: ${diretorio.anterior ?? '-'} => ${diretorio.novo ?? '-'} (${formatPct(diretorio.variacaoPct)})`);
172
170
  });
173
171
  if (regressao) {
174
- logSistema.performanceRegressaoDetectada(limite);
172
+ logSistema.performanceRegressaoDetectada(limite ?? 0);
175
173
  }
176
174
  else {
177
175
  logSistema.performanceSemRegressoes();
@@ -10,7 +10,7 @@ const msgs = messages.CliComandoPluginsMensagens;
10
10
  */
11
11
  export function comandoPlugins() {
12
12
  const plugins = new Command('plugins').description(msgs.descricao);
13
- plugins.command('list').description(msgs.listDescricao).option('--json', msgs.jsonDescricao).action(opts => {
13
+ plugins.command('list').description(msgs.listDescricao).option('--json', msgs.jsonDescricao).action((opts) => {
14
14
  try {
15
15
  const lista = listarAnalistas();
16
16
  if (opts.json) {
@@ -28,7 +28,7 @@ export function comandoPlugins() {
28
28
  sair(ExitCode.Failure);
29
29
  }
30
30
  });
31
- plugins.command('install <pacote>').description(msgs.installDescricao).action(pacote => {
31
+ plugins.command('install <pacote>').description(msgs.installDescricao).action((pacote) => {
32
32
  log.info(msgs.buscandoPacote(pacote));
33
33
  log.info(msgs.instalando);
34
34
  // Mock de instalação para v0.5.0
@@ -37,11 +37,11 @@ export function comandoPlugins() {
37
37
  log.info(msgs.dicaAnalistas);
38
38
  }, 500);
39
39
  });
40
- plugins.command('remove <pacote>').description(msgs.removeDescricao).action(pacote => {
40
+ plugins.command('remove <pacote>').description(msgs.removeDescricao).action((pacote) => {
41
41
  log.info(msgs.removendo(pacote));
42
42
  log.sucesso(msgs.pluginRemovido(pacote));
43
43
  });
44
- plugins.command('init <nome>').description(msgs.initDescricao).action(nome => {
44
+ plugins.command('init <nome>').description(msgs.initDescricao).action((nome) => {
45
45
  log.info(msgs.gerandoTemplate(nome));
46
46
  log.sucesso(msgs.arquivoCriado(nome));
47
47
  log.info(msgs.dicaImplementar);
@@ -41,10 +41,10 @@ export async function executarAutoFixInterno(opts, ocorrenciasFiltradas, fileEnt
41
41
  }
42
42
  correcoesPorArquivo.get(arquivo)?.push(fix);
43
43
  }
44
- const maxFixesPerArquivo = autoCorrecaoConfiguracao.maxFixesPerArquivo ?? Infinity;
44
+ const maxFixesPerArquivo = autoCorrecaoConfiguracao.maxFixesPerArquivo;
45
45
  for (const [arquivo] of correcoesPorArquivo) {
46
46
  try {
47
- const fileEntrada = fileEntriesComAst.find(fe => fe.relPath === arquivo || fe.fullCaminho === arquivo);
47
+ const fileEntrada = fileEntriesComAst?.find(fe => fe.relPath === arquivo || fe.fullCaminho === arquivo);
48
48
  if (!fileEntrada || typeof fileEntrada.content !== 'string') {
49
49
  logSistema.autoFixArquivoNaoEncontrado(arquivo);
50
50
  continue;
@@ -140,7 +140,7 @@ function escapeNonAscii(str) {
140
140
  export function traduzirRelatorioJson(json) {
141
141
  try {
142
142
  const { CAMPO_ROTULOS } = getMessages();
143
- if (!CAMPO_ROTULOS || Object.keys(CAMPO_ROTULOS).length === 0) {
143
+ if (Object.keys(CAMPO_ROTULOS).length === 0) {
144
144
  return json;
145
145
  }
146
146
  const obj = JSON.parse(json);
@@ -134,9 +134,6 @@ export function validarOptionsSharding(options) {
134
134
  if (!options.formato) {
135
135
  erros.push('Formato é obrigatório');
136
136
  }
137
- else if (options.formato !== 'json' && options.formato !== 'markdown') {
138
- erros.push('Formato deve ser "json" ou "markdown"');
139
- }
140
137
  if (!options.ocorrenciasPorShard || options.ocorrenciasPorShard <= 0) {
141
138
  erros.push('ocorrenciasPorShard deve ser maior que 0');
142
139
  }
@@ -22,7 +22,7 @@ export async function exportarRelatorioSvgOtimizacao(params) {
22
22
  const { entries, relatoriosDir, ts } = params;
23
23
  const candidatos = [];
24
24
  for (const erro of entries) {
25
- if (!erro || typeof erro.relPath !== 'string') {
25
+ if (typeof erro.relPath !== 'string') {
26
26
  continue;
27
27
  }
28
28
  if (!/\.svg$/i.test(erro.relPath)) {
@@ -50,7 +50,7 @@ export async function executarDeteccaoArquetipos(entries, baseDir, options) {
50
50
  };
51
51
  }
52
52
  // Processar resultado
53
- const arquetipos = resultado.candidatos || [];
53
+ const arquetipos = resultado.candidatos;
54
54
  const principal = arquetipos.length > 0 ? arquetipos[0] : undefined; // Log de resultado (se não silencioso)
55
55
  if (!options.silent && principal) {
56
56
  log.info(messages.MENSAGENS_ARQUETIPOS.identificado(principal.nome, principal.confidence));
@@ -59,16 +59,13 @@ export async function executarDeteccaoArquetipos(entries, baseDir, options) {
59
59
  }
60
60
  }
61
61
  // Salvar se solicitado
62
- let salvo = false;
63
- if (options.salvar && resultado) {
64
- salvo = await salvarArquetipo(resultado, baseDir, options.silent);
65
- }
62
+ const salvo = await salvarArquetipo(resultado, baseDir, options.silent);
66
63
  return {
67
64
  executado: true,
68
65
  arquetipos: arquetipos.map(arquivo => ({
69
66
  tipo: arquivo.nome,
70
67
  confianca: arquivo.confidence,
71
- caracteristicas: arquivo.matchedRequired || []
68
+ caracteristicas: arquivo.matchedRequired
72
69
  })),
73
70
  principal: principal ? {
74
71
  tipo: principal.nome,
@@ -83,14 +83,14 @@ async function executarComTimeout(entries, options, timeoutMs) {
83
83
  resolve(resultado);
84
84
  }).catch((erro) => {
85
85
  clearTimeout(timer);
86
- reject(erro);
86
+ reject(erro instanceof Error ? erro : new Error(String(erro)));
87
87
  });
88
88
  });
89
89
  }
90
90
  /**
91
91
  * Lógica interna de auto-fix
92
92
  */
93
- async function executarAutoFixInterno(entries, options) {
93
+ function executarAutoFixInterno(entries, options) {
94
94
  // NOTA: Integração real com sistema de auto-fix pendente de implementação
95
95
  // Por enquanto, retornar resultado mock
96
96
  const stats = {
@@ -100,12 +100,12 @@ async function executarAutoFixInterno(entries, options) {
100
100
  correcoesSugeridas: 0,
101
101
  correcoesPuladas: 0
102
102
  };
103
- return {
103
+ return Promise.resolve({
104
104
  executado: true,
105
105
  mode: options.mode,
106
106
  dryRun: options.dryRun,
107
107
  stats
108
- };
108
+ });
109
109
  }
110
110
  // ─── Formatação para JSON ─────────────────────────────────────
111
111
  /**
@@ -40,7 +40,7 @@ export async function executarGuardian(entries, options) {
40
40
  const resultado = await scanSystemIntegrity(entries, {
41
41
  suppressLogs: options.silent,
42
42
  }); // Processar resultado
43
- const status = resultado.status || IntegridadeStatus.Ok;
43
+ const status = resultado.status;
44
44
  const drift = resultado.detalhes?.length ?? 0;
45
45
  const temProblemas = status === IntegridadeStatus.AlteracoesDetectadas;
46
46
  // Log de resultado (se não silencioso)
@@ -98,7 +98,7 @@ function buildJsonSaida(ocorrencias, guardianResultado, fileEntries, opts, arque
98
98
  };
99
99
  if (arquetiposResultado) {
100
100
  saida.estruturaIdentificada = {
101
- melhores: arquetiposResultado.candidatos || [],
101
+ melhores: arquetiposResultado.candidatos,
102
102
  baseline: arquetiposResultado.baseline ?? null,
103
103
  drift: arquetiposResultado.drift ?? {
104
104
  alterouArquetipo: false,
@@ -116,7 +116,7 @@ async function emitJsonSaida(ocorrencias, guardianResultado, fileEntries, opts,
116
116
  try {
117
117
  const pkgRaw = await fs.promises.readFile(path.join(process.cwd(), 'package.json'), 'utf-8');
118
118
  const pkgObj = JSON.parse(pkgRaw);
119
- if (pkgObj && typeof pkgObj.version === 'string') {
119
+ if (typeof pkgObj.version === 'string') {
120
120
  pkgVersion = pkgObj.version;
121
121
  }
122
122
  }
@@ -192,7 +192,7 @@ function emitTypeSummary(ocorrencias, nivelOcorrencias, opts) {
192
192
  for (const oc of ocorrencias) {
193
193
  const key = (oc.relPath || (oc.arquivo ?? 'desconhecido'));
194
194
  const nv = oc.nivel ?? 'info';
195
- if (nv === 'erro' || nv === 'alto') {
195
+ if (nv === 'erro') {
196
196
  arquivoContagem.set(key, (arquivoContagem.get(key) ?? 0) + 1);
197
197
  }
198
198
  }
@@ -311,7 +311,7 @@ function emitArchetypeDisplay(arquetiposResultado, opts) {
311
311
  const candidatosCount = arquetiposResultado.candidatos.length || 0;
312
312
  log.info(`DEBUG: arquetiposResultado=${!!arquetiposResultado}, candidatos=${candidatosCount}`);
313
313
  }
314
- if (!opts.json && arquetiposResultado && (arquetiposResultado.baseline || arquetiposResultado.drift)) {
314
+ if (!opts.json && (arquetiposResultado.baseline || arquetiposResultado.drift)) {
315
315
  const linhas = [];
316
316
  if (arquetiposResultado.baseline) {
317
317
  const b = arquetiposResultado.baseline;
@@ -389,7 +389,7 @@ async function emitReportsAndExport(resultadoExecucao, fileEntriesComAst, baseDi
389
389
  const analistasAgregados = {};
390
390
  for (const a of metricasOriginais?.analistas ?? []) {
391
391
  const nome = a.nome || 'desconhecido';
392
- if (!analistasAgregados[nome]) {
392
+ if (!(nome in analistasAgregados)) {
393
393
  analistasAgregados[nome] = { duracaoMs: 0, ocorrencias: 0, execucoes: 0 };
394
394
  }
395
395
  analistasAgregados[nome].duracaoMs += a.duracaoMs || 0;
@@ -615,7 +615,7 @@ function emitVerboseResultSummary(ocorrenciasFiltradas, tiposOcorrencias, nivelO
615
615
  }
616
616
  }
617
617
  const SAMPLE_MAX = 50;
618
- const sample = ocorrenciasFiltradas.slice(0, SAMPLE_MAX).map(oc => `${oc.relPath}:${oc.linha ?? ''} [${oc.nivel ?? ''}] ${(oc.mensagem ?? '').replace(/\n/g, ' ')}`);
618
+ const sample = ocorrenciasFiltradas.slice(0, SAMPLE_MAX).map(oc => `${oc.relPath}:${oc.linha ?? ''} [${oc.nivel}] ${oc.mensagem.replace(/\n/g, ' ')}`);
619
619
  if (sample.length) {
620
620
  const logExt = log;
621
621
  if (typeof logExt.imprimirBloco === 'function') {
@@ -663,7 +663,7 @@ export async function processarDiagnostico(opts) {
663
663
  const subOpts = { ...opts, paths: undefined };
664
664
  const subResult = await processarDiagnosticoInterno(subOpts);
665
665
  if (subResult) {
666
- const ocorr = subResult.resultadoFinal.ocorrencias ?? [];
666
+ const ocorr = subResult.resultadoFinal.ocorrencias;
667
667
  const tagged = ocorr.map(o => ({
668
668
  ...o,
669
669
  projeto: projetoNome,
@@ -798,10 +798,10 @@ async function processarDiagnosticoInterno(opts) {
798
798
  }
799
799
  let nomeProjeto = path.basename(baseDir);
800
800
  try {
801
- const pkg = fileEntries.find(fe => /(^|[\\/])package\.json$/.test(fe.relPath || fe.fullCaminho));
801
+ const pkg = fileEntries?.find(fe => /(^|[\\/])package\.json$/.test(fe.relPath || fe.fullCaminho));
802
802
  if (pkg && typeof pkg.content === 'string' && pkg.content.trim()) {
803
803
  const parsed = JSON.parse(pkg.content);
804
- if (parsed && typeof parsed.name === 'string' && parsed.name.trim()) {
804
+ if (typeof parsed.name === 'string' && parsed.name.trim()) {
805
805
  nomeProjeto = parsed.name.trim();
806
806
  }
807
807
  }
@@ -810,7 +810,7 @@ async function processarDiagnosticoInterno(opts) {
810
810
  try {
811
811
  const raw = await fs.promises.readFile(pkgCaminho, 'utf-8');
812
812
  const parsed = JSON.parse(raw);
813
- if (parsed && typeof parsed.name === 'string' && parsed.name.trim()) {
813
+ if (typeof parsed.name === 'string' && parsed.name.trim()) {
814
814
  nomeProjeto = parsed.name.trim();
815
815
  }
816
816
  }
@@ -982,7 +982,7 @@ async function processarDiagnosticoInterno(opts) {
982
982
  fast: opts.fast,
983
983
  });
984
984
  registrarUltimasMetricas(resultadoExecucao.metricas);
985
- let ocorrenciasFiltradas = dedupeOcorrencias(resultadoExecucao.ocorrencias || []);
985
+ let ocorrenciasFiltradas = dedupeOcorrencias(resultadoExecucao.ocorrencias);
986
986
  const trustCompiler = Boolean(optsDyn.trustCompiler ?? configDyn.SPECIAL_TRUST_COMPILER);
987
987
  if (trustCompiler) {
988
988
  try {
@@ -1064,7 +1064,7 @@ async function processarDiagnosticoInterno(opts) {
1064
1064
  }
1065
1065
  if (config.VERBOSE || config.DEV_MODE) {
1066
1066
  if (config.DEV_MODE && !opts.json && resultadoExecucao.metricas) {
1067
- const analistasComOcorrencias = resultadoExecucao.metricas.analistas?.filter(a => (a.ocorrencias ?? 0) > 0);
1067
+ const analistasComOcorrencias = resultadoExecucao.metricas.analistas?.filter(a => a.ocorrencias > 0);
1068
1068
  if (analistasComOcorrencias?.length) {
1069
1069
  logSistema.processamentoAnalistasProblemas(analistasComOcorrencias.length);
1070
1070
  analistasComOcorrencias.forEach(a => {
@@ -1074,7 +1074,7 @@ async function processarDiagnosticoInterno(opts) {
1074
1074
  }
1075
1075
  }
1076
1076
  try {
1077
- if (!opts.json && !config.SCAN_ONLY && totalOcorrencias === 0) {
1077
+ if (totalOcorrencias === 0) {
1078
1078
  logRelatorio.repositorioImpecavel();
1079
1079
  }
1080
1080
  }
@@ -1086,11 +1086,11 @@ async function processarDiagnosticoInterno(opts) {
1086
1086
  }
1087
1087
  emitArchetypeDisplay(arquetiposResultado, opts);
1088
1088
  if (opts.json) {
1089
- await emitJsonSaida(resultadoExecucao.ocorrencias || [], guardianResultado, fileEntriesComAst || fileEntries, opts, arquetiposResultado);
1089
+ await emitJsonSaida(resultadoExecucao.ocorrencias, guardianResultado, fileEntriesComAst, opts, arquetiposResultado);
1090
1090
  _jsonEmitted = true;
1091
1091
  if (!process.env.VITEST) {
1092
1092
  const erros = (nivelOcorrencias.get('erro') ?? 0);
1093
- const { parseErros } = buildJsonSaida(resultadoExecucao.ocorrencias || [], guardianResultado, fileEntriesComAst || fileEntries, opts, arquetiposResultado);
1093
+ const { parseErros } = buildJsonSaida(resultadoExecucao.ocorrencias, guardianResultado, fileEntriesComAst, opts, arquetiposResultado);
1094
1094
  const exitCode = parseErros.totalOriginais > 0 && config.PARSE_ERRO_FALHA
1095
1095
  ? 2
1096
1096
  : erros > 0
@@ -1099,27 +1099,23 @@ async function processarDiagnosticoInterno(opts) {
1099
1099
  process.exit(exitCode);
1100
1100
  }
1101
1101
  }
1102
- if (!opts.json && !config.SCAN_ONLY) {
1103
- if (totalOcorrencias > 0 && ocorrenciasFiltradas) {
1104
- emitTypeSummary(ocorrenciasFiltradas, nivelOcorrencias, opts);
1105
- }
1106
- if (!config.COMPACT_MODE && !process.env.__SUKUNA_TUDO_PRONTO_EMITIDO) {
1107
- log.info(messages.CliProcessamentoDiagnosticoMensagens.tudoPronto);
1108
- process.env['__SUKUNA_TUDO_PRONTO_EMITIDO'] = '1';
1109
- }
1110
- if (process.env.VITEST) {
1111
- log.info(messages.CliProcessamentoDiagnosticoMensagens.diagnosticoConcluido);
1112
- }
1102
+ if (totalOcorrencias > 0) {
1103
+ emitTypeSummary(ocorrenciasFiltradas, nivelOcorrencias, opts);
1104
+ }
1105
+ if (!config.COMPACT_MODE && !process.env.__SUKUNA_TUDO_PRONTO_EMITIDO) {
1106
+ log.info(messages.CliProcessamentoDiagnosticoMensagens.tudoPronto);
1107
+ process.env['__SUKUNA_TUDO_PRONTO_EMITIDO'] = '1';
1108
+ }
1109
+ if (process.env.VITEST) {
1110
+ log.info(messages.CliProcessamentoDiagnosticoMensagens.diagnosticoConcluido);
1113
1111
  }
1114
1112
  await emitReportsAndExport(resultadoExecucao, fileEntriesComAst, baseDir, guardianResultado, totalOcorrencias, opts);
1115
- if (!opts.json && !config.SCAN_ONLY) {
1116
- if (totalOcorrencias > 0 && resultadoExecucao && ocorrenciasFiltradas) {
1117
- emitTypeSummary(ocorrenciasFiltradas, nivelOcorrencias, opts);
1118
- }
1119
- if (!config.COMPACT_MODE && !process.env.__SUKUNA_TUDO_PRONTO_EMITIDO) {
1120
- log.info(messages.CliProcessamentoDiagnosticoMensagens.tudoPronto);
1121
- process.env['__SUKUNA_TUDO_PRONTO_EMITIDO'] = '1';
1122
- }
1113
+ if (totalOcorrencias > 0) {
1114
+ emitTypeSummary(ocorrenciasFiltradas, nivelOcorrencias, opts);
1115
+ }
1116
+ if (!config.COMPACT_MODE && !process.env.__SUKUNA_TUDO_PRONTO_EMITIDO) {
1117
+ log.info(messages.CliProcessamentoDiagnosticoMensagens.tudoPronto);
1118
+ process.env['__SUKUNA_TUDO_PRONTO_EMITIDO'] = '1';
1123
1119
  }
1124
1120
  }
1125
1121
  catch (error) {
@@ -1152,7 +1148,7 @@ async function processarDiagnosticoInterno(opts) {
1152
1148
  };
1153
1149
  }
1154
1150
  try {
1155
- if (!opts.json && !config.SCAN_ONLY && totalOcorrencias === 0) {
1151
+ if (totalOcorrencias === 0) {
1156
1152
  logRelatorio.repositorioImpecavel();
1157
1153
  }
1158
1154
  }
@@ -76,7 +76,7 @@ export async function exportarPorNivel(ocorrenciasLimpas, dir, id, salvar) {
76
76
  export function computeLinguagens(fes) {
77
77
  const extensoes = {};
78
78
  let sem_ext = 0;
79
- for (const arquivo of fes || []) {
79
+ for (const arquivo of fes) {
80
80
  const rel = arquivo.relPath || arquivo.fullCaminho || '';
81
81
  const base = rel.split(/[\\/]/).pop() ?? '';
82
82
  const idx = base.lastIndexOf('.');
@@ -88,7 +88,7 @@ export function computeLinguagens(fes) {
88
88
  extensoes[ext] = (extensoes[ext] || 0) + 1;
89
89
  }
90
90
  }
91
- return { total: (fes || []).length, extensoes: { ...extensoes, sem_ext } };
91
+ return { total: fes.length, extensoes: { ...extensoes, sem_ext } };
92
92
  }
93
93
  export function limparOcorrencia(oc) {
94
94
  return {
@@ -192,15 +192,12 @@ function agruparPorArquivo(casos) {
192
192
  */
193
193
  function agruparPorCategoria(casos) {
194
194
  return casos.reduce((acc, caso) => {
195
- if (!acc[caso.categoria]) {
196
- acc[caso.categoria] = [];
197
- }
198
195
  acc[caso.categoria].push({
199
196
  arquivo: caso.arquivo,
200
197
  linha: caso.linha
201
198
  });
202
199
  return acc;
203
- }, {});
200
+ }, { legitimo: [], melhoravel: [], corrigir: [] });
204
201
  }
205
202
  /**
206
203
  * Exporta relatórios de fix-types (Markdown e JSON)
@@ -80,8 +80,8 @@ export function exibirMolduraConflitos(conflitos, limite = 10) {
80
80
  const linhas = [messages.CliExibirMolduraMensagens.conflitosCabecalhoLinha1, messages.CliExibirMolduraMensagens.conflitosCabecalhoLinha2];
81
81
  const primeiros = conflitos.slice(0, limite);
82
82
  for (const elem of primeiros) {
83
- const alvo = normalizePath(String((elem && typeof elem === 'object' && 'alvo' in elem && elem.alvo) ?? JSON.stringify(elem))).slice(0, 31).padEnd(31, ' ');
84
- const motivo = String((elem && typeof elem === 'object' && 'motivo' in elem && elem.motivo) ?? '-').slice(0, 30);
83
+ const alvo = normalizePath(elem.alvo ?? JSON.stringify(elem)).slice(0, 31).padEnd(31, ' ');
84
+ const motivo = (elem.motivo ?? '-').slice(0, 30);
85
85
  linhas.push(`${alvo} ${motivo}`);
86
86
  }
87
87
  if (conflitos.length > limite) {
@@ -89,9 +89,9 @@ export function exibirMolduraConflitos(conflitos, limite = 10) {
89
89
  }
90
90
  exibirMolduraSegura(messages.CliExibirMolduraMensagens.conflitosTitulo, linhas, () => {
91
91
  primeiros.forEach(elem => {
92
- const alvoStr = (elem && typeof elem === 'object' && 'alvo' in elem && elem.alvo) ?? 'alvo desconhecido';
93
- const motivoStr = (elem && typeof elem === 'object' && 'motivo' in elem && elem.motivo) ?? '-';
94
- log.aviso(messages.CliExibirMolduraMensagens.conflitosFallbackLinha(String(alvoStr), String(motivoStr)));
92
+ const alvoStr = elem.alvo ?? 'alvo desconhecido';
93
+ const motivoStr = elem.motivo ?? '-';
94
+ log.aviso(messages.CliExibirMolduraMensagens.conflitosFallbackLinha(alvoStr, motivoStr));
95
95
  });
96
96
  if (conflitos.length > limite) {
97
97
  log.aviso(messages.CliExibirMolduraMensagens.conflitosFallbackOverflow(conflitos.length - limite));
@@ -35,9 +35,6 @@ export const AGRESSIVA_AUTO_CORRECAO_CONFIGURACAO = {
35
35
  // Backwards compat constant name used elsewhere in the codebase
36
36
  export const AUTO_CORRECAO_CONFIGURACAO_PADROES = PADRAO_AUTO_CORRECAO_CONFIGURACAO;
37
37
  export function shouldExcludeFile(fileCaminho, config) {
38
- if (!config.excludePadroes) {
39
- return false;
40
- }
41
38
  return config.excludePadroes.some(pattern => {
42
39
  const regexPadrao = pattern.replace(/\*\*/g, '.*').replace(/\*/g, '[^/]*').replace(/\?/g, '.');
43
40
  return new RegExp(regexPadrao).test(fileCaminho);
@@ -50,9 +47,6 @@ export function shouldExcludeFunction(functionName, config) {
50
47
  return config.excludeFunctionPatterns.some(pattern => new RegExp(pattern, 'i').test(functionName));
51
48
  }
52
49
  export function isCategoryAllowed(category, config) {
53
- if (!config.allowedCategories) {
54
- return true;
55
- }
56
50
  // allowedCategories is an array of known category strings - coerce to string[] for safe includes check
57
51
  return (config.allowedCategories).includes(category);
58
52
  }
@@ -4,7 +4,7 @@
4
4
  // - Fornecer API estável com funções obrigatórias (não opcionais) para evitar 'possibly undefined'.
5
5
  // - Suportar encadeamento básico usado no projeto (ex.: chalk.cyan.bold(...)).
6
6
  // - Em ambientes sem chalk, aplicar fallback de identidade (retorna a string sem cor/estilo).
7
- import chalkDefault, * as chalkNs from 'chalk';
7
+ import chalkDefault from 'chalk';
8
8
  const ID = (string) => string;
9
9
  function getSourceFns(x) {
10
10
  if (!x) {
@@ -72,7 +72,7 @@ function makeChalkLike(src) {
72
72
  };
73
73
  }
74
74
  // Preferimos a instância default; se não existir, usamos o namespace (CJS)
75
- const resolvedUnknown = chalkDefault ?? chalkNs.default ?? chalkNs;
75
+ const resolvedUnknown = chalkDefault;
76
76
  /**
77
77
  * Instância segura de chalk com API estável e suporte a encadeamento.
78
78
  * Em ambientes sem chalk nativo, fornece fallback de identidade (sem cores).
@@ -193,7 +193,7 @@ function ehObjetoPlano(valor) {
193
193
  return !!valor && typeof valor === 'object' && !Array.isArray(valor);
194
194
  }
195
195
  function mesclarProfundo(target, src, fonte, diffs, prefix = '') {
196
- for (const chave of Object.keys(src || {})) {
196
+ for (const chave of Object.keys(src)) {
197
197
  if (chave === '__proto__' || chave === 'constructor' || chave === 'prototype') {
198
198
  continue;
199
199
  }
@@ -254,12 +254,10 @@ function converterConfigSimplificada(config) {
254
254
  };
255
255
  for (const [lang, enabled] of Object.entries(langs)) {
256
256
  const defaults = langPadroes[lang];
257
- if (defaults) {
258
- resultado.languageSupport[lang] = {
259
- enabled,
260
- ...defaults
261
- };
262
- }
257
+ resultado.languageSupport[lang] = {
258
+ enabled,
259
+ ...defaults
260
+ };
263
261
  }
264
262
  const enabledPlugins = ['core'];
265
263
  resultado.plugins = {
@@ -288,7 +286,7 @@ function converterConfigSimplificada(config) {
288
286
  return resultado;
289
287
  }
290
288
  function sincronizarIgnorados() {
291
- const dyn = (config.INCLUDE_EXCLUDE_RULES || {});
289
+ const dyn = config.INCLUDE_EXCLUDE_RULES;
292
290
  const glob = Array.isArray(dyn.globalExcludeGlob) ? dyn.globalExcludeGlob : [];
293
291
  Array.from(new Set(glob.map(grupo => grupo)));
294
292
  const cfg = config;
@@ -112,5 +112,5 @@ export function getAllExpectedDirNames() {
112
112
  }));
113
113
  }
114
114
  export function getDirVariantPattern(key) {
115
- return DIR_VARIANT_PATTERNS[key] ?? /^$/;
115
+ return DIR_VARIANT_PATTERNS[key];
116
116
  }