add validation tools
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: Google
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
AlignConsecutiveAssignments: true
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
ColumnLimit: 96
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
SortIncludes: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
Standard: Cpp11
|
||||||
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. "$(dirname "$0")/isTopLevel.sh"
|
||||||
|
|
||||||
|
for f in $(git ls-files | grep -E '.*\.(cc|h)$'); do
|
||||||
|
echo "formatting ${f}"
|
||||||
|
clang-format -i "${f}"
|
||||||
|
done
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(pwd)" != "$(git rev-parse --show-toplevel)" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. "$(dirname "$0")/../isTopLevel.sh"
|
||||||
|
|
||||||
|
RETVAL=0
|
||||||
|
|
||||||
|
for f in $(git ls-files | grep -E '.*\.(cc|h)$'); do
|
||||||
|
if ! clang-format "${f}" | diff "${f}" - > /dev/null 2>&1; then
|
||||||
|
echo "Error: Invalid code formatting in ${f}" >&2
|
||||||
|
RETVAL=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $RETVAL
|
||||||
Executable
+25
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. "$(dirname "$0")/../isTopLevel.sh"
|
||||||
|
|
||||||
|
RETVAL=0
|
||||||
|
|
||||||
|
for f in $(git ls-files | grep -E '^src\/.*\.h$'); do
|
||||||
|
# ファイルパスから正しいインクルードガードの文字列を生成する
|
||||||
|
s1="$(echo "$f" | sed -r 's/^src\///; s/[\/\.-]+/_/g; s/^.*$/\U&/')_"
|
||||||
|
|
||||||
|
# ファイルからインクルードガードを読み込む
|
||||||
|
s2=$(grep -Pzo '#ifndef\s+\K\b(\w+)\b(?=\s+#define\s+\b\1\b)' "$f" | tr '\0' '\n')
|
||||||
|
|
||||||
|
if [ -z "$s2" ]; then
|
||||||
|
echo "error: $f: include guard is missing or incorrect" >&2
|
||||||
|
echo " ($s1)" >&2
|
||||||
|
RETVAL=1
|
||||||
|
elif [ "$s2" != "$s1" ]; then
|
||||||
|
echo "error: $f: include guard is incorrect" >&2
|
||||||
|
echo " ($s2 => $s1)" >&2
|
||||||
|
RETVAL=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $RETVAL
|
||||||
Reference in New Issue
Block a user