Skip to content

Commit 6d8fa39

Browse files
authored
Add 'GCOVR_*' markers to the blacklist and refactor 'nolint-check' job (#682)
1 parent d493e73 commit 6d8fa39

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

.github/workflows/static-analysis-pr.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,25 @@ jobs:
140140
exit 0
141141
fi
142142
143+
markers=(
144+
"NOLINT::Found 'NOLINT'"
145+
"IWYU[[:space:]]+pragma::Found 'IWYU pragma'"
146+
"LCOV_EXCL_START::Found 'LCOV_EXCL_START'"
147+
"LCOV_EXCL_STOP::Found 'LCOV_EXCL_STOP'"
148+
"GCOVR_EXCL_LINE::Found 'GCOVR_EXCL_LINE'"
149+
"GCOVR_EXCL_START::Found 'GCOVR_EXCL_START'"
150+
"GCOVR_EXCL_STOP::Found 'GCOVR_EXCL_STOP'"
151+
)
152+
143153
for file in $CHANGED_FILES; do
144-
if grep -q "NOLINT" "$file"; then
145-
echo "::error::Found 'NOLINT' in $file."
146-
exit 1
147-
fi
148-
if grep -Eq 'IWYU[[:space:]]+pragma' "$file"; then
149-
echo "::error::Found 'IWYU pragma' in $file."
150-
exit 1
151-
fi
152-
if grep -q "LCOV_EXCL_START" "$file"; then
153-
echo "::error::Found 'LCOV_EXCL_START' in $file."
154-
exit 1
155-
fi
156-
if grep -q "LCOV_EXCL_STOP" "$file"; then
157-
echo "::error::Found 'LCOV_EXCL_STOP' in $file."
158-
exit 1
159-
fi
154+
for marker in "${markers[@]}"; do
155+
pattern="${marker%%::*}"
156+
message="${marker#*::}"
157+
if grep -Eq "$pattern" "$file"; then
158+
echo "::error::${message} in $file."
159+
exit 1
160+
fi
161+
done
160162
done
161163
162164
echo "No linter suppression markers found in changed files."

0 commit comments

Comments
 (0)