@mocoto/mahoraga 0.14.2 → 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 +19 -19
- package/dist/analysts/architects/archetypes-custom.js +8 -6
- package/dist/analysts/architects/detector-archetypes.js +30 -27
- package/dist/analysts/architects/signals-project-advanced.js +24 -26
- package/dist/analysts/architects/signals-project.js +1 -1
- package/dist/analysts/architects/strategist-structure.js +47 -66
- package/dist/analysts/azure-pipelines/analysts/analyst-azure.js +21 -14
- 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 -37
- package/dist/analysts/azure-pipelines/scorers/scorer-azure.js +10 -7
- package/dist/analysts/circleci/analysts/analyst-circleci.js +23 -15
- 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 +20 -17
- package/dist/analysts/converters/engines/converter-gha-to-gitlab.js +17 -15
- package/dist/analysts/corrections/analyst-quick-fixes.js +25 -28
- package/dist/analysts/corrections/analyst-scoring.js +24 -21
- package/dist/analysts/corrections/corrector-structure.js +35 -35
- 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 +54 -51
- 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 +10 -10
- 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-validator.js +2 -1
- package/dist/analysts/corrections/type-safety/usage-analyzer.js +36 -39
- package/dist/analysts/css/analysts/analyst-css.js +16 -15
- 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 +20 -15
- 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 +89 -83
- package/dist/analysts/detectors/detector-bugs-ml.js +21 -19
- package/dist/analysts/detectors/detector-code-fragile.js +30 -26
- package/dist/analysts/detectors/detector-duplications.js +21 -18
- package/dist/analysts/detectors/detector-monorepo.js +41 -36
- package/dist/analysts/detectors/detector-performance.js +22 -16
- package/dist/analysts/detectors/detector-recommendation-architecture.js +39 -35
- package/dist/analysts/detectors/detector-security.js +43 -42
- package/dist/analysts/detectors/detector-structure.js +29 -26
- package/dist/analysts/js-ts/detectors/detector-anti-patterns-async.js +4 -1
- package/dist/analysts/js-ts/detectors/detector-constructions-syntactic.js +10 -16
- package/dist/analysts/plugins/detector-documentation.js +1 -0
- package/dist/analysts/react/analysts/analyst-react-hooks.js +4 -2
- package/dist/analysts/react/analysts/analyst-react.js +1 -1
- package/dist/analysts/react/corrections/correction-react.js +2 -2
- package/dist/analysts/react/detectors/detector-react-best-practices.js +1 -1
- package/dist/analysts/registry/autodiscovery.js +2 -2
- package/dist/analysts/tailwind/corrections/correction-tailwind.js +0 -8
- package/dist/analysts/tailwind/scorers/scorer-tailwind.js +1 -2
- package/dist/cli/commands/command-analysts.js +3 -2
- package/dist/cli/commands/command-formatters.js +1 -1
- package/dist/cli/commands/command-github-actions.js +1 -1
- package/dist/cli/commands/command-guardian.js +1 -1
- package/dist/cli/commands/command-marketplace.js +4 -4
- package/dist/cli/diagnostic/filters.js +9 -9
- package/dist/core/config/chalk-safe.js +4 -4
- package/dist/core/config/config.js +5 -5
- package/dist/core/execution/analysis-cache.js +1 -1
- package/dist/core/execution/ast-cache.js +1 -3
- package/dist/core/execution/executor.js +2 -4
- package/dist/core/execution/scanner.js +1 -1
- 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/ja/analysts/report-circleci-messages.js +7 -7
- package/dist/core/messages/ja/caretakers/caretaker-messages.js +1 -7
- 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/zh/analysts/report-circleci-messages.js +7 -7
- package/dist/core/messages/zh/caretakers/caretaker-messages.js +1 -7
- package/dist/core/parsing/parser.js +2 -3
- package/dist/core/parsing/utils.js +1 -0
- package/dist/core/workers/worker-pool.js +0 -0
- package/dist/guardian/records.js +1 -0
- package/dist/guardian/sentinel.js +1 -0
- package/dist/guardian/watcher-hidden.js +1 -0
- package/dist/licenses/fs-utils.js +2 -1
- package/dist/licenses/header-options.js +1 -0
- package/dist/licenses/index.js +1 -1
- package/dist/reports/generator-report.js +3 -3
- package/dist/reports/report-patterns-usage.js +1 -1
- package/dist/shared/data-processing/fragment-report.js +1 -1
- package/dist/shared/formatters/engines/stylelint.js +40 -34
- package/dist/shared/formatters/formatters/markdown.js +1 -1
- package/dist/shared/helpers/framework-detector.js +5 -1
- package/dist/shared/persistence/persistence.js +13 -5
- package/dist/shared/plugins/core-plugin.js +3 -1
- package/dist/types/analysts/tailwind-correction.js +2 -0
- package/dist/types/index.js +3 -3
- package/dist/types/processing/filters.js +5 -4
- package/dist/vulnerabilities/npm-audit.js +1 -0
- package/dist/vulnerabilities/scanner.js +1 -1
- package/dist/vulnerabilities/vulnerabilities.js +1 -0
- package/package.json +5 -10
|
@@ -19,7 +19,7 @@ export function detectarCorrecoesReact(src, _relPath) {
|
|
|
19
19
|
correcoes.push({
|
|
20
20
|
tipo: 'react-dangerous-html',
|
|
21
21
|
original: linha.trim(),
|
|
22
|
-
sugerido: '//
|
|
22
|
+
sugerido: '// SEGURANCA: Use DOMPurify.sanitize() antes de dangerouslySetInnerHTML\n// <div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(html) }} />',
|
|
23
23
|
linha: numeroLinha,
|
|
24
24
|
confianca: 90
|
|
25
25
|
});
|
|
@@ -122,7 +122,7 @@ export function detectarCorrecoesReact(src, _relPath) {
|
|
|
122
122
|
correcoes.push({
|
|
123
123
|
tipo: 'react-use-client-missing',
|
|
124
124
|
original: linha.trim(),
|
|
125
|
-
sugerido:
|
|
125
|
+
sugerido: `'use client';\n\n${linha.trim()}`,
|
|
126
126
|
linha: numeroLinha,
|
|
127
127
|
confianca: 70
|
|
128
128
|
});
|
|
@@ -66,7 +66,7 @@ function detectWithBabel(src, relPath) {
|
|
|
66
66
|
try {
|
|
67
67
|
const plugins = ['decorators-legacy', 'classProperties', 'classPrivateProperties', 'classPrivateMethods', 'optionalChaining', 'nullishCoalescingOperator', 'topLevelAwait', 'importAttributes', 'jsx'];
|
|
68
68
|
plugins.unshift('typescript');
|
|
69
|
-
const ast = babelParse(src, { sourceType: 'unambiguous', errorRecovery: true, plugins });
|
|
69
|
+
const ast = babelParse(src, { sourceType: 'unambiguous', errorRecovery: true, plugins: plugins });
|
|
70
70
|
const out = [];
|
|
71
71
|
const seen = new Set();
|
|
72
72
|
const pushOnce = (o) => {
|
|
@@ -13,8 +13,8 @@ function extrairEntradasDeModulo(mod) {
|
|
|
13
13
|
const out = [];
|
|
14
14
|
const candidates = [];
|
|
15
15
|
candidates.push(metrica.default);
|
|
16
|
-
if (Array.isArray(metrica.analistas)) {
|
|
17
|
-
candidates.push(...metrica.analistas);
|
|
16
|
+
if (Array.isArray((metrica).analistas)) {
|
|
17
|
+
candidates.push(...(metrica).analistas);
|
|
18
18
|
}
|
|
19
19
|
// Coleta exportações nomeadas que pareçam analista/técnica
|
|
20
20
|
for (const valor of Object.values(metrica)) {
|
|
@@ -32,13 +32,6 @@ function detectarClasseSufixoV3(classe) {
|
|
|
32
32
|
const sub = V3_TO_V4_SUFFIX_CLASSES[base];
|
|
33
33
|
return sub ? `${variante}${sub}` : null;
|
|
34
34
|
}
|
|
35
|
-
function detectarImportantPrefix(texto) {
|
|
36
|
-
const match = texto.match(/!([\w-]+)/);
|
|
37
|
-
if (match) {
|
|
38
|
-
return match[1];
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
35
|
export function detectarCorrecoesTailwind(src, _relPath) {
|
|
43
36
|
const correcoes = [];
|
|
44
37
|
const linhas = splitLines(src);
|
|
@@ -60,7 +53,6 @@ export function detectarCorrecoesTailwind(src, _relPath) {
|
|
|
60
53
|
for (const cls of unique) {
|
|
61
54
|
const v4Class = detectarClasseV3Deprecated(cls);
|
|
62
55
|
if (v4Class) {
|
|
63
|
-
const newClasses = unique.map(c => c === cls ? v4Class : c);
|
|
64
56
|
correcoes.push({
|
|
65
57
|
tipo: 'tailwind-v3-to-v4-rename',
|
|
66
58
|
original: cls,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
import { splitLines } from '../../../shared/helpers/index.js';
|
|
3
2
|
const V3_DEPRECATED_MAP = {
|
|
4
3
|
'shadow-sm': 'shadow-xs',
|
|
5
4
|
'drop-shadow-sm': 'drop-shadow-xs',
|
|
@@ -23,7 +22,7 @@ export function pontuarTailwind(src, _relPath) {
|
|
|
23
22
|
const match = metrica.match(/["']([^"']*)["']/);
|
|
24
23
|
return match ? match[1].split(/\s+/).filter(Boolean) : [];
|
|
25
24
|
}).flat();
|
|
26
|
-
const v3Deprecated = allClasses.filter(c =>
|
|
25
|
+
const v3Deprecated = allClasses.filter(c => c in V3_DEPRECATED_MAP);
|
|
27
26
|
if (v3Deprecated.length === 0) {
|
|
28
27
|
score += 5;
|
|
29
28
|
strengths.push('Sem classes obsoletas do v3');
|
|
@@ -40,8 +40,9 @@ export function comandoAnalistas() {
|
|
|
40
40
|
for (const arquivo of lista) {
|
|
41
41
|
const registroOriginal = registroAnalistas.find(raiz => raiz.nome === arquivo.nome);
|
|
42
42
|
let limitesStr = '';
|
|
43
|
-
if (registroOriginal
|
|
44
|
-
|
|
43
|
+
if (registroOriginal && 'limites' in registroOriginal && registroOriginal.limites) {
|
|
44
|
+
const limites = registroOriginal.limites;
|
|
45
|
+
limitesStr = Object.entries(limites).map(([chave, valor]) => `${chave}:${String(valor)}`).join('<br>');
|
|
45
46
|
}
|
|
46
47
|
linhas.push(messages.CliComandoAnalistasMensagens.docLinhaAnalista(arquivo.nome, arquivo.categoria, arquivo.descricao || '', limitesStr));
|
|
47
48
|
}
|
|
@@ -52,7 +52,7 @@ export function comandoFormatters() {
|
|
|
52
52
|
log.erro(FormattersMensagens.moduloInvalido(caminho));
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const formatter = { nome, ...mod.default, descricao: mod.default.descricao ?? '' };
|
|
55
|
+
const formatter = { nome, ...mod.default, descricao: mod.default.descricao ?? '', formato: mod.default.formato ?? 'json' };
|
|
56
56
|
registrarFormatter(formatter);
|
|
57
57
|
log.sucesso(FormattersMensagens.formatadorRegistrado(nome));
|
|
58
58
|
}
|
|
@@ -220,7 +220,7 @@ export function comandoGithubActions() {
|
|
|
220
220
|
sair(ExitCode.Failure);
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
|
-
const formato = opts.format;
|
|
223
|
+
const formato = (opts.format ?? 'json');
|
|
224
224
|
if (!['json', 'markdown', 'html', 'csv'].includes(formato)) {
|
|
225
225
|
log.erro(CliComandoGithubActionsMensagens.formatoInvalido(formato));
|
|
226
226
|
sair(ExitCode.Failure);
|
|
@@ -167,7 +167,7 @@ export function comandoGuardian(aplicarFlagsGlobais) {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
catch (err) {
|
|
170
|
-
logGuardian.erroGuardian(err.message);
|
|
170
|
+
logGuardian.erroGuardian(err instanceof Error ? err.message : String(err));
|
|
171
171
|
mostrarErroDev(err);
|
|
172
172
|
if (opts.json) {
|
|
173
173
|
console.log(JSON.stringify({ status: 'erro', mensagem: extrairMensagemErro(err) }));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { messages } from '../../core/messages/index.js';
|
|
4
4
|
import { ExitCode, sair } from '../helpers/index.js';
|
|
5
|
-
import { buscarPacotesInstalados, info
|
|
5
|
+
import { buscarPacotesInstalados, info, instalarPacote, listarPacotesInstalados, obterInfoPacote, removerPacote, resolverMelhorVersao, search } from '../../shared/marketplace/index.js';
|
|
6
6
|
const log = messages.log;
|
|
7
7
|
const msgs = messages.CliComandoMarketplaceMensagens;
|
|
8
8
|
export function comandoMarketplace() {
|
|
@@ -15,7 +15,7 @@ export function comandoMarketplace() {
|
|
|
15
15
|
.action(async (termo, opts) => {
|
|
16
16
|
try {
|
|
17
17
|
log.info(msgs.buscando(termo));
|
|
18
|
-
const { total, resultados } = await
|
|
18
|
+
const { total, resultados } = await search(termo);
|
|
19
19
|
if (opts.json) {
|
|
20
20
|
console.log(JSON.stringify({ total, resultados }, null, 2));
|
|
21
21
|
return;
|
|
@@ -48,7 +48,7 @@ export function comandoMarketplace() {
|
|
|
48
48
|
log.info(msgs.jaInstalado(nome, instalado.versao));
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
const analista = await
|
|
51
|
+
const analista = await info(nome);
|
|
52
52
|
if (!analista) {
|
|
53
53
|
log.erro(msgs.analistaNaoEncontrado(nome));
|
|
54
54
|
sair(ExitCode.Failure);
|
|
@@ -122,7 +122,7 @@ export function comandoMarketplace() {
|
|
|
122
122
|
.option('--json', msgs.jsonDescricao)
|
|
123
123
|
.action(async (nome, opts) => {
|
|
124
124
|
try {
|
|
125
|
-
const analista = await
|
|
125
|
+
const analista = await info(nome);
|
|
126
126
|
const local = await obterInfoPacote(nome);
|
|
127
127
|
if (!analista && !local) {
|
|
128
128
|
log.erro(msgs.analistaNaoEncontrado(nome));
|
|
@@ -100,10 +100,9 @@ export function detectarTipoProjeto(baseDir = process.cwd()) {
|
|
|
100
100
|
export function getDefaultExcludes(tipoProjeto) {
|
|
101
101
|
// Tenta obter do mahoraga.config.json
|
|
102
102
|
const configIncluirExcluir = config.INCLUDE_EXCLUDE_RULES;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
103
|
+
const globalExclude = configIncluirExcluir.globalExcludeGlob;
|
|
104
|
+
if (Array.isArray(globalExclude) && globalExclude.length > 0) {
|
|
105
|
+
return Array.from(new Set(globalExclude));
|
|
107
106
|
}
|
|
108
107
|
// Fallback: usa padrões do sistema baseado no tipo de projeto
|
|
109
108
|
const tipo = tipoProjeto ?? detectarTipoProjeto();
|
|
@@ -162,16 +161,17 @@ export function processarFiltros(opcoes) {
|
|
|
162
161
|
*/
|
|
163
162
|
export function aplicarFiltrosAoConfig(filtros) {
|
|
164
163
|
// Configurar includes
|
|
164
|
+
const cfg = config;
|
|
165
165
|
if (filtros.includeFlat.length > 0) {
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
cfg.CLI_INCLUDE_GROUPS = filtros.includeGroups;
|
|
167
|
+
cfg.CLI_INCLUDE_PATTERNS = filtros.includeFlat;
|
|
168
168
|
}
|
|
169
169
|
else {
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
cfg.CLI_INCLUDE_GROUPS = [];
|
|
171
|
+
cfg.CLI_INCLUDE_PATTERNS = [];
|
|
172
172
|
}
|
|
173
173
|
// Configurar excludes
|
|
174
|
-
|
|
174
|
+
cfg.CLI_EXCLUDE_PATTERNS = filtros.excludePadroes;
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
177
|
* API simplificada: processa e aplica filtros em uma única chamada
|
|
@@ -12,7 +12,7 @@ function getSourceFns(x) {
|
|
|
12
12
|
}
|
|
13
13
|
const src = x;
|
|
14
14
|
const pick = (chave) => {
|
|
15
|
-
const valor = src[chave];
|
|
15
|
+
const valor = (src)[chave];
|
|
16
16
|
return typeof valor === 'function' ? valor : undefined;
|
|
17
17
|
};
|
|
18
18
|
return {
|
|
@@ -38,7 +38,7 @@ function makeChalkLike(src) {
|
|
|
38
38
|
dim: src.dim ?? ID
|
|
39
39
|
};
|
|
40
40
|
const attachBoldChain = (colorFn) => {
|
|
41
|
-
const fn = (
|
|
41
|
+
const fn = (string) => colorFn(string);
|
|
42
42
|
// suporte a encadeamento como chalk.cyan.bold(...)
|
|
43
43
|
fn.bold = ((string) => colorFn(base.bold(string)));
|
|
44
44
|
return fn;
|
|
@@ -49,9 +49,9 @@ function makeChalkLike(src) {
|
|
|
49
49
|
const yellow = attachBoldChain(base.yellow);
|
|
50
50
|
const magenta = attachBoldChain(base.magenta);
|
|
51
51
|
const gray = attachBoldChain(base.gray);
|
|
52
|
-
const dim = (
|
|
52
|
+
const dim = (string) => base.dim(string); // dim sem encadeamento usado
|
|
53
53
|
// bold em si (sem necessidade de cor encadeada no projeto)
|
|
54
|
-
const bold = (
|
|
54
|
+
const bold = (string) => base.bold(string);
|
|
55
55
|
// Opcional: permitir bold.cyan(...), caso apareça futuramente
|
|
56
56
|
bold.cyan = ((string) => base.cyan(base.bold(string)));
|
|
57
57
|
bold.green = ((string) => base.green(base.bold(string)));
|
|
@@ -64,7 +64,7 @@ export const configPadrao = {
|
|
|
64
64
|
'.deprecados/**', '**/deprecados/**', '.pensando/**', '**/pensando/**',
|
|
65
65
|
'**/.mahoraga/**', 'mahoraga/**',
|
|
66
66
|
'**/*.log', '**/*.lock', 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml',
|
|
67
|
-
'**/.git/**',
|
|
67
|
+
'**/.git/**', 'next/**',
|
|
68
68
|
]
|
|
69
69
|
},
|
|
70
70
|
// ─── Scanner & Extensões ──────────────────────────────────────
|
|
@@ -236,9 +236,9 @@ function converterConfigSimplificada(config) {
|
|
|
236
236
|
javascript: { parser: 'babel', plugin: 'core' },
|
|
237
237
|
typescript: { parser: 'babel', plugin: 'core' },
|
|
238
238
|
html: { parser: 'htmlparser2', plugin: 'core' },
|
|
239
|
-
css: { parser: '
|
|
240
|
-
scss: { parser: '
|
|
241
|
-
sass: { parser: '
|
|
239
|
+
css: { parser: 'postcss', plugin: 'core' },
|
|
240
|
+
scss: { parser: 'postcss', plugin: 'core' },
|
|
241
|
+
sass: { parser: 'postcss', plugin: 'core' },
|
|
242
242
|
xml: { parser: 'fast-xml-parser', plugin: 'core' },
|
|
243
243
|
php: { parser: 'heuristic', plugin: 'core' },
|
|
244
244
|
python: { parser: 'heuristic', plugin: 'core' },
|
|
@@ -288,7 +288,7 @@ function converterConfigSimplificada(config) {
|
|
|
288
288
|
function sincronizarIgnorados() {
|
|
289
289
|
const dyn = config.INCLUDE_EXCLUDE_RULES;
|
|
290
290
|
const glob = Array.isArray(dyn.globalExcludeGlob) ? dyn.globalExcludeGlob : [];
|
|
291
|
-
Array.from(new Set(glob
|
|
291
|
+
Array.from(new Set(glob));
|
|
292
292
|
const cfg = config;
|
|
293
293
|
delete cfg.ZELADOR_IGNORE_PATTERNS;
|
|
294
294
|
delete cfg.GUARDIAN_IGNORE_PATTERNS;
|
|
@@ -57,9 +57,7 @@ export class ScopeAstCache {
|
|
|
57
57
|
relPath: entry.relPath,
|
|
58
58
|
});
|
|
59
59
|
if (parsed && typeof parsed === 'object') {
|
|
60
|
-
|
|
61
|
-
ast = AST_SENTINEL;
|
|
62
|
-
}
|
|
60
|
+
ast = AST_SENTINEL;
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
63
|
this.metrics.parseTimeMs += performance.now() - inicio;
|
|
@@ -12,7 +12,7 @@ import { analysisCache } from './analysis-cache.js';
|
|
|
12
12
|
import { ScopeAstCache } from './ast-cache.js';
|
|
13
13
|
import { ocorrenciaErroAnalista } from '../../types/index.js';
|
|
14
14
|
async function withTimeout(value, timeoutMs, errorMessage) {
|
|
15
|
-
let timer
|
|
15
|
+
let timer;
|
|
16
16
|
try {
|
|
17
17
|
return await Promise.race([
|
|
18
18
|
Promise.resolve(value),
|
|
@@ -22,9 +22,7 @@ async function withTimeout(value, timeoutMs, errorMessage) {
|
|
|
22
22
|
]);
|
|
23
23
|
}
|
|
24
24
|
finally {
|
|
25
|
-
|
|
26
|
-
clearTimeout(timer);
|
|
27
|
-
}
|
|
25
|
+
clearTimeout(timer);
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
function getGlobalExec() {
|
|
@@ -39,7 +39,7 @@ export async function scanRepository(baseDir, options = {}) {
|
|
|
39
39
|
const excludePadroesNorm = ensureStringArray(config.CLI_EXCLUDE_PATTERNS).map(caminho => toPosix((caminho || '')));
|
|
40
40
|
// [PIN] ÚNICO PONTO DE EXCLUDE: globalExcludeGlob da configuração legacy ou campo simplificado
|
|
41
41
|
const legacyExcludes = config.INCLUDE_EXCLUDE_RULES.globalExcludeGlob ?? [];
|
|
42
|
-
const ignorePadroesNorm = ensureStringArray(legacyExcludes).map((caminho) => toPosix((caminho || '')));
|
|
42
|
+
const ignorePadroesNorm = ensureStringArray([...legacyExcludes]).map((caminho) => toPosix((caminho || '')));
|
|
43
43
|
const hasIncluir = includeGroupsNorm.length > 0 || includePadroesNorm.length > 0;
|
|
44
44
|
// Sinaliza quando os includes pedem ocorrências em qualquer profundidade (ex.: '**/nome/**') ou quando
|
|
45
45
|
// o usuário forneceu nomes simples (que o expandIncludes converte em '**/nome/**').
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
export const RelatorioCircleciMensagens = {
|
|
3
3
|
tituloPadrao: 'Analysis Report - CircleCI',
|
|
4
|
-
repositorio: (
|
|
5
|
-
data: (
|
|
6
|
-
tempo: (
|
|
4
|
+
repositorio: (...args) => `**Repository:** ${String(args[0])}`,
|
|
5
|
+
data: (...args) => `**Date:** ${String(args[0])}`,
|
|
6
|
+
tempo: (...args) => `**Time:** ${args[0]}ms`,
|
|
7
7
|
resumo: '## Summary',
|
|
8
|
-
scoreGeral: (
|
|
9
|
-
totalConfigs: (
|
|
10
|
-
totalOcorrencias: (
|
|
8
|
+
scoreGeral: (...args) => `| Overall Score | ${args[0]}/100 |`,
|
|
9
|
+
totalConfigs: (...args) => `| Total Configs | ${args[0]} |`,
|
|
10
|
+
totalOcorrencias: (...args) => `| Total Occurrences | ${args[0]} |`,
|
|
11
11
|
severidade: '## Severity',
|
|
12
12
|
configsAnalisadas: '## Configs Analyzed',
|
|
13
13
|
ocorrenciasDetalhadas: '## Detailed Occurrences',
|
|
14
14
|
geradoPor: '*Generated by Mahoraga v0.7.0*',
|
|
15
|
-
formatoNaoSuportado: (
|
|
15
|
+
formatoNaoSuportado: (...args) => `Unsupported format: ${args[0]}`,
|
|
16
16
|
schemaJson: 'mahoraga://schemas/circleci-report/v1',
|
|
17
17
|
versao: '0.7.0',
|
|
18
18
|
csvCabecalho: 'File,Line,Severity,Type,Message,Suggestion',
|
|
@@ -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
|
* Caretaker Messages
|
|
7
7
|
*
|
|
8
8
|
* Centralizes all messages related to caretakers (auto-fix)
|
|
9
9
|
* including: imports, types, structure, etc.
|
|
10
10
|
*/
|
|
11
|
-
/**
|
|
12
|
-
* Icons and emojis used by caretakers
|
|
13
|
-
*/
|
|
14
|
-
const ICONES_ZELADOR = {
|
|
15
|
-
...ICONES_ZELADOR_CENTRAL
|
|
16
|
-
};
|
|
17
11
|
/**
|
|
18
12
|
* Import Caretaker Messages
|
|
19
13
|
*/
|
|
@@ -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
|
// 正当化: ゼラドーメッセージ用のインライン型
|
|
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
|
*/
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
export const RelatorioCircleciMensagens = {
|
|
3
3
|
tituloPadrao: 'Relatório de Análise - CircleCI',
|
|
4
|
-
repositorio: (
|
|
5
|
-
data: (
|
|
6
|
-
tempo: (
|
|
4
|
+
repositorio: (...args) => `**Repositório:** ${String(args[0])}`,
|
|
5
|
+
data: (...args) => `**Data:** ${String(args[0])}`,
|
|
6
|
+
tempo: (...args) => `**Tempo:** ${args[0]}ms`,
|
|
7
7
|
resumo: '## Resumo',
|
|
8
|
-
scoreGeral: (
|
|
9
|
-
totalConfigs: (
|
|
10
|
-
totalOcorrencias: (
|
|
8
|
+
scoreGeral: (...args) => `| Score Geral | ${args[0]}/100 |`,
|
|
9
|
+
totalConfigs: (...args) => `| Total de Configs | ${args[0]} |`,
|
|
10
|
+
totalOcorrencias: (...args) => `| Total de Ocorrências | ${args[0]} |`,
|
|
11
11
|
severidade: '## Severidade',
|
|
12
12
|
configsAnalisadas: '## Configs Analisadas',
|
|
13
13
|
ocorrenciasDetalhadas: '## Ocorrências Detalhadas',
|
|
14
14
|
geradoPor: '*Gerado por Mahoraga v0.7.0*',
|
|
15
|
-
formatoNaoSuportado: (
|
|
15
|
+
formatoNaoSuportado: (...args) => `Formato não suportado: ${args[0]}`,
|
|
16
16
|
schemaJson: 'mahoraga://schemas/circleci-report/v1',
|
|
17
17
|
versao: '0.7.0',
|
|
18
18
|
csvCabecalho: 'Arquivo,Linha,Severidade,Tipo,Mensagem,Sugestao',
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
// @mahoraga-disable tipo-literal-inline-complexo
|
|
3
3
|
// Justificativa: tipos inline para mensagens de zeladores
|
|
4
|
-
import { ICONES_ACAO, ICONES_STATUS, ICONES_ZELADOR
|
|
4
|
+
import { ICONES_ACAO, ICONES_STATUS, ICONES_ZELADOR } from '../../shared/icons.js';
|
|
5
5
|
/**
|
|
6
6
|
* Mensagens dos Zeladores
|
|
7
7
|
*
|
|
8
8
|
* Centraliza todas as mensagens relacionadas aos zeladores (auto-fix)
|
|
9
9
|
* incluindo: imports, tipos, estrutura, etc.
|
|
10
10
|
*/
|
|
11
|
-
/**
|
|
12
|
-
* Ícones e emojis usados pelos zeladores
|
|
13
|
-
*/
|
|
14
|
-
const ICONES_ZELADOR = {
|
|
15
|
-
...ICONES_ZELADOR_CENTRAL
|
|
16
|
-
};
|
|
17
11
|
/**
|
|
18
12
|
* Mensagens do Zelador de Imports
|
|
19
13
|
*/
|
|
@@ -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
|
*/
|
|
@@ -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';
|
|
@@ -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
|
})();
|
|
Binary file
|
package/dist/guardian/records.js
CHANGED
|
@@ -6,6 +6,7 @@ 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
8
|
const DESTINO_PADRAO = path.join(config.STATE_DIR, 'integridade.json');
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
9
10
|
function getLog() {
|
|
10
11
|
const { log, GuardianMensagens } = getMessages();
|
|
11
12
|
return { log, GuardianMensagens };
|
|
@@ -7,6 +7,7 @@ import { config } from '../core/config/index.js';
|
|
|
7
7
|
import { getMessages } from '../core/messages/index.js';
|
|
8
8
|
import { ensureDir, normalizePath } from '../shared/helpers/index.js';
|
|
9
9
|
import { GuardianError, IntegridadeStatus } from '../types/index.js';
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
10
11
|
function getLog() {
|
|
11
12
|
const { log, GuardianMensagens } = getMessages();
|
|
12
13
|
return { log, GuardianMensagens };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
import { carregarRegistros, inicializarChaves, REGISTRO_VIGIA_CAMINHO_PADRAO, salvarRegistros, verificarAssinatura } from './index.js';
|
|
3
3
|
import { getMessages } from '../core/messages/index.js';
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
4
5
|
function getLog() {
|
|
5
6
|
const { log, VigiaOcultaMensagens } = getMessages();
|
|
6
7
|
return { log, VigiaOcultaMensagens };
|
|
@@ -23,8 +23,9 @@ export function readPackageJsonSync(pkgCaminho) {
|
|
|
23
23
|
try {
|
|
24
24
|
const data = fs.readFileSync(pkgCaminho, 'utf8');
|
|
25
25
|
const parsed = JSON.parse(data);
|
|
26
|
-
if (typeof parsed !== 'object' || parsed === null)
|
|
26
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
27
27
|
return null;
|
|
28
|
+
}
|
|
28
29
|
return parsed;
|
|
29
30
|
}
|
|
30
31
|
catch {
|
package/dist/licenses/index.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
export { addDisclaimer, disclaimerModule, verifyDisclaimer } from './disclaimer.js';
|
|
6
6
|
export * from './fs-utils.js';
|
|
7
7
|
export { generateNotices } from './generate-notices.js';
|
|
8
|
+
export * from './header-options.js';
|
|
8
9
|
export * from './licenses.js';
|
|
9
10
|
export * from './normalizer.js';
|
|
10
11
|
export { checkLicenseStatus, DEFAULT_LICENSE_POLICY } from './policy.js';
|
|
11
12
|
export * from './scanner.js';
|
|
12
13
|
export * from './types.js';
|
|
13
|
-
export * from './header-options.js';
|
|
@@ -25,9 +25,9 @@ export async function gerarRelatorioMarkdown(resultado, outputCaminho, modoBrief
|
|
|
25
25
|
});
|
|
26
26
|
// Extrair dados do Guardian
|
|
27
27
|
const guardianData = guardian && typeof guardian === 'object' ? {
|
|
28
|
-
status: 'status' in guardian ?
|
|
29
|
-
timestamp: 'timestamp' in guardian ?
|
|
30
|
-
totalArquivos: 'totalArquivos' in guardian ?
|
|
28
|
+
status: 'status' in guardian ? guardian.status : 'não executada',
|
|
29
|
+
timestamp: 'timestamp' in guardian ? guardian.timestamp : '-',
|
|
30
|
+
totalArquivos: 'totalArquivos' in guardian ? guardian.totalArquivos : '-'
|
|
31
31
|
} : {
|
|
32
32
|
status: 'não executada',
|
|
33
33
|
timestamp: '-',
|
|
@@ -10,7 +10,7 @@ export function exibirRelatorioPadroesUso() {
|
|
|
10
10
|
const titulo = 'Padrões de Uso do Código';
|
|
11
11
|
const linhas = [];
|
|
12
12
|
const logComBloco = log;
|
|
13
|
-
const largura = logComBloco.calcularLargura
|
|
13
|
+
const largura = logComBloco.calcularLargura(titulo, linhas, 84);
|
|
14
14
|
logComBloco.imprimirBloco(titulo, linhas, (string) => string, typeof largura === 'number' ? largura : 84);
|
|
15
15
|
}
|
|
16
16
|
// Rodapé compatível com testes
|