-
Notifications
You must be signed in to change notification settings - Fork 858
feature: clang-tidy&format #10209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: clang-tidy&format #10209
Changes from 37 commits
5c88149
87570a8
54ce5de
641e1dd
38b22b3
971ba6b
5e61964
dd0b8d4
7cb37d4
6b9b233
6c5fb46
a7e444a
cb50c1a
7f4fd0a
258b7b5
a69db53
91ac241
91893eb
6bca460
e61eab5
3865544
93da1ef
d620df1
26a1309
80c5221
3445b73
8381617
756b95e
75d2fb8
221802c
0a86b0a
fcabfda
6041650
b49ecbb
1e52aad
c367fa1
27bd703
b5a75ad
b3009ed
4d152a3
087e704
8be3f31
42ee81f
c8e583f
f06b680
4c102da
723f850
2345c5b
f4c7205
04e90b7
433ccfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/compile_commands.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
set -u | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this like clang-format-diff ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No - This checks the clang version to be used. But instead of using the logic provided by franks awesome find command one could have come up with some regular expression for clang-format-diff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have changed the script to use clang-format-diff |
||
|
||
## locate executable | ||
clang_format="${ARANGODB_CLANG_FORMAT:-""}" | ||
clang_format_version="${ARANGODB_CLANG_FORMAT_VERSION:-"6.0.1"}" | ||
|
||
# fallback if nothing is found | ||
if [[ -z $clang_format ]]; then | ||
for candidate in "$HOME/.local/bin/clang-format" "clang-format-arangodb" "clang-format-6" "clang-format"; do | ||
echo "checking candidate $candidate" | ||
path="$(type -p ${candidate})" | ||
if [[ -n $path ]]; then | ||
clang_format="$path" | ||
echo "selecting this candidate" | ||
break; | ||
fi | ||
done | ||
else | ||
echo "clang-format provided by environment" | ||
fi | ||
|
||
# fallback if nothing is found | ||
if [[ -z $clang_format ]]; then | ||
echo "using fallback" | ||
clang_format="clang-format" | ||
fi | ||
|
||
## check version | ||
echo "checking version of $clang_format" | ||
version_string=$(${clang_format} --version) | ||
re=".*version ${clang_format_version}.*" | ||
if ! [[ $version_string =~ $re ]]; then | ||
echo "your version: '$version_string' does not match version 6.0.1" | ||
exit 1 | ||
fi | ||
|
||
|
||
## find relevant files | ||
files="$( | ||
find arangod arangosh lib enterprise \ | ||
-name Zip -prune -o \ | ||
-type f "(" -name "*.cpp" -o -name "*.h" ")" \ | ||
"!" "(" -name "tokens.*" -o -name "v8-json.*" -o -name "voc-errors.*" -o -name "grammar.*" -o -name "xxhash.*" -o -name "exitcodes.*" ")" | ||
)" | ||
|
||
git_files=$(git diff --name-only) | ||
files_final=() | ||
for gf in ${git_files[@]}; do | ||
echo "---------------------" | ||
for f in ${files[@]}; do | ||
echo "$gf -- $f" | ||
if [[ $gf == $f ]]; then | ||
files_final+=( "$f" ) | ||
continue | ||
fi | ||
done | ||
done | ||
|
||
# do final formatting | ||
${clang_format} -i -verbose -style=file ${files_final[@]} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
set -u | ||
|
||
# Make any failure in piped commands be reflected in the exit code. | ||
set -o pipefail | ||
|
||
readonly bash_source_dir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))" | ||
|
||
|
||
## locate executable | ||
clang_format="${ARANGODB_CLANG_FORMAT:-""}" | ||
clang_format_version="${ARANGODB_CLANG_FORMAT_VERSION:-"9.0.0"}" | ||
|
||
# fallback if nothing is found | ||
if [[ -z $clang_format ]]; then | ||
for candidate in "$HOME/.local/bin/clang-format" "clang-format-arangodb" "clang-format-9" "clang-format"; do | ||
echo "checking candidate $candidate" | ||
path="$(type -p ${candidate})" | ||
if [[ -n $path ]]; then | ||
clang_format="$path" | ||
echo "selecting this candidate" | ||
break; | ||
fi | ||
done | ||
else | ||
echo "clang-format provided by environment" | ||
fi | ||
|
||
# fallback if nothing is found | ||
if [[ -z $clang_format ]]; then | ||
echo "using fallback" | ||
clang_format="clang-format" | ||
fi | ||
|
||
## check version | ||
echo "checking version of $clang_format" | ||
version_string=$(${clang_format} --version) | ||
re=".*version ${clang_format_version}.*" | ||
if ! [[ $version_string =~ $re ]]; then | ||
echo "your version: '$version_string' does not match version 6.0.1" | ||
exit 1 | ||
fi | ||
|
||
|
||
diff="$(git diff -U0 --no-color HEAD^)" | ||
if type colordiff 2>/dev/null; then | ||
#need pipefail option | ||
${bash_source_dir}/lib/clang-format-diff.py --verbose -binary "${clang_format}" -style=file -p1 <<<"$diff" | colordiff -u3 | ||
else | ||
${bash_source_dir}/lib/clang-format-diff.py --verbose -binary "${clang_format}" -style=file -p1 <<<"$diff" | ||
fi | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
set -u | ||
|
||
## locate executable | ||
clang_format="${ARANGODB_CLANG_FORMAT:-""}" | ||
clang_format_version="${ARANGODB_CLANG_FORMAT_VERSION:-"6.0.1"}" | ||
|
||
# fallback if nothing is found | ||
if [[ -z $clang_format ]]; then | ||
for candidate in "$HOME/.local/bin/clang-format" "clang-format-arangodb" "clang-format-6" "clang-format"; do | ||
echo "checking candidate $candidate" | ||
path="$(type -p ${candidate})" | ||
if [[ -n $path ]]; then | ||
clang_format="$path" | ||
echo "selecting this candidate" | ||
break; | ||
fi | ||
done | ||
else | ||
echo "clang-format provided by environment" | ||
fi | ||
|
||
# fallback if nothing is found | ||
if [[ -z $clang_format ]]; then | ||
echo "using fallback" | ||
clang_format="clang-format" | ||
fi | ||
|
||
## check version | ||
echo "checking version of $clang_format" | ||
version_string=$(${clang_format} --version) | ||
re=".*version ${clang_format_version}.*" | ||
if ! [[ $version_string =~ $re ]]; then | ||
echo "your version: '$version_string' does not match version 6.0.1" | ||
exit 1 | ||
fi | ||
|
||
|
||
## find relevant files | ||
files="$( | ||
find arangod arangosh lib enterprise \ | ||
-name Zip -prune -o \ | ||
-type f "(" -name "*.cpp" -o -name "*.h" ")" \ | ||
"!" "(" -name "tokens.*" -o -name "v8-json.*" -o -name "voc-errors.*" -o -name "grammar.*" -o -name "xxhash.*" -o -name "exitcodes.*" ")" | ||
)" | ||
|
||
# do final formatting | ||
${clang_format} -i -verbose -style=file ${files[@]} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
#!/usr/bin/env bash | ||
set -u | ||
|
||
## locate executable | ||
clang_tidy="${ARANGODB_CLANG_TIDY:-""}" | ||
clang_tidy_version="${ARANGODB_CLANG_TIDY_VERSION:-"9.0.0"}" | ||
|
||
# fallback if nothing is found | ||
if [[ -z $clang_tidy ]]; then | ||
for candidate in "$HOME/.local/bin/clang-tidy" "clang-tidy-arangodb" "clang-tidy-9" "clang-tidy"; do | ||
echo "checking candidate $candidate" | ||
path="$(type -p ${candidate})" | ||
if [[ -n $path ]]; then | ||
clang_tidy="$path" | ||
echo "selecting this candidate" | ||
break; | ||
fi | ||
done | ||
else | ||
echo "clang-tidy provided by environment" | ||
fi | ||
|
||
# fallback if nothing is found | ||
if [[ -z $clang_tidy ]]; then | ||
echo "using fallback" | ||
clang_tidy="clang-tidy" | ||
fi | ||
|
||
## check version | ||
echo "checking version of $clang_tidy" | ||
version_string=$(${clang_tidy} --version) | ||
re=".*version ${clang_tidy_version}.*" | ||
if ! [[ $version_string =~ $re ]]; then | ||
echo "your version: '$version_string' does not match version 6.0.1" | ||
exit 1 | ||
fi | ||
|
||
## find relevant files | ||
#-type f "(" -name "*.cpp" -o -name "*.h" ")" \ | ||
files="$( | ||
find arangod arangosh lib enterprise \ | ||
-name Zip -prune -o \ | ||
-type f "(" -name "*.cpp" ")" \ | ||
"!" "(" -name "tokens.*" -o -name "v8-json.*" -o -name "voc-errors.*" -o -name "grammar.*" -o -name "xxhash.*" -o -name "exitcodes.*" ")" | ||
)" | ||
|
||
${clang_tidy} --quiet -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus* ${files} | ||
ObiWahn marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.