-
Notifications
You must be signed in to change notification settings - Fork 0
feat(DVT-1005): corrige falsos positivos e exibe priority das violacoes CodeNarc #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(DVT-1005): corrige falsos positivos e exibe priority das violacoes CodeNarc #66
Conversation
|
🏷️ [bumpr] |
Wiz Scan SummaryDisplaying only findings that violated a policy
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
| name="$4" | ||
| filter_mode="$5" | ||
| level="$6" | ||
| $includes_arg >/dev/null 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| -name="codenarc" \ | ||
| -filter-mode="${INPUT_FILTER_MODE}" \ | ||
| -level="${INPUT_LEVEL}" \ | ||
| ${INPUT_REVIEWDOG_FLAGS} >/dev/null || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| -name="codenarc" \ | ||
| -filter-mode="${INPUT_FILTER_MODE}" \ | ||
| -level="${INPUT_LEVEL}" \ | ||
| ${INPUT_REVIEWDOG_FLAGS} >/dev/null || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| -name="codenarc" \ | ||
| -filter-mode="nofilter" \ | ||
| -level="warning" \ | ||
| ${INPUT_REVIEWDOG_FLAGS} >/dev/null || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| name="$4" | ||
| filter_mode="$5" | ||
| level="$6" | ||
| $includes_arg >/dev/null 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[shellcheck (suggestion)] reported by reviewdog 🐶
| $includes_arg >/dev/null 2>&1 | |
| "$includes_arg" >/dev/null 2>&1 |
| -name="codenarc" \ | ||
| -filter-mode="${INPUT_FILTER_MODE}" \ | ||
| -level="${INPUT_LEVEL}" \ | ||
| ${INPUT_REVIEWDOG_FLAGS} >/dev/null || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[shellcheck (suggestion)] reported by reviewdog 🐶
| ${INPUT_REVIEWDOG_FLAGS} >/dev/null || true | |
| "${INPUT_REVIEWDOG_FLAGS}" >/dev/null || true |
| -name="codenarc" \ | ||
| -filter-mode="${INPUT_FILTER_MODE}" \ | ||
| -level="${INPUT_LEVEL}" \ | ||
| ${INPUT_REVIEWDOG_FLAGS} >/dev/null || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[shellcheck (suggestion)] reported by reviewdog 🐶
| ${INPUT_REVIEWDOG_FLAGS} >/dev/null || true | |
| "${INPUT_REVIEWDOG_FLAGS}" >/dev/null || true |
| -name="codenarc" \ | ||
| -filter-mode="nofilter" \ | ||
| -level="warning" \ | ||
| ${INPUT_REVIEWDOG_FLAGS} >/dev/null || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[shellcheck (suggestion)] reported by reviewdog 🐶
| ${INPUT_REVIEWDOG_FLAGS} >/dev/null || true | |
| "${INPUT_REVIEWDOG_FLAGS}" >/dev/null || true |
Impacto
Esta alteração corrige falsos positivos no bloqueio de merge do
codenarc-actione aprimora a exibição da prioridade das violações do CodeNarc nos logs.Problema anterior:
compactdo CodeNarc não fornecia a prioridade individualmente.Solução implementada:
priority) de cada violação.jqfoi integrado para extrair seletivamente as violações de Prioridade 1 (P1) do relatório JSON e formatá-las em um output compacto.[P1],[P2],[P3], facilitando a identificação e a depuração.reviewdogprocessa o output formatado (agora contendo a prioridade) utilizandoerrorformat(-efm). Violações baseadas em linha são reportadas comogithub-pr-reviewe violações baseadas em arquivo comogithub-pr-check.Observação sobre SARIF:
A utilização do formato SARIF do CodeNarc, embora inicialmente considerada e um padrão mais robusto, foi adiada. O suporte a SARIF no CodeNarc é uma funcionalidade muito recente (implementada na branch
mastere sem uma versão estável/tag liberada no momento). Para garantir a estabilidade e evitar dependências em funcionalidades instáveis, optou-se por uma abordagem alternativa robusta que atinge os mesmos objetivos de precisão e exibição de prioridade, utilizando as versões estáveis existentes do CodeNarc e Reviewdog.Link da tarefa no JIRA
https://asaas.atlassian.net/browse/DVT-1005
Mudanças técnicas:
3.6.0-groovy3.0.23. A configuração de output foi alterada paraJSONpara incluir apriorityde cada violação.v0.13.0. A integração é feita viaerrorformat(-efm), sem a necessidade de suporte direto a SARIF.jqpara o parseamento do JSON do CodeNarc. O scriptentrypoint.shtevechmod +xadicionado.entrypoint.sh:convert_json_to_compactque utilizajqpara formatar o JSON em um formato legível, incluindo a prioridade ([P1]).check_blocking_rulesfoi revisada para extrair apenas P1s do JSON, verificar sua presença em linhas alteradas e bloquear o merge de forma precisa.reviewdogé alimentado foi adaptada para o formato compacto (errorformat).Cenários testados
✅ Bloqueio correto (sem falsos positivos)
Cenário 1: P1 fora do diff + P2 dentro → NÃO deve bloquear ✅
https://github.com/asaasdev/test-workflows-run/pull/907
https://github.com/asaasdev/test-workflows-run/actions/runs/21264924084/job/61290272849?pr=907
Cenário 2: P1 dentro do diff → DEVE bloquear ❌
https://github.com/asaasdev/test-workflows-run/pull/908
https://github.com/asaasdev/test-workflows-run/actions/runs/21265632030/job/61290264034?pr=908
Cenário 3: Apenas P2 → NÃO deve bloquear ✅
https://github.com/asaasdev/test-workflows-run/pull/914
https://github.com/asaasdev/test-workflows-run/actions/runs/21293863565/job/61294428119?pr=914
Cenário 4: Violação file-based (PackageName) → Detectar corretamente
https://github.com/asaasdev/test-workflows-run/pull/915
https://github.com/asaasdev/test-workflows-run/actions/runs/21293864534/job/61294431297?pr=915
https://github.com/asaasdev/test-workflows-run/runs/61294483610
Cenário 5: Múltiplas P1 - algumas dentro, outras fora do diff → DEVE bloquear ❌
https://github.com/asaasdev/test-workflows-run/pull/916
https://github.com/asaasdev/test-workflows-run/actions/runs/21293865641/job/61294435683?pr=916
Cenário 6: Modo local (sem git diff)
✅ Logs exibem priority
[P1],[P2],[P3]arquivo:linha:Regra Mensagem [PX]✅ Reviewdog funciona
github-pr-review)github-pr-check)-reporter=local✅ Casos especiais