@@ -12,7 +12,8 @@ CHANGED_FILES_CACHE="/tmp/changed_files.txt"
1212
1313cleanup_temp_files () {
1414 rm -f " $CODENARC_RESULT " " $LINE_VIOLATIONS " " $FILE_VIOLATIONS " " $VIOLATIONS_FLAG " \
15- " $ALL_DIFF " " $CHANGED_LINES_CACHE " " $CHANGED_FILES_CACHE " > /dev/null 2>&1
15+ " $ALL_DIFF " " $CHANGED_LINES_CACHE " " $CHANGED_FILES_CACHE " \
16+ " ${FILE_VIOLATIONS} .formatted" > /dev/null 2>&1
1617}
1718
1819trap ' cleanup_temp_files' EXIT
@@ -51,8 +52,16 @@ run_reviewdog_with_config() {
5152}
5253
5354separate_violations () {
55+ echo " 🔍 DEBUG: Conteúdo completo do CODENARC_RESULT:"
56+ echo " --- INÍCIO ---"
57+ cat " $CODENARC_RESULT "
58+ echo " --- FIM ---"
59+
60+ # Capturar violações line-based (formato: arquivo:linha:regra)
5461 grep -E ' :[0-9]+:' " $CODENARC_RESULT " > " $LINE_VIOLATIONS " || true
55- grep -E ' :null:' " $CODENARC_RESULT " > " $FILE_VIOLATIONS " || true
62+
63+ # Capturar violações file-based (ambos os formatos: :null: e ||)
64+ grep -E ' :null:|\|\|' " $CODENARC_RESULT " > " $FILE_VIOLATIONS " || true
5665
5766 echo " 🔍 DEBUG: Line violations encontradas:"
5867 [ -s " $LINE_VIOLATIONS " ] && head -3 " $LINE_VIOLATIONS " || echo " Nenhuma"
@@ -69,15 +78,28 @@ run_reviewdog() {
6978 if [ -s " $LINE_VIOLATIONS " ]; then
7079 echo " 📤 Enviando violações com linha (${INPUT_REPORTER:- github-pr-check} )..."
7180 run_reviewdog_with_config " $LINE_VIOLATIONS " " %f:%l:%m" \
72- " ${INPUT_REPORTER:- github-pr-check} " " codenarc-lines " \
81+ " ${INPUT_REPORTER:- github-pr-check} " " codenarc" \
7382 " ${INPUT_FILTER_MODE} " " ${INPUT_LEVEL} "
7483 fi
7584
7685 # Violações file-based forçando github-pr-check
7786 if [ -s " $FILE_VIOLATIONS " ]; then
7887 echo " 📤 Enviando violações file-based (github-pr-check)..."
79- run_reviewdog_with_config " $FILE_VIOLATIONS " " %f:%l:%m" \
80- " github-pr-check" " codenarc-files" " nofilter" " warning"
88+
89+ # Criar arquivo temporário com formato correto para reviewdog
90+ > " ${FILE_VIOLATIONS} .formatted"
91+ while read -r violation; do
92+ if echo " $violation " | grep -q ' ||' ; then
93+ # Formato CI: arquivo||regra mensagem -> arquivo::regra mensagem
94+ echo " $violation " | sed ' s/||/::/'
95+ else
96+ # Formato local: arquivo:null:regra mensagem -> arquivo::regra mensagem
97+ echo " $violation " | sed ' s/:null:/::/'
98+ fi
99+ done < " $FILE_VIOLATIONS " > " ${FILE_VIOLATIONS} .formatted"
100+
101+ run_reviewdog_with_config " ${FILE_VIOLATIONS} .formatted" " %f::%m" \
102+ " github-pr-check" " codenarc" " nofilter" " warning"
81103 fi
82104
83105 # Fallback se não houver violações categorizadas
@@ -189,7 +211,12 @@ check_blocking_rules() {
189211
190212 echo " 0" > " $VIOLATIONS_FLAG "
191213
192- grep -E ' :[0-9]+:|:null:' " $CODENARC_RESULT " | while IFS=: read -r file line rest; do
214+ grep -E ' :[0-9]+:|:null:|\|\|' " $CODENARC_RESULT " | while IFS=: read -r file line rest; do
215+ # Tratar formato || (ambiente CI)
216+ if echo " $file " | grep -q ' ||' ; then
217+ file=$( echo " $file " | cut -d' |' -f1)
218+ line=" "
219+ fi
193220 [ -z " $file " ] && continue
194221 file_matches_patterns " $file " " $allowed_patterns " || continue
195222
0 commit comments