Skip to content

Commit

Permalink
Fix check format script to recognize source files
Browse files Browse the repository at this point in the history
Previously, all source files were passed to clang-format as a SINGLE file,
resulting in clang-format reporting an error due to "no such file or directory."
  • Loading branch information
Lai-YT authored and leewei05 committed Sep 9, 2023
1 parent 70d4efc commit dd6370e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions scripts/check-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

SOURCES=$(find "$(git rev-parse --show-toplevel)" | grep -E "\.(c|h)pp\$")

# reports violations
clang-format --dry-run "${SOURCES}"

VIOLATION_COUNT="$(clang-format --output-replacements-xml "${SOURCES}" | grep -E -c "</replacement>")"
exit "$VIOLATION_COUNT"
total_violation_count=0
for file in $SOURCES; do
# reports violations
clang-format --dry-run "$file"
# count violations
violation_count=$(clang-format --output-replacements-xml "$file" | grep -E -c "</replacement>")
total_violation_count=$((total_violation_count + violation_count))
done
exit "$total_violation_count"

0 comments on commit dd6370e

Please sign in to comment.