Skip to content

Commit 77912ab

Browse files
committed
Fix check_style for using namespace std exclusing in test/*
1 parent fe1f9c6 commit 77912ab

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

scripts/check_style.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,27 @@ FORMATERROR=$(
8585
# unqualified move()/forward() checks, i.e. make sure that std::move() and std::forward() are used instead of move() and forward()
8686
preparedGrep "move\(.+\)" | grep -v "std::move" | grep -E "[^a-z]move"
8787
preparedGrep "forward\(.+\)" | grep -v "std::forward" | grep -E "[^a-z]forward"
88+
) | grep -E -v -e "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" -e "^test/" || true
89+
)
90+
91+
# Special error handling for `using namespace std;` exclusion, since said statement can be present in the test directory
92+
# and its subdirectories, but is excluded in the above ruleset. In order to have consistent codestyle with regards to
93+
# std namespace usage, test directory must also be covered.
94+
FORMATSTDERROR=$(
95+
(
8896
# make sure `using namespace std` is not used in INCLUDE_DIRECTORIES
8997
# shellcheck disable=SC2068,SC2068
9098
grep -nIE -d skip "using namespace std;" ${NAMESPACE_STD_FREE_FILES[@]}
91-
) | grep -E -v -e "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" -e "^test/" || true
99+
) || true
92100
)
93101

94-
if [[ "$FORMATERROR" != "" ]]
102+
# Merge errors into single string
103+
FORMATEDERRORS="$FORMATERROR$FORMATSTDERROR"
104+
105+
if [[ "$FORMATEDERRORS" != "" ]]
95106
then
96107
echo "Coding style error:" | tee -a "$ERROR_LOG"
97-
echo "$FORMATERROR" | tee -a "$ERROR_LOG"
108+
echo "$FORMATEDERRORS" | tee -a "$ERROR_LOG"
98109
scripts/ci/post_style_errors_on_github.sh "$ERROR_LOG"
99110
exit 1
100111
fi

0 commit comments

Comments
 (0)