@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.
- package/README.md +0 -34
- package/dist/analysts/architects/analyst-structure.js +20 -20
- package/dist/analysts/architects/archetypes-custom.js +16 -19
- package/dist/analysts/architects/detector-archetypes.js +43 -36
- package/dist/analysts/architects/orchestrator-archetypes.js +3 -3
- package/dist/analysts/architects/signals-project-advanced.js +26 -28
- package/dist/analysts/architects/signals-project.js +2 -2
- package/dist/analysts/architects/strategist-structure.js +47 -66
- package/dist/analysts/azure-pipelines/analysts/analyst-azure.js +41 -35
- package/dist/analysts/azure-pipelines/corrections/correction-azure.js +22 -19
- package/dist/analysts/azure-pipelines/detectors/detector-azure-performance.js +21 -18
- package/dist/analysts/azure-pipelines/detectors/detector-azure-security.js +25 -20
- package/dist/analysts/azure-pipelines/detectors/detector-azure-structure.js +39 -40
- package/dist/analysts/azure-pipelines/scorers/scorer-azure.js +10 -7
- package/dist/analysts/circleci/analysts/analyst-circleci.js +33 -27
- package/dist/analysts/circleci/corrections/correction-circleci.js +22 -20
- package/dist/analysts/circleci/detectors/detector-circleci-performance.js +23 -19
- package/dist/analysts/circleci/detectors/detector-circleci-security.js +78 -82
- package/dist/analysts/circleci/detectors/detector-circleci-structure.js +22 -22
- package/dist/analysts/converters/convert-registry.js +1 -1
- package/dist/analysts/converters/engines/converter-gha-to-gitlab.js +17 -15
- package/dist/analysts/converters/index.js +1 -1
- package/dist/analysts/corrections/analyst-quick-fixes.js +25 -28
- package/dist/analysts/corrections/analyst-scoring.js +24 -21
- package/dist/analysts/corrections/auto-fix-engine.js +1 -1
- package/dist/analysts/corrections/corrector-structure.js +43 -42
- package/dist/analysts/corrections/fix-alias-imports.js +10 -6
- package/dist/analysts/corrections/fix-md-fences.js +23 -23
- package/dist/analysts/corrections/map-reversion.js +56 -53
- package/dist/analysts/corrections/pruning.js +19 -16
- package/dist/analysts/corrections/quick-fixes/fix-any-to-proper-type.js +57 -61
- package/dist/analysts/corrections/quick-fixes/fix-unknown-to-specific-type.js +30 -30
- package/dist/analysts/corrections/reorganize-barrels.js +13 -13
- package/dist/analysts/corrections/rewrite-testes-aliases.js +23 -22
- package/dist/analysts/corrections/scoring-shared.js +19 -18
- package/dist/analysts/corrections/type-safety/context-analyzer.js +15 -10
- package/dist/analysts/corrections/type-safety/type-analyzer.js +3 -3
- package/dist/analysts/corrections/type-safety/type-validator.js +4 -3
- package/dist/analysts/corrections/type-safety/usage-analyzer.js +39 -42
- package/dist/analysts/css/analysts/analyst-css.js +42 -42
- package/dist/analysts/css/corrections/correction-css.js +19 -11
- package/dist/analysts/css/detectors/detector-css-best-practices.js +129 -118
- package/dist/analysts/css/scorers/scorer-css.js +23 -18
- package/dist/analysts/css-in-js/analysts/analyst-css-in-js.js +24 -17
- package/dist/analysts/css-in-js/corrections/correction-css-in-js.js +31 -16
- package/dist/analysts/css-in-js/detectors/detector-css-in-js-best-practices.js +28 -30
- package/dist/analysts/css-in-js/scorers/scorer-css-in-js.js +79 -54
- package/dist/analysts/css-in-js/shared.js +7 -0
- package/dist/analysts/detectors/detector-architecture.js +91 -85
- package/dist/analysts/detectors/detector-bugs-ml.js +29 -27
- package/dist/analysts/detectors/detector-code-fragile.js +41 -36
- package/dist/analysts/detectors/detector-dependencies.js +5 -5
- package/dist/analysts/detectors/detector-duplications.js +26 -26
- package/dist/analysts/detectors/detector-monorepo.js +51 -45
- package/dist/analysts/detectors/detector-performance.js +24 -17
- package/dist/analysts/detectors/detector-recommendation-architecture.js +40 -36
- package/dist/analysts/detectors/detector-security.js +43 -42
- package/dist/analysts/detectors/detector-structure.js +31 -28
- package/dist/analysts/github-actions/analysts/analyst-github-actions.js +5 -8
- package/dist/analysts/github-actions/detectors/detector-workflow-accessibility.js +1 -9
- package/dist/analysts/github-actions/detectors/detector-workflow-structure.js +1 -4
- package/dist/analysts/github-actions/detectors/detector-workflow-trigger-unsafe.js +6 -5
- package/dist/analysts/gitlab-ci/analysts/analyst-gitlab-ci.js +2 -2
- package/dist/analysts/gitlab-ci/detectors/detector-gitlab-ci-structure.js +0 -3
- package/dist/analysts/go/analysts/analyst-best-practices.js +2 -2
- package/dist/analysts/go/analysts/analyst-concurrency.js +1 -1
- package/dist/analysts/go/analysts/analyst-security.js +1 -1
- package/dist/analysts/go/detectors/detector-conventions.js +1 -1
- package/dist/analysts/html/analysts/analyst-html.js +10 -12
- package/dist/analysts/html/detectors/detector-html.js +3 -3
- package/dist/analysts/js-ts/analysts/analyst-commands-cli.js +22 -22
- package/dist/analysts/js-ts/analysts/analyst-functions-long.js +5 -5
- package/dist/analysts/js-ts/analysts/analyst-patterns-usage.js +6 -2
- package/dist/analysts/js-ts/detectors/detector-anti-patterns-async.js +84 -9
- package/dist/analysts/js-ts/detectors/detector-constructions-syntactic.js +33 -10
- package/dist/analysts/js-ts/detectors/detector-context-smart.js +6 -6
- package/dist/analysts/js-ts/detectors/detector-leaks-memory.js +1 -1
- package/dist/analysts/js-ts/detectors/detector-types-unsafe.js +33 -2
- package/dist/analysts/php/analysts/analyst-php.js +3 -3
- package/dist/analysts/php/detectors/detector-php-best-practices.js +5 -5
- package/dist/analysts/php/detectors/detector-php-security.js +5 -5
- package/dist/analysts/php/scorers/scorer-php.js +2 -2
- package/dist/analysts/plugins/detector-documentation.js +6 -6
- package/dist/analysts/plugins/detector-markdown.js +7 -7
- package/dist/analysts/python/analysts/analyst-python.js +2 -5
- package/dist/analysts/react/analysts/analyst-react-hooks.js +66 -9
- package/dist/analysts/react/analysts/analyst-react.js +46 -2
- package/dist/analysts/react/corrections/correction-react.js +41 -1
- package/dist/analysts/react/detectors/detector-react-best-practices.js +5 -5
- package/dist/analysts/react/scorers/scorer-react.js +36 -1
- package/dist/analysts/registry/autodiscovery.js +2 -2
- package/dist/analysts/rust/analysts/analyst-best-practices.js +42 -3
- package/dist/analysts/rust/analysts/analyst-memory.js +2 -2
- package/dist/analysts/rust/analysts/analyst-rust.js +52 -5
- package/dist/analysts/rust/analysts/analyst-security.js +29 -1
- package/dist/analysts/scorers/scorer.js +5 -5
- package/dist/analysts/shell/analysts/analyst-shell.js +81 -5
- package/dist/analysts/shell/corrections/correction-shell.js +34 -1
- package/dist/analysts/shell/detectors/detector-shell-security.js +88 -0
- package/dist/analysts/shell/scorers/scorer-shell.js +58 -1
- package/dist/analysts/strategists/operator-structure.js +5 -7
- package/dist/analysts/strategists/suggestions-contextuais.js +5 -2
- package/dist/analysts/svg/analysts/analyst-svg.js +1 -0
- package/dist/analysts/tailwind/analysts/analyst-tailwind.js +79 -55
- package/dist/analysts/tailwind/corrections/correction-tailwind.js +108 -9
- package/dist/analysts/tailwind/detectors/detector-tailwind-best-practices.js +122 -7
- package/dist/analysts/tailwind/scorers/scorer-tailwind.js +62 -11
- package/dist/analysts/xml/analysts/analyst-xml.js +2 -2
- package/dist/app/index.js +1 -0
- package/dist/bin/cli-bootstrap.js +6 -4
- package/dist/bin/index.js +6 -4
- package/dist/caretakers/scoring.js +1 -0
- package/dist/cli/commands/command-analysts.js +4 -3
- package/dist/cli/commands/command-azure.js +1 -1
- package/dist/cli/commands/command-circleci.js +1 -1
- package/dist/cli/commands/command-compliance.js +1 -1
- package/dist/cli/commands/command-diagnose.js +10 -13
- package/dist/cli/commands/command-fix-types.js +9 -32
- package/dist/cli/commands/command-formatters.js +2 -2
- package/dist/cli/commands/command-github-actions.js +1 -1
- package/dist/cli/commands/command-gitlab-ci.js +1 -1
- package/dist/cli/commands/command-guardian.js +1 -1
- package/dist/cli/commands/command-imports.js +6 -6
- package/dist/cli/commands/command-jenkins.js +1 -1
- package/dist/cli/commands/command-licenses.js +1 -1
- package/dist/cli/commands/command-marketplace.js +7 -7
- package/dist/cli/commands/command-names.js +3 -8
- package/dist/cli/commands/command-perf.js +7 -9
- package/dist/cli/commands/command-plugins.js +4 -4
- package/dist/cli/diagnostic/auto-fix.js +2 -2
- package/dist/cli/diagnostic/exporters/json-exporter.js +1 -1
- package/dist/cli/diagnostic/exporters/sharded-exporter.js +0 -3
- package/dist/cli/diagnostic/exporters/svg-optimization-exporter.js +1 -1
- package/dist/cli/diagnostic/filters.js +9 -9
- package/dist/cli/diagnostic/handlers/archetype-handler.js +3 -6
- package/dist/cli/diagnostic/handlers/auto-fix-handler.js +4 -4
- package/dist/cli/diagnostic/handlers/guardian-handler.js +1 -1
- package/dist/cli/diagnostic/processing-diagnostic.js +31 -35
- package/dist/cli/diagnostic/processing-helpers.js +2 -2
- package/dist/cli/handlers/fix-types-exporter.js +1 -4
- package/dist/cli/helpers/display-frame.js +5 -5
- package/dist/core/config/auto/auto-fix-config.js +0 -6
- package/dist/core/config/chalk-safe.js +6 -6
- package/dist/core/config/config.js +11 -13
- package/dist/core/config/conventions.js +1 -1
- package/dist/core/config/security.js +2 -2
- package/dist/core/execution/analysis-cache.js +5 -8
- package/dist/core/execution/ast-cache.js +1 -3
- package/dist/core/execution/executor.js +8 -21
- package/dist/core/execution/inquisitor.js +24 -21
- package/dist/core/execution/results.js +1 -0
- package/dist/core/execution/scanner.js +4 -4
- package/dist/core/messages/en/analysts/analyst-github-actions-messages.js +1 -1
- package/dist/core/messages/en/analysts/analyst-patterns-usage-messages.js +1 -0
- package/dist/core/messages/en/analysts/analyst-shell-messages.js +15 -0
- package/dist/core/messages/en/analysts/detector-constructions-syntactic-messages.js +6 -0
- package/dist/core/messages/en/analysts/detector-js-ts-messages.js +27 -0
- package/dist/core/messages/en/analysts/detector-react-messages.js +8 -0
- package/dist/core/messages/en/analysts/detector-shell-messages.js +17 -0
- package/dist/core/messages/en/analysts/detector-tailwind-messages.js +3 -3
- package/dist/core/messages/en/analysts/report-circleci-messages.js +7 -7
- package/dist/core/messages/en/caretakers/caretaker-messages.js +1 -7
- package/dist/core/messages/en/core/plugin-messages.js +31 -3
- package/dist/core/messages/en/log/log.js +4 -4
- package/dist/core/messages/en/ui/filter-config.js +1 -5
- package/dist/core/messages/i18n-system.js +3 -3
- package/dist/core/messages/index.js +3 -3
- package/dist/core/messages/ja/analysts/analyst-github-actions-messages.js +1 -1
- package/dist/core/messages/ja/analysts/analyst-patterns-usage-messages.js +1 -0
- package/dist/core/messages/ja/analysts/analyst-shell-messages.js +15 -0
- package/dist/core/messages/ja/analysts/detector-constructions-syntactic-messages.js +6 -0
- package/dist/core/messages/ja/analysts/detector-js-ts-messages.js +27 -0
- package/dist/core/messages/ja/analysts/detector-react-messages.js +8 -0
- package/dist/core/messages/ja/analysts/detector-shell-messages.js +17 -0
- package/dist/core/messages/ja/analysts/detector-tailwind-messages.js +3 -3
- package/dist/core/messages/ja/analysts/report-circleci-messages.js +7 -7
- package/dist/core/messages/ja/caretakers/caretaker-messages.js +1 -7
- package/dist/core/messages/ja/core/plugin-messages.js +31 -3
- package/dist/core/messages/ja/log/log.js +4 -4
- package/dist/core/messages/ja/ui/filter-config.js +1 -1
- package/dist/core/messages/pt/analysts/analyst-github-actions-messages.js +1 -1
- package/dist/core/messages/pt/analysts/analyst-patterns-usage-messages.js +1 -0
- package/dist/core/messages/pt/analysts/analyst-shell-messages.js +15 -0
- package/dist/core/messages/pt/analysts/detector-constructions-syntactic-messages.js +6 -0
- package/dist/core/messages/pt/analysts/detector-js-ts-messages.js +27 -0
- package/dist/core/messages/pt/analysts/detector-react-messages.js +8 -0
- package/dist/core/messages/pt/analysts/detector-shell-messages.js +17 -0
- package/dist/core/messages/pt/analysts/detector-tailwind-messages.js +3 -3
- package/dist/core/messages/pt/analysts/report-circleci-messages.js +7 -7
- package/dist/core/messages/pt/caretakers/caretaker-messages.js +1 -7
- package/dist/core/messages/pt/core/plugin-messages.js +31 -3
- package/dist/core/messages/pt/log/log-engine.js +6 -6
- package/dist/core/messages/pt/log/log.js +3 -3
- package/dist/core/messages/pt/ui/filter-config.js +1 -1
- package/dist/core/messages/shared/icons.js +3 -3
- package/dist/core/messages/zh/analysts/analyst-github-actions-messages.js +1 -1
- package/dist/core/messages/zh/analysts/analyst-patterns-usage-messages.js +1 -0
- package/dist/core/messages/zh/analysts/analyst-shell-messages.js +15 -0
- package/dist/core/messages/zh/analysts/detector-constructions-syntactic-messages.js +6 -0
- package/dist/core/messages/zh/analysts/detector-js-ts-messages.js +27 -0
- package/dist/core/messages/zh/analysts/detector-react-messages.js +8 -0
- package/dist/core/messages/zh/analysts/detector-shell-messages.js +17 -0
- package/dist/core/messages/zh/analysts/detector-tailwind-messages.js +3 -3
- package/dist/core/messages/zh/analysts/report-circleci-messages.js +7 -7
- package/dist/core/messages/zh/caretakers/caretaker-messages.js +1 -7
- package/dist/core/messages/zh/core/plugin-messages.js +31 -3
- package/dist/core/messages/zh/log/log.js +3 -3
- package/dist/core/messages/zh/ui/filter-config.js +1 -5
- package/dist/core/parsing/filters.js +3 -3
- package/dist/core/parsing/langs/json.js +1 -1
- package/dist/core/parsing/langs/python.js +1 -1
- package/dist/core/parsing/langs/typescript.js +1 -1
- package/dist/core/parsing/parser.js +3 -4
- package/dist/core/parsing/utils.js +1 -0
- package/dist/core/registry/file-registry.js +3 -2
- package/dist/core/registry/paths.js +3 -3
- package/dist/core/reporting/default-reporter.js +2 -2
- package/dist/core/schema/version.js +6 -6
- package/dist/core/workers/worker-executor.js +3 -3
- package/dist/core/workers/worker-pool.js +0 -0
- package/dist/guardian/baseline.js +1 -1
- package/dist/guardian/gpg.js +3 -1
- package/dist/guardian/integrity.js +2 -7
- package/dist/guardian/records.js +7 -1
- package/dist/guardian/result.js +1 -1
- package/dist/guardian/sentinel.js +7 -1
- package/dist/guardian/watcher-hidden.js +6 -1
- package/dist/licenses/fs-utils.js +5 -1
- package/dist/licenses/generate-notices.js +1 -1
- package/dist/licenses/index.js +1 -0
- package/dist/licenses/normalizer.js +10 -9
- package/dist/node.loader.js +224 -4
- package/dist/reports/analise-async-patterns.js +1 -1
- package/dist/reports/filter-smart.js +2 -5
- package/dist/reports/generator-report.js +7 -7
- package/dist/reports/report-archetypes.js +10 -10
- package/dist/reports/report-caretaker-health.js +2 -1
- package/dist/reports/report-patterns-usage.js +1 -1
- package/dist/sdk/analyzer.js +1 -1
- package/dist/shared/data-processing/fragment-report.js +11 -11
- package/dist/shared/data-processing/json.js +1 -1
- package/dist/shared/data-processing/occurrences.js +3 -2
- package/dist/shared/formatters/code-min-formatter.js +1 -1
- package/dist/shared/formatters/engines/prettier.js +1 -1
- package/dist/shared/formatters/engines/stylelint.js +43 -40
- package/dist/shared/formatters/formatter.js +8 -8
- package/dist/shared/formatters/formatters/code.js +3 -3
- package/dist/shared/formatters/formatters/css.js +2 -10
- package/dist/shared/formatters/formatters/dotfiles.js +1 -1
- package/dist/shared/formatters/formatters/html.js +1 -5
- package/dist/shared/formatters/formatters/json.js +0 -3
- package/dist/shared/formatters/formatters/markdown.js +19 -24
- package/dist/shared/formatters/formatters/properties.js +2 -2
- package/dist/shared/formatters/formatters/shell.js +1 -4
- package/dist/shared/formatters/formatters/sql.js +0 -3
- package/dist/shared/formatters/formatters/xml.js +5 -7
- package/dist/shared/formatters/formatters/yaml.js +2 -7
- package/dist/shared/formatters/index.js +1 -1
- package/dist/shared/helpers/framework-detector.js +6 -2
- package/dist/shared/helpers/json.js +1 -1
- package/dist/shared/helpers/magic-constants-whitelist.js +1 -1
- package/dist/shared/helpers/masking.js +17 -17
- package/dist/shared/helpers/reader-report.js +0 -12
- package/dist/shared/helpers/structural-hash.js +3 -2
- package/dist/shared/helpers/structure.js +1 -1
- package/dist/shared/marketplace/registry.js +1 -1
- package/dist/shared/marketplace/remote.js +4 -4
- package/dist/shared/persistence/persistence.js +13 -6
- package/dist/shared/plugins/core-plugin.js +5 -1
- package/dist/shared/plugins/registry.js +3 -2
- package/dist/types/analysts/tailwind-correction.js +2 -0
- package/dist/types/caretakers/imports-barrel.js +1 -0
- package/dist/types/caretakers/index.js +4 -0
- package/dist/types/caretakers/map-reversion.js +1 -0
- package/dist/types/caretakers/pruning.js +1 -0
- package/dist/types/caretakers/scoring.js +1 -0
- package/dist/types/common/analysts.js +1 -1
- package/dist/types/core/config/filters.js +1 -0
- package/dist/types/core/config/index.js +2 -0
- package/dist/types/core/execution/ambiente.js +1 -0
- package/dist/types/core/execution/linguagens.js +1 -0
- package/dist/types/core/execution/parse-errors.js +1 -0
- package/dist/types/core/execution/results.js +1 -0
- package/dist/types/core/execution/structure-json.js +1 -0
- package/dist/types/core/index.js +1 -0
- package/dist/types/core/messages/index.js +1 -0
- package/dist/types/core/messages/log.js +1 -0
- package/dist/types/core/parsing/babel-narrow.js +1 -0
- package/dist/types/core/parsing/index.js +1 -0
- package/dist/types/core/runtime.js +1 -0
- package/dist/types/guardian/index.js +2 -0
- package/dist/types/guardian/integrity.js +7 -0
- package/dist/types/guardian/snapshot.js +1 -0
- package/dist/types/index.js +4 -4
- package/dist/types/licenses/index.js +2 -0
- package/dist/types/processing/display.js +16 -13
- package/dist/types/processing/filters.js +8 -11
- package/dist/types/reports/compliance.js +1 -0
- package/dist/types/reports/streaming.js +1 -0
- package/dist/types/scripts/index.js +1 -0
- package/dist/types/scripts/migrar-aliases.js +1 -0
- package/dist/types/sdk/index.js +1 -0
- package/dist/types/shared/index.js +2 -0
- package/dist/types/vulnerabilities/index.js +2 -0
- package/dist/vulnerabilities/scanner.js +3 -2
- package/package.json +14 -20
|
@@ -162,11 +162,11 @@ export const ICONES_ZELADOR = {
|
|
|
162
162
|
export function getIcone(categoria, nome) {
|
|
163
163
|
switch (categoria) {
|
|
164
164
|
case 'nivel':
|
|
165
|
-
return ICONES_NIVEL[nome]
|
|
165
|
+
return ICONES_NIVEL[nome];
|
|
166
166
|
case 'status':
|
|
167
|
-
return ICONES_STATUS[nome]
|
|
167
|
+
return ICONES_STATUS[nome];
|
|
168
168
|
case 'acao':
|
|
169
|
-
return ICONES_ACAO[nome]
|
|
169
|
+
return ICONES_ACAO[nome];
|
|
170
170
|
default:
|
|
171
171
|
return '[*]';
|
|
172
172
|
}
|
|
@@ -54,5 +54,5 @@ export const AnalistaGithubActionsMensagens = {
|
|
|
54
54
|
pullRequestTargetGrantsWritePermissionsSugestao: '使用 pull_request 代替 pull_request_target,或仔细验证源分支',
|
|
55
55
|
workflowDispatchWithoutInputs: 'workflow_dispatch 未定义 inputs',
|
|
56
56
|
workflowDispatchWithoutInputsSugestao: '定义必需输入以控制手动工作流执行',
|
|
57
|
-
erroAplicarCorrecao: (erro) => `应用修复错误: ${erro}`,
|
|
57
|
+
erroAplicarCorrecao: (erro) => `应用修复错误: ${String(erro)}`,
|
|
58
58
|
};
|
|
@@ -16,5 +16,6 @@ export const PadroesUsoMensagens = {
|
|
|
16
16
|
nonArrowCallback: "使用 'function' 的回调更适合使用箭头函数。建议使用 () => {}。",
|
|
17
17
|
consoleLog: "在生产代码中检测到 console.log。请删除或替换为适当的日志记录器。",
|
|
18
18
|
uselessConditional: "不必要的比较:if (x === true)。只需使用 if (x)。",
|
|
19
|
+
satisfiesUsage: "TypeScript 的 'satisfies' 关键字已使用 — 在不拓宽类型的情况下确保类型安全",
|
|
19
20
|
erroAnalise: (relPath, erro) => `分析 ${relPath} 中的使用模式失败:${erro}`
|
|
20
21
|
};
|
|
@@ -60,4 +60,19 @@ export const AnalistaShellMensagens = {
|
|
|
60
60
|
loopOverCommandOutputSugestao: '使用glob: "for f in *"。',
|
|
61
61
|
pipeOverTempfile: '管道可以替代临时文件。',
|
|
62
62
|
pipeOverTempfileSugestao: '使用管道代替临时文件。',
|
|
63
|
+
// Modern Bash (2026)
|
|
64
|
+
missingSetU: '缺少 "set -u" — 未设置的变量将静默展开为空。',
|
|
65
|
+
missingSetUSugestao: '添加 "set -u" 以捕获变量名拼写错误。',
|
|
66
|
+
missingIso: '缺少 IFS=$\'\\n\\t\' — 分词可能导致意外行为。',
|
|
67
|
+
missingIsoSugestao: '在脚本开头添加 IFS=$\'\\n\\t\' 以确保安全分词。',
|
|
68
|
+
missingTrap: '未找到 trap 处理程序 — 信号时可能跳过清理。',
|
|
69
|
+
missingTrapSugestao: '添加 trap 处理程序: trap "cleanup" EXIT INT TERM。',
|
|
70
|
+
missingMainFn: '脚本缺少 main 函数模式。',
|
|
71
|
+
missingMainFnSugestao: '将逻辑包装在 main() 中并在底部调用 main "$@"。',
|
|
72
|
+
missingCommandV: '硬编码路径而非使用 command -v。',
|
|
73
|
+
missingCommandVSugestao: '使用 "command -v <工具>" 检查可用性。',
|
|
74
|
+
missingDebugMode: '脚本没有调试模式 — 故障排除更困难。',
|
|
75
|
+
missingDebugModeSugestao: '添加 [[ "${DEBUG:-}" == "true" ]] && set -x 以启用调试跟踪。',
|
|
76
|
+
missingInputValidation: '命令参数未验证 — 意外输入可能导致错误。',
|
|
77
|
+
missingInputValidationSugestao: '在开头验证参数: [[ -z "$1" ]] && { echo "用法: ..."; exit 1; }。',
|
|
63
78
|
};
|
|
@@ -11,4 +11,10 @@ export const DetectorConstrucoesSintaticasMensagens = {
|
|
|
11
11
|
templateLiteralOveruse: "简单拼接不需要使用模板字面量。请使用 '+' 运算符。",
|
|
12
12
|
unnecessaryObjectSpread: "不必要的对象展开。直接赋值 'obj.prop = val' 更高效。",
|
|
13
13
|
getterSetterWithoutValidation: "getter/setter 的 setter 中没有验证。请添加验证以防止无效数据。",
|
|
14
|
+
// ES2025/ES2026
|
|
15
|
+
explicitResourceManagement: "检测到使用 'using' 的显式资源管理 (ES2026)",
|
|
16
|
+
temporalApiUsage: "检测到 Temporal API 的使用 (ES2026) — 现代日期/时间替代 Date",
|
|
17
|
+
iteratorHelperUsage: "检测到迭代器辅助方法 (ES2025) — 可迭代对象的惰性求值",
|
|
18
|
+
setMethodUsage: "检测到新的 Set 方法 (ES2025) — 用于集合操作",
|
|
19
|
+
mapUpsertUsage: "检测到 Map 的 upsert 方法 (ES2026) — .getOrInsert() / .getOrInsertComputed()",
|
|
14
20
|
};
|
|
@@ -54,4 +54,31 @@ export const DetectorJsTsMensagens = {
|
|
|
54
54
|
observerWithoutDisconnect: 'Observer(MutationObserver/IntersectionObserver)没有 disconnect()。这会导致内存泄漏。',
|
|
55
55
|
webSocketWithoutClose: 'WebSocket 没有对应的 close() 调用。连接可能保持打开状态。',
|
|
56
56
|
workerWithoutTerminate: 'Worker 没有 terminate() 调用。worker 将继续在后台运行。',
|
|
57
|
+
// ES2025+ features
|
|
58
|
+
satisfiesAvailable: '类型可以使用 "satisfies" 替代 "as" 断言以获得更安全的窄化',
|
|
59
|
+
satisfiesAvailableSugestao: '将 "as Type" 替换为 "satisfies Type" 以验证而不拓宽类型',
|
|
60
|
+
usingResourceManagement: '检测到使用 "using" 的显式资源管理 (ES2026)',
|
|
61
|
+
usingResourceManagementSugestao: '确保资源实现了 Symbol.dispose 或 Symbol.asyncDispose',
|
|
62
|
+
temporalApi: '检测到 Temporal API 使用 (ES2026)',
|
|
63
|
+
temporalApiSugestao: 'Temporal 替代 Date — 使用 Temporal.Now, Temporal.PlainDate 等',
|
|
64
|
+
iteratorHelper: '检测到迭代器辅助方法 (ES2025)',
|
|
65
|
+
iteratorHelperSugestao: '迭代器辅助方法 (.map(), .filter(), .take()) 支持惰性求值',
|
|
66
|
+
setMethods: '检测到新的 Set 方法 (ES2025)',
|
|
67
|
+
setMethodsSugestao: '使用 Set.prototype.union(), .intersection(), .difference() 进行集合操作',
|
|
68
|
+
topLevelAwait: '检测到顶层 await',
|
|
69
|
+
topLevelAwaitSugestao: '确认顶层 await 不会不必要地阻塞导入',
|
|
70
|
+
promiseWithResolvers: '检测到 Promise.withResolvers() (ES2025)',
|
|
71
|
+
promiseWithResolversSugestao: '尽可能使用 async/await 而不是 Promise.withResolvers()',
|
|
72
|
+
promiseAllSettled: '检测到 Promise.allSettled() — 适合 all-settled 模式',
|
|
73
|
+
promiseAllSettledSugestao: '当你需要所有 promise 的结果(无论是否被拒绝)时使用 Promise.allSettled()',
|
|
74
|
+
forAwaitOf: '检测到 for await...of — 异步迭代',
|
|
75
|
+
forAwaitOfSugestao: '确保异步可迭代对象正确实现了 Symbol.asyncIterator',
|
|
76
|
+
regexpEscape: '检测到 RegExp.escape() (ES2025)',
|
|
77
|
+
regexpEscapeSugestao: '使用 RegExp.escape() 安全地转义正则表达式中的用户输入',
|
|
78
|
+
errorIsError: '检测到 Error.isError() (ES2026)',
|
|
79
|
+
errorIsErrorSugestao: '使用 Error.isError() 进行可靠的错误类型检查',
|
|
80
|
+
arrayFromAsync: '检测到 Array.fromAsync() (ES2026)',
|
|
81
|
+
arrayFromAsyncSugestao: '使用 Array.fromAsync() 从异步可迭代对象创建数组',
|
|
82
|
+
mapGetOrInsert: '检测到 Map.getOrInsert() / .getOrInsertComputed() (ES2026)',
|
|
83
|
+
mapGetOrInsertSugestao: '使用 getOrInsert() 进行原子化的 Map upsert 操作',
|
|
57
84
|
};
|
|
@@ -57,4 +57,12 @@ export const DetectorReactMensagens = {
|
|
|
57
57
|
contextTooBroadSugestao: '拆分为更小的context',
|
|
58
58
|
liftingStateTooHigh: '状态提升到比所需更多的层级',
|
|
59
59
|
liftingStateTooHighSugestao: '考虑使用context或局部状态',
|
|
60
|
+
react19ForwardRef: 'forwardRef 在 React 19 中已弃用',
|
|
61
|
+
react19ForwardRefSugestao: '将 ref 作为常规 prop 传递',
|
|
62
|
+
react19FC: 'React.FC 在 React 19 中已弃用',
|
|
63
|
+
react19FCSugestao: '直接键入 props,不要使用 React.FC',
|
|
64
|
+
react19UseClient: '缺少 \'use client\' 指令 (React 19)',
|
|
65
|
+
react19UseClientSugestao: '为客户端组件在文件顶部添加 \'use client\'',
|
|
66
|
+
react19DefaultProps: 'defaultProps 在 React 19 中已弃用',
|
|
67
|
+
react19DefaultPropsSugestao: '使用默认参数值代替',
|
|
60
68
|
};
|
|
@@ -60,4 +60,21 @@ export const DetectorShellMensagens = {
|
|
|
60
60
|
loopOverCommandOutputSugestao: '使用glob模式代替解析ls',
|
|
61
61
|
pipeOverTempfile: '管道可以替代临时文件',
|
|
62
62
|
pipeOverTempfileSugestao: '使用管道代替临时文件',
|
|
63
|
+
// Modern Bash (2026)
|
|
64
|
+
missingSetU: '缺少 "set -u" — 未设置的变量将静默展开为空',
|
|
65
|
+
missingSetUSugestao: '添加 "set -u" 以捕获变量名拼写错误',
|
|
66
|
+
missingIso: '缺少 IFS=$\'\\n\\t\' — 分词可能导致意外行为',
|
|
67
|
+
missingIsoSugestao: '在脚本开头添加 IFS=$\'\\n\\t\' 以确保安全分词',
|
|
68
|
+
missingTrap: '未找到 trap 处理程序 — 信号时可能跳过清理',
|
|
69
|
+
missingTrapSugestao: '添加 trap 处理程序: trap "cleanup" EXIT INT TERM',
|
|
70
|
+
missingMainFn: '脚本缺少 main 函数模式',
|
|
71
|
+
missingMainFnSugestao: '将逻辑包装在 main() 中并在底部调用 main "$@"',
|
|
72
|
+
missingCommandV: '硬编码路径而非使用 command -v',
|
|
73
|
+
missingCommandVSugestao: '使用 "command -v <工具>" 检查可用性',
|
|
74
|
+
missingDebugMode: '脚本没有调试模式 — 故障排除更困难',
|
|
75
|
+
missingDebugModeSugestao: '添加 [[ "${DEBUG:-}" == "true" ]] && set -x 以启用调试跟踪',
|
|
76
|
+
missingInputValidation: '命令参数未验证 — 意外输入可能导致错误',
|
|
77
|
+
missingInputValidationSugestao: '在开头验证参数: [[ -z "$1" ]] && { echo "用法: ..."; exit 1; }',
|
|
78
|
+
shellCheckRecommended: '考虑运行 ShellCheck 进行全面分析',
|
|
79
|
+
shellCheckRecommendedSugestao: '安装 shellcheck 并运行: shellcheck script.sh',
|
|
63
80
|
};
|
|
@@ -5,13 +5,13 @@ export const DetectorTailwindMensagens = {
|
|
|
5
5
|
repeatedClasses: (duplicates) => `重复的类: ${duplicates}`,
|
|
6
6
|
repeatedClassesSugestao: '请删除重复的类',
|
|
7
7
|
arbitraryValue: (val) => `检测到任意值: ${val}`,
|
|
8
|
-
arbitraryValueSugestao: '
|
|
8
|
+
arbitraryValueSugestao: '请考虑通过 CSS 中的 @theme 添加 (Tailwind v4)',
|
|
9
9
|
important: '在Tailwind类中检测到!important',
|
|
10
10
|
importantSugestao: '避免使用!important - 请重构优先级',
|
|
11
11
|
arbitraryValueOveruse: '过度使用任意值 - 可能表明缺少设计令牌',
|
|
12
|
-
arbitraryValueOveruseSugestao: '
|
|
12
|
+
arbitraryValueOveruseSugestao: '通过 CSS 中的 @theme 定义自定义令牌,而不是使用任意值 (Tailwind v4)',
|
|
13
13
|
missingDesignToken: '检测到硬编码值 - 请使用 Tailwind 设计令牌',
|
|
14
|
-
missingDesignTokenSugestao: '将颜色、间距和大小提取到
|
|
14
|
+
missingDesignTokenSugestao: '将颜色、间距和大小提取到 CSS 的 @theme 中 (Tailwind v4)',
|
|
15
15
|
responsiveWithoutBase: '响应式类没有对应的基础类',
|
|
16
16
|
responsiveWithoutBaseSugestao: '在响应式变体之前添加基础类',
|
|
17
17
|
inlineStylesWithTailwind: '检测到内联样式与 Tailwind 类一起使用',
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
export const RelatorioCircleciMensagens = {
|
|
3
3
|
tituloPadrao: '分析报告 - CircleCI',
|
|
4
|
-
repositorio: (
|
|
5
|
-
data: (
|
|
6
|
-
tempo: (
|
|
4
|
+
repositorio: (...args) => `**仓库:** ${String(args[0])}`,
|
|
5
|
+
data: (...args) => `**日期:** ${String(args[0])}`,
|
|
6
|
+
tempo: (...args) => `**时间:** ${args[0]}ms`,
|
|
7
7
|
resumo: '## 摘要',
|
|
8
|
-
scoreGeral: (
|
|
9
|
-
totalConfigs: (
|
|
10
|
-
totalOcorrencias: (
|
|
8
|
+
scoreGeral: (...args) => `| 总体评分 | ${args[0]}/100 |`,
|
|
9
|
+
totalConfigs: (...args) => `| 配置总数 | ${args[0]} |`,
|
|
10
|
+
totalOcorrencias: (...args) => `| 出现总次数 | ${args[0]} |`,
|
|
11
11
|
severidade: '## 严重程度',
|
|
12
12
|
configsAnalisadas: '## 已分析的配置',
|
|
13
13
|
ocorrenciasDetalhadas: '## 详细出现情况',
|
|
14
14
|
geradoPor: '*由Mahoraga v0.7.0生成*',
|
|
15
|
-
formatoNaoSuportado: (
|
|
15
|
+
formatoNaoSuportado: (...args) => `不支持的格式: ${args[0]}`,
|
|
16
16
|
schemaJson: 'mahoraga://schemas/circleci-report/v1',
|
|
17
17
|
versao: '0.7.0',
|
|
18
18
|
csvCabecalho: '文件,行,严重程度,类型,消息,建议',
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
// @mahoraga-disable tipo-literal-inline-complexo
|
|
3
3
|
// Justification: inline types for caretaker messages
|
|
4
|
-
import { ICONES_ACAO, ICONES_STATUS, ICONES_ZELADOR
|
|
4
|
+
import { ICONES_ACAO, ICONES_STATUS, ICONES_ZELADOR } from '../../shared/icons.js';
|
|
5
5
|
/**
|
|
6
6
|
* 管理员消息
|
|
7
7
|
*
|
|
8
8
|
* 集中化所有与管理员 (自动修复) 相关的消息
|
|
9
9
|
* 包括: 导入、类型、结构等。
|
|
10
10
|
*/
|
|
11
|
-
/**
|
|
12
|
-
* 管理员使用的图标和表情
|
|
13
|
-
*/
|
|
14
|
-
const ICONES_ZELADOR = {
|
|
15
|
-
...ICONES_ZELADOR_CENTRAL
|
|
16
|
-
};
|
|
17
11
|
/**
|
|
18
12
|
* 导入管理员消息
|
|
19
13
|
*/
|
|
@@ -29,7 +29,16 @@ export const ReactMensagens = {
|
|
|
29
29
|
export const ReactHooksMensagens = {
|
|
30
30
|
useEffectNoDeps: 'useEffect 缺少依赖数组 (请评估依赖项以避免循环)。',
|
|
31
31
|
memoCallbackNoDeps: 'Hook 缺少依赖数组 (useMemo/useCallback)。',
|
|
32
|
-
hookInConditional: '在条件语句中声明了 Hook (违反了 Hooks 规则)。'
|
|
32
|
+
hookInConditional: '在条件语句中声明了 Hook (违反了 Hooks 规则)。',
|
|
33
|
+
react19Use: '检测到 use() 钩子 (React 19) — 请确保包裹在 <Suspense> 边界内。',
|
|
34
|
+
react19UseOptimistic: '检测到 useOptimistic 钩子 (React 19) — 需要更新函数。',
|
|
35
|
+
react19UseActionState: '检测到 useActionState 钩子 (React 19) — 用于表单操作。',
|
|
36
|
+
react19UseFormStatus: '检测到 useFormStatus 钩子 (React 19) — 访问表单待处理状态。',
|
|
37
|
+
react19ForwardRefDeprecated: 'forwardRef 在 React 19 中已弃用 — 将 ref 作为常规 prop 传递。',
|
|
38
|
+
react19FCDeprecated: 'React.FC/FunctionComponent 在 React 19 中已弃用 — 直接键入 props。',
|
|
39
|
+
react19DefaultPropsDeprecated: 'defaultProps 在 React 19 中已弃用 — 使用默认参数。',
|
|
40
|
+
react19UseClient: '文件使用了客户端功能 (hooks/events) 但缺少 \'use client\' 指令 (React 19)。',
|
|
41
|
+
react19FormAction: '检测到带有 action 属性的表单 (React 19)。'
|
|
33
42
|
};
|
|
34
43
|
// ─── Tailwind 消息 ──────────────────────────────────────────────
|
|
35
44
|
export const TailwindMensagens = {
|
|
@@ -38,7 +47,13 @@ export const TailwindMensagens = {
|
|
|
38
47
|
importantUsage: (token) => `在 (${token}) 中检测到使用 ! (important)。建议使用工具类或作用域增强,而非 important。`,
|
|
39
48
|
variantConflict: (prop, variants) => `${prop} 可能存在变体冲突 (变体: ${variants.slice(0, 6).join(', ')})。请检查顺序/作用域。`,
|
|
40
49
|
dangerousArbitraryValue: (token) => `带有潜在危险的 url 任意值 (${token})。避免使用 javascript:/data:text/html。`,
|
|
41
|
-
arbitraryValue: (token) => `带有任意值的类 (${token})
|
|
50
|
+
arbitraryValue: (token) => `带有任意值的类 (${token})。请确认是否符合设计。`,
|
|
51
|
+
v3DeprecatedUtility: (token, replacement) => `v3 废弃的工具类 "${token}" → 使用 "${replacement}" (Tailwind v4).`,
|
|
52
|
+
v3Directive: `检测到 @tailwind 指令 (v3) → 使用 @import "tailwindcss" (Tailwind v4).`,
|
|
53
|
+
v3LayerUtilities: `检测到 @layer utilities (v3) → 使用 @utility (Tailwind v4).`,
|
|
54
|
+
themeFunction: `检测到 theme() 函数 (v3 已弃用) → 优先使用 CSS 变量 (var(--color-*)).`,
|
|
55
|
+
v3ImportantPrefix: (token) => `"${token}" 中的 !important 前缀 (v3) → 将 ! 移到末尾 ("${token.replace('!', '')}!" ).`,
|
|
56
|
+
v3ArbitraryVar: `方括号中的变量 (v3) → 使用圆括号 (例如用 bg-(--var) 代替 bg-[--var]).`
|
|
42
57
|
};
|
|
43
58
|
// ─── CSS 消息 ───────────────────────────────────────────────────
|
|
44
59
|
export const CssMensagens = {
|
|
@@ -270,7 +285,20 @@ export const RustMensagens = {
|
|
|
270
285
|
missingDoc: (fnName) => `公开函数 '${fnName}' 缺少文档注释 (///)。`,
|
|
271
286
|
namingConvention: (constName) => `常量 '${constName}' 应遵循 SCREAMING_CASE 命名约定。`,
|
|
272
287
|
redundantReturn: '函数末尾的 return 是多余的;Rust 使用隐式返回 (最后一个表达式)。',
|
|
273
|
-
wildcardImport: (importPath) => `通配符导入 '${importPath}'
|
|
288
|
+
wildcardImport: (importPath) => `通配符导入 '${importPath}' 可能污染命名空间;建议使用显式导入。`,
|
|
289
|
+
lazyLockSuggestion: '检测到 once_cell::sync::Lazy — 使用 std::sync::LazyLock (Rust 1.80+)。',
|
|
290
|
+
onceLockSuggestion: '检测到 once_cell::sync::OnceCell — 使用 std::sync::OnceLock (Rust 1.70+)。',
|
|
291
|
+
offsetOfSuggestion: '手动指针偏移访问字段 — 使用 std::mem::offset_of! (Rust 1.77+)。',
|
|
292
|
+
letChainsPattern: '检测到 let_chains 模式 (Rust 1.78 起稳定)。',
|
|
293
|
+
assertMatchesSuggestion: 'assert!(matches!(...)) 模式 — 考虑 assert_matches!(...) (nightly)。',
|
|
294
|
+
isSomeAnd: '.is_some() && 谓词模式 — 使用 .is_some_and(|x| ...) (Rust 1.70+)。',
|
|
295
|
+
isOkAnd: '.is_ok() && 谓词模式 — 使用 .is_ok_and(|x| ...) (Rust 1.70+)。',
|
|
296
|
+
inspectMethod: '具有副作用的 map() — 使用 .inspect() (Rust 1.76+)。',
|
|
297
|
+
implicitFormatCapture: 'format!("...{var}...") 可使用隐式捕获 (Rust 1.80+)。',
|
|
298
|
+
pointerCast: '使用 `as` 进行指针转换 — 使用 .cast() (Rust 1.72+)。',
|
|
299
|
+
splitOnce: '使用索引访问的 splitn(2, ...) — 使用 .split_once() (Rust 1.62+)。',
|
|
300
|
+
okErrAntipattern: '.ok()?.unwrap() 反模式 — 直接在 Result 上使用 ?。',
|
|
301
|
+
collectOverPush: '循环中使用 push() 构建集合 — 使用 .map().collect()。'
|
|
274
302
|
};
|
|
275
303
|
// ─── Java / Kotlin 消息 ─────────────────────────────────────────
|
|
276
304
|
export const JavaMensagens = {
|
|
@@ -140,7 +140,7 @@ export function formatarLinha({ nivel, mensagem, sanitize = true }) {
|
|
|
140
140
|
if (!process.env.VITEST && process.env.SUKUNA_CENTER === '1') {
|
|
141
141
|
try {
|
|
142
142
|
const cols = obterColunasTerm();
|
|
143
|
-
const out =
|
|
143
|
+
const out = typeof process.stdout.isTTY !== 'undefined' ? process.stdout : undefined;
|
|
144
144
|
const isTty = !!out && out.isTTY;
|
|
145
145
|
if (isTty && cols && cols > 0) {
|
|
146
146
|
const ANSI_REGEX = /[\u001B\u009B][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
@@ -164,7 +164,7 @@ export function formatarLinha({ nivel, mensagem, sanitize = true }) {
|
|
|
164
164
|
function obterColunasTerm() {
|
|
165
165
|
// Tries to get terminal width safely
|
|
166
166
|
try {
|
|
167
|
-
const out =
|
|
167
|
+
const out = typeof process.stdout.columns !== 'undefined' ? process.stdout : undefined;
|
|
168
168
|
const cols = out?.columns;
|
|
169
169
|
if (typeof cols === 'number' && cols > 0) {
|
|
170
170
|
return cols;
|
|
@@ -414,7 +414,7 @@ export const log = {
|
|
|
414
414
|
const visibleLen = (string) => string.replace(ANSI_REGEX, '').length;
|
|
415
415
|
const frameWidth = Math.max(...lines.map(linha => visibleLen(linha)));
|
|
416
416
|
const cols = obterColunasTerm() ?? 0;
|
|
417
|
-
const outStream =
|
|
417
|
+
const outStream = typeof process.stdout.isTTY !== 'undefined' ? process.stdout : undefined;
|
|
418
418
|
const isTty = !!outStream && outStream.isTTY;
|
|
419
419
|
if (isTty) {
|
|
420
420
|
const pad = Math.floor(Math.max(0, cols - frameWidth) / 2);
|
|
@@ -221,11 +221,7 @@ export const AGRUPAMENTOS_MENSAGEM = [
|
|
|
221
221
|
* 获取问题类型的优先级
|
|
222
222
|
*/
|
|
223
223
|
export function getPrioridade(tipo) {
|
|
224
|
-
return PRIORIDADES[tipo]
|
|
225
|
-
prioridade: 'baixa',
|
|
226
|
-
icone: ICONES_ARQUIVO.arquivo,
|
|
227
|
-
descricao: '未分类问题'
|
|
228
|
-
};
|
|
224
|
+
return PRIORIDADES[tipo];
|
|
229
225
|
}
|
|
230
226
|
/**
|
|
231
227
|
* 按消息查找分组
|
|
@@ -16,7 +16,7 @@ export function aplicarSupressaoOcorrencias(ocorrencias, filtros) {
|
|
|
16
16
|
const relPath = ocorrencia.relPath || '';
|
|
17
17
|
const mensagem = (ocorrencia).mensagem || '';
|
|
18
18
|
// Suprime por tipo/regra (verifica tanto o tipo quanto a mensagem)
|
|
19
|
-
if (filtros.suppressRules?.some(rule => tipo.includes(rule) || mensagem.includes(rule))) {
|
|
19
|
+
if (filtros.suppressRules?.some((rule) => tipo.includes(rule) || mensagem.includes(rule))) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
22
|
// Suprime por severidade: se a regra tiver override de severidade "off", suprime
|
|
@@ -24,14 +24,14 @@ export function aplicarSupressaoOcorrencias(ocorrencias, filtros) {
|
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
26
|
// Suprime por caminho (glob patterns)
|
|
27
|
-
if (filtros.suppressByPath?.some(pattern => {
|
|
27
|
+
if (filtros.suppressByPath?.some((pattern) => {
|
|
28
28
|
const regex = globPatternToRegExp(pattern);
|
|
29
29
|
return regex.test(relPath);
|
|
30
30
|
})) {
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
33
33
|
// Suprime por padrão de arquivo
|
|
34
|
-
if (filtros.suppressByFilePattern?.some(pattern => {
|
|
34
|
+
if (filtros.suppressByFilePattern?.some((pattern) => {
|
|
35
35
|
const fileNome = relPath.split('/').pop() ?? '';
|
|
36
36
|
const regex = globPatternToRegExp(pattern);
|
|
37
37
|
return regex.test(fileNome);
|
|
@@ -7,7 +7,7 @@ export function parseComJson(codigo) {
|
|
|
7
7
|
const info = {
|
|
8
8
|
type: Array.isArray(parsed) ? 'array' : typeof parsed,
|
|
9
9
|
};
|
|
10
|
-
if (typeof parsed === 'object' &&
|
|
10
|
+
if (typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
11
11
|
const keys = Object.keys(parsed);
|
|
12
12
|
info.keys = keys;
|
|
13
13
|
info.depth = estimateDepth(parsed, 0);
|
|
@@ -8,7 +8,7 @@ export function parseComPython(codigo) {
|
|
|
8
8
|
const asyncFunctions = Array.from(codigo.matchAll(/^\s*async\s+def\s+([A-Za-z0-9_]+)/gm)).map(m => m[1]);
|
|
9
9
|
const imports = Array.from(codigo.matchAll(/^\s*(?:from\s+([\w.]+)\s+)?import\s+(.+)$/gm)).map(m => ({
|
|
10
10
|
module: m[1] || null,
|
|
11
|
-
names: m[2].split(',').map(s => s.trim().split(/\s+as\s+/)[0]).filter(Boolean)
|
|
11
|
+
names: m[2].split(',').map(s => s.trim().split(/\s+as\s+/)[0]).filter(Boolean)
|
|
12
12
|
}));
|
|
13
13
|
const decorators = Array.from(codigo.matchAll(/^\s*@([A-Za-z0-9_.]+)/gm)).map(m => m[1]);
|
|
14
14
|
const topLevelVars = Array.from(codigo.matchAll(/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=(?!=)/gm)).map(m => m[1]);
|
|
@@ -9,7 +9,7 @@ export function parseComTypeScript(codigo, tsx = false) {
|
|
|
9
9
|
const sf = ts.createSourceFile(tsx ? 'file.tsx' : 'file.ts', codigo, ts.ScriptTarget.Latest, false, tsx ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
|
|
10
10
|
return wrapMinimal(tsx ? 'tsx-tsc' : 'ts-tsc', {
|
|
11
11
|
kind: sf.kind,
|
|
12
|
-
statements: sf.statements.length
|
|
12
|
+
statements: sf.statements.length
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
catch (erro) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
1
2
|
import { getMessages } from '../messages/index.js';
|
|
2
3
|
import { getGlobalRegistry, initializeDefaultPlugins } from '../../shared/plugins/index.js';
|
|
3
4
|
import { parseComBabel, parseComCss, parseComGo, parseComHtmlFunc, parseComJson, parseComMarkdown, parseComPhp, parseComPython, parseComRust, parseComScss, parseComShell, parseComText, parseComTypeScript, parseComVue, parseComXml, parseComYaml, } from './langs/index.js';
|
|
@@ -83,7 +84,7 @@ export async function decifrarSintaxe(codigo, ext, opts = {}) {
|
|
|
83
84
|
}
|
|
84
85
|
if (opts.timeoutMs) {
|
|
85
86
|
return (async () => {
|
|
86
|
-
let timer =
|
|
87
|
+
let timer = undefined;
|
|
87
88
|
try {
|
|
88
89
|
const race = Promise.race([Promise.resolve(parseResultado), new Promise(resolve => {
|
|
89
90
|
timer = setTimeout(() => {
|
|
@@ -94,9 +95,7 @@ export async function decifrarSintaxe(codigo, ext, opts = {}) {
|
|
|
94
95
|
return await race;
|
|
95
96
|
}
|
|
96
97
|
finally {
|
|
97
|
-
|
|
98
|
-
clearTimeout(timer);
|
|
99
|
-
}
|
|
98
|
+
clearTimeout(timer);
|
|
100
99
|
setCurrentParsingFile(undefined);
|
|
101
100
|
}
|
|
102
101
|
})();
|
|
@@ -109,17 +109,18 @@ async function tryMigrate(targetPath) {
|
|
|
109
109
|
*/
|
|
110
110
|
export async function readJSON(fileCaminho, options = {}) {
|
|
111
111
|
const { default: defaultValue, migrate = true, validate } = options;
|
|
112
|
+
let resolvedPath = fileCaminho;
|
|
112
113
|
try {
|
|
113
114
|
// Tentar migração se habilitado
|
|
114
115
|
if (migrate) {
|
|
115
116
|
const migration = await tryMigrate(fileCaminho);
|
|
116
117
|
if (migration.migrated && migration.to) {
|
|
117
118
|
// Usar arquivo migrado
|
|
118
|
-
|
|
119
|
+
resolvedPath = migration.to;
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
// Ler e parsear diretamente (sem check de existência separado para evitar TOCTOU)
|
|
122
|
-
const content = await fs.readFile(
|
|
123
|
+
const content = await fs.readFile(resolvedPath, 'utf-8');
|
|
123
124
|
const parsed = JSON.parse(content);
|
|
124
125
|
// Validar se fornecido
|
|
125
126
|
if (validate && !validate(parsed)) {
|
|
@@ -87,11 +87,11 @@ export const REPORT_PADROES = {
|
|
|
87
87
|
*/
|
|
88
88
|
export const MIGRACAO_MAPA = {
|
|
89
89
|
// Guardian: baseline.json → guardian.baseline.json
|
|
90
|
-
[
|
|
90
|
+
[path.join(SUKUNA_DIRS.STATE, 'baseline.json')]: SUKUNA_ARQUIVOS.GUARDIAN_BASELINE,
|
|
91
91
|
// Estrutura: baseline-estrutura.json → estrutura.baseline.json
|
|
92
|
-
[
|
|
92
|
+
[path.join(SUKUNA_DIRS.STATE, 'baseline-estrutura.json')]: SUKUNA_ARQUIVOS.ESTRUTURA_BASELINE,
|
|
93
93
|
// Arquétipo: mahoraga.repo.arquetipo.json (raiz) → .mahoraga/estrutura.arquetipo.json
|
|
94
|
-
[
|
|
94
|
+
[path.join(PROJETO_RAIZ, 'mahoraga.repo.arquetipo.json')]: SUKUNA_ARQUIVOS.ESTRUTURA_ARQUETIPO
|
|
95
95
|
};
|
|
96
96
|
/**
|
|
97
97
|
* Retorna o caminho legado (se existir) ou o novo
|
|
@@ -23,7 +23,7 @@ export function createDefaultReporter() {
|
|
|
23
23
|
}
|
|
24
24
|
// Mapeamentos mínimos (incrementais) por code
|
|
25
25
|
if (code === 'ARQ_PADRAO') {
|
|
26
|
-
const padrao =
|
|
26
|
+
const padrao = typeof data?.padraoIdentificado === 'string' ? data.padraoIdentificado : '';
|
|
27
27
|
const confianca = Number((data?.confianca) ?? 0);
|
|
28
28
|
return criarOcorrencia({
|
|
29
29
|
tipo,
|
|
@@ -50,7 +50,7 @@ export function createDefaultReporter() {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
if (code === 'ARQ_VIOLACAO') {
|
|
53
|
-
const violacao =
|
|
53
|
+
const violacao = typeof data?.violacao === 'string' ? data.violacao : '';
|
|
54
54
|
return criarOcorrencia({
|
|
55
55
|
tipo,
|
|
56
56
|
nivel,
|
|
@@ -23,10 +23,10 @@ export const HISTORICO_VERSOES = {
|
|
|
23
23
|
* Cria metadados de schema para a versão atual
|
|
24
24
|
*/
|
|
25
25
|
export function criarSchemaMetadata(versao = VERSAO_ATUAL, descricaoPersonalizada) {
|
|
26
|
-
|
|
27
|
-
if (!base) {
|
|
26
|
+
if (!(versao in HISTORICO_VERSOES)) {
|
|
28
27
|
throw new Error(messages.ExcecoesMensagens.versaoSchemaDesconhecida(versao));
|
|
29
28
|
}
|
|
29
|
+
const base = HISTORICO_VERSOES[versao];
|
|
30
30
|
return {
|
|
31
31
|
...base,
|
|
32
32
|
...(descricaoPersonalizada && {
|
|
@@ -40,7 +40,7 @@ export function criarSchemaMetadata(versao = VERSAO_ATUAL, descricaoPersonalizad
|
|
|
40
40
|
export function validarSchema(relatorio) {
|
|
41
41
|
const erros = [];
|
|
42
42
|
// Verificar estrutura básica
|
|
43
|
-
if (
|
|
43
|
+
if (typeof relatorio !== 'object') {
|
|
44
44
|
erros.push('Relatório deve ser um objeto');
|
|
45
45
|
return {
|
|
46
46
|
valido: false,
|
|
@@ -64,7 +64,7 @@ export function validarSchema(relatorio) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
// Verificar se a versão existe no histórico
|
|
67
|
-
if (schema.versao && typeof schema.versao === 'string' && !
|
|
67
|
+
if (schema.versao && typeof schema.versao === 'string' && !(schema.versao in HISTORICO_VERSOES)) {
|
|
68
68
|
erros.push(`Versão de schema desconhecida: ${schema.versao}`);
|
|
69
69
|
}
|
|
70
70
|
// Verificar presença dos dados
|
|
@@ -119,9 +119,9 @@ export function extrairDados(relatorio) {
|
|
|
119
119
|
* Verifica se uma versão é compatível com a atual
|
|
120
120
|
*/
|
|
121
121
|
export function versaoCompativel(versao) {
|
|
122
|
-
|
|
123
|
-
if (!metadata) {
|
|
122
|
+
if (!(versao in HISTORICO_VERSOES)) {
|
|
124
123
|
return false;
|
|
125
124
|
}
|
|
125
|
+
const metadata = HISTORICO_VERSOES[versao];
|
|
126
126
|
return metadata.compatibilidade.includes(VERSAO_ATUAL);
|
|
127
127
|
}
|
|
@@ -99,7 +99,7 @@ async function processarLote(lote, contexto) {
|
|
|
99
99
|
const inicio = Date.now();
|
|
100
100
|
const out = await executarTecnicaEmArquivo(tecnica, file, contexto, timeoutMs);
|
|
101
101
|
const dur = Date.now() - inicio;
|
|
102
|
-
if (
|
|
102
|
+
if (Array.isArray(out)) {
|
|
103
103
|
fileResultado.ocorrencias.push(...out);
|
|
104
104
|
}
|
|
105
105
|
fileResultado.tempos.push({
|
|
@@ -150,8 +150,8 @@ async function main() {
|
|
|
150
150
|
/* ignore */
|
|
151
151
|
}
|
|
152
152
|
const resultados = await processarLote(wd.lote ?? wd.files ?? [], contexto);
|
|
153
|
-
const occurrences = resultados.flatMap(raiz => raiz.ocorrencias
|
|
154
|
-
const metrics = resultados.flatMap(raiz => raiz.tempos
|
|
153
|
+
const occurrences = resultados.flatMap(raiz => raiz.ocorrencias);
|
|
154
|
+
const metrics = resultados.flatMap(raiz => raiz.tempos);
|
|
155
155
|
const processedArquivos = Array.isArray(wd.files) ? wd.files.length : resultados.length || 0;
|
|
156
156
|
if (port) {
|
|
157
157
|
port.postMessage({
|
|
Binary file
|
|
@@ -9,7 +9,7 @@ import { lerEstado, salvarEstado } from '../shared/persistence/index.js';
|
|
|
9
9
|
export async function carregarBaseline() {
|
|
10
10
|
try {
|
|
11
11
|
const json = await lerEstado(LINHA_BASE_CAMINHO);
|
|
12
|
-
if (
|
|
12
|
+
if (typeof json === 'object' && !Array.isArray(json)) {
|
|
13
13
|
const entries = Object.entries(json).filter(([chave, valor]) => typeof chave === 'string' && typeof valor === 'string');
|
|
14
14
|
return Object.fromEntries(entries);
|
|
15
15
|
}
|
package/dist/guardian/gpg.js
CHANGED
|
@@ -80,6 +80,8 @@ export async function inicializarChaves() {
|
|
|
80
80
|
}
|
|
81
81
|
const par = await gerarParDeChaves();
|
|
82
82
|
await salvarChavePublica(par.chavePublica);
|
|
83
|
-
|
|
83
|
+
if (par.chavePrivada) {
|
|
84
|
+
await salvarChavePrivada(par.chavePrivada);
|
|
85
|
+
}
|
|
84
86
|
return par;
|
|
85
87
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
IntegridadeStatus["Criado"] = "baseline-criado";
|
|
5
|
-
IntegridadeStatus["Aceito"] = "baseline-aceito";
|
|
6
|
-
IntegridadeStatus["Ok"] = "ok";
|
|
7
|
-
IntegridadeStatus["AlteracoesDetectadas"] = "alteracoes-detectadas";
|
|
8
|
-
})(IntegridadeStatus || (IntegridadeStatus = {}));
|
|
2
|
+
import { IntegridadeStatus } from '../types/guardian/integrity.js';
|
|
3
|
+
export { IntegridadeStatus };
|
|
9
4
|
export class GuardianError extends Error {
|
|
10
5
|
detalhes;
|
|
11
6
|
constructor(erros) {
|
package/dist/guardian/records.js
CHANGED
|
@@ -5,8 +5,12 @@ import { config } from '../core/config/index.js';
|
|
|
5
5
|
import { getMessages } from '../core/messages/index.js';
|
|
6
6
|
import { ensureDir } from '../shared/helpers/index.js';
|
|
7
7
|
import { lerEstado, salvarEstado } from '../shared/persistence/index.js';
|
|
8
|
-
const { log, GuardianMensagens } = getMessages();
|
|
9
8
|
const DESTINO_PADRAO = path.join(config.STATE_DIR, 'integridade.json');
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
10
|
+
function getLog() {
|
|
11
|
+
const { log, GuardianMensagens } = getMessages();
|
|
12
|
+
return { log, GuardianMensagens };
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* Salva as assinaturas GPG dos arquivos fornecidos em um arquivo de integridade.
|
|
12
16
|
*/
|
|
@@ -21,6 +25,7 @@ export async function salvarRegistros(fileEntries, destino = DESTINO_PADRAO) {
|
|
|
21
25
|
}
|
|
22
26
|
await ensureDir(destino);
|
|
23
27
|
await salvarEstado(destino, registros);
|
|
28
|
+
const { log, GuardianMensagens } = getLog();
|
|
24
29
|
log.sucesso(GuardianMensagens.registroIntegridadeSalvo(destino));
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
@@ -31,6 +36,7 @@ export async function carregarRegistros(caminho = DESTINO_PADRAO) {
|
|
|
31
36
|
return await lerEstado(caminho);
|
|
32
37
|
}
|
|
33
38
|
catch {
|
|
39
|
+
const { log, GuardianMensagens } = getLog();
|
|
34
40
|
log.aviso(GuardianMensagens.nenhumRegistroEncontrado(caminho));
|
|
35
41
|
return [];
|
|
36
42
|
}
|
package/dist/guardian/result.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Tipos para resultados do Guardian
|
|
4
4
|
*/
|
|
5
|
+
import { IntegridadeStatus } from './index.js';
|
|
5
6
|
/**
|
|
6
7
|
* Type guard para verificar se é resultado válido do Guardian
|
|
7
8
|
*/
|
|
@@ -19,7 +20,6 @@ export function isGuardianResult(value) {
|
|
|
19
20
|
const status = obj.status;
|
|
20
21
|
return (status === 'ok' || status === 'alteracoes-detectadas' || status === 'erro');
|
|
21
22
|
}
|
|
22
|
-
import { IntegridadeStatus } from './integrity.js';
|
|
23
23
|
/**
|
|
24
24
|
* Converte ResultadoGuardian (tipo legado) para GuardianResult
|
|
25
25
|
*/
|