Skip to content

Commit c000247

Browse files
author
Cameron Custer
committed
grep check: exclude comment lines from macro checks (docstrings spell out macros)
1 parent 4a45aae commit c000247

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tests/scripts/grep_clangformat_cppcheck.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@ grep "endl" --recursive library_checker_aizu_tests/ && exit 1
1313
echo "check template<class T> over template<typename T>:"
1414
grep --extended-regexp "template\s?<typename" --recursive ../library/ && exit 1
1515

16+
# comment lines are excluded from the macro checks below: doc
17+
# comments spell out the macros to match the expanded main branch
18+
comment_line="^[^:]*:[[:space:]]*//"
19+
1620
echo "check ll instead of long long or int64_t"
17-
grep "long long" --recursive ../library/ && exit 1
18-
grep "int64_t" --recursive ../library/**/*.hpp | grep "uint64_t" --invert-match && exit 1
21+
grep "long long" --recursive ../library/ | grep --invert-match --extended-regexp "$comment_line" && exit 1
22+
grep "int64_t" --recursive ../library/**/*.hpp | grep "uint64_t" --invert-match | grep --invert-match --extended-regexp "$comment_line" && exit 1
1923

2024
echo "check pii instead of pair<int, int>"
21-
grep "pair<int, int>" --recursive ../library/**/*.hpp && exit 1
25+
grep "pair<int, int>" --recursive ../library/**/*.hpp | grep --invert-match --extended-regexp "$comment_line" && exit 1
2226

2327
echo "check sz instead of ssize"
24-
grep "ssize" --recursive ../library/ && exit 1
28+
grep "ssize" --recursive ../library/ | grep --invert-match --extended-regexp "$comment_line" && exit 1
2529

2630
echo "check vi instead of vector<int>"
27-
grep "vector<int>" --recursive ../library/**/*.hpp && exit 1
31+
grep "vector<int>" --recursive ../library/**/*.hpp | grep --invert-match --extended-regexp "$comment_line" && exit 1
2832

2933
echo "check begin(arr) instead of arr.begin(), similarly for end, rbegin, rend, empty, size:"
3034
grep --recursive ../library/ library_checker_aizu_tests/ --fixed-strings --regexp=".begin()" --regexp=".rbegin()" --regexp=".end()" --regexp=".rend()" --regexp=".empty()" --regexp=".size()" && exit 1

0 commit comments

Comments
 (0)