Skip to content

Commit 47d5b3c

Browse files
Add link to table
1 parent 73f9d26 commit 47d5b3c

1 file changed

Lines changed: 36 additions & 7 deletions

File tree

tidy.sh

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,32 @@ write_step_summary() {
177177
errors=$(awk -F'\t' '$1=="error"{c++} END{print c+0}' "${findings_tsv}")
178178
total=$((warnings + errors))
179179

180+
# Render a check name as a markdown link to its official clang-tidy docs page
181+
# (mirrors what cpp-linter-action used to do). The canonical URL layout is
182+
# https://clang.llvm.org/extra/clang-tidy/checks/<module>/<rest>.html
183+
# where <module> is everything up to the first '-'. Two categories don't
184+
# follow that layout:
185+
# * clang-diagnostic-* -- compiler diagnostics, no per-check doc page
186+
# * clang-analyzer-* -- static analyzer, documented on a single page
187+
# Those fall back to plain code formatting / the analyzer index page.
188+
check_link() {
189+
local name="$1"
190+
local module="${name%%-*}"
191+
local rest="${name#*-}"
192+
case "${name}" in
193+
clang-diagnostic-*)
194+
printf '`%s`' "${name}"
195+
;;
196+
clang-analyzer-*)
197+
printf '[`%s`](https://clang.llvm.org/docs/analyzer/checkers.html)' "${name}"
198+
;;
199+
*)
200+
printf '[`%s`](https://clang.llvm.org/extra/clang-tidy/checks/%s/%s.html)' \
201+
"${name}" "${module}" "${rest}"
202+
;;
203+
esac
204+
}
205+
180206
{
181207
echo "## clang-tidy results"
182208
echo
@@ -193,19 +219,22 @@ write_step_summary() {
193219
echo '|-------|-------|'
194220
awk -F'\t' '{print $5}' "${findings_tsv}" \
195221
| sort | uniq -c | sort -rn | head -5 \
196-
| awk '{ n = $1; $1 = ""; sub(/^ /, ""); printf("| `%s` | %d |\n", $0, n) }'
222+
| while read -r count name; do
223+
printf '| %s | %d |\n' "$(check_link "${name}")" "${count}"
224+
done
197225
echo
198226

199227
echo "<details><summary>All ${total} findings</summary>"
200228
echo
201229
echo '| Severity | File | Check | Message |'
202230
echo '|----------|------|-------|---------|'
203-
awk -F'\t' '{
204-
sev = $1; path = $2; lineno = $3; check = $5; msg = $6
205-
gsub(/\|/, "\\|", msg)
206-
icon = (sev == "error") ? "error" : "warning"
207-
printf("| %s | `%s:%s` | `%s` | %s |\n", icon, path, lineno, check, msg)
208-
}' "${findings_tsv}"
231+
while IFS=$'\t' read -r sev path lineno col check msg; do
232+
msg="${msg//|/\\|}"
233+
local icon
234+
icon=$([[ "${sev}" == "error" ]] && echo error || echo warning)
235+
printf '| %s | `%s:%s` | %s | %s |\n' \
236+
"${icon}" "${path}" "${lineno}" "$(check_link "${check}")" "${msg}"
237+
done < "${findings_tsv}"
209238
echo
210239
echo "</details>"
211240
echo

0 commit comments

Comments
 (0)