Skip to content

Commit

Permalink
Use clang-tidy to check more code conventions (cuberite#4214)
Browse files Browse the repository at this point in the history
* Create clang-tidy.sh
* Add clang-tidy to circle.yml
* Fixed some naming violations

Fixes cuberite#4164
  • Loading branch information
Bond-009 authored and peterbell10 committed May 6, 2018
1 parent fbf5cf7 commit b9fdaf8
Show file tree
Hide file tree
Showing 13 changed files with 224 additions and 168 deletions.
17 changes: 17 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Checks: '-*,readability-identifier-naming'
CheckOptions:
- key: readability-identifier-naming.PrivateMemberPrefix
value: 'm_'
- key: readability-identifier-naming.ClassConstantCase
value: aNy_CasE
# an empty *Prefix needs a *Case to work
- key: readability-identifier-naming.ClassConstantPrefix
value: ''
#- key: readability-identifier-naming.PrivateMemberCase
# value: CamelCase
#- key: readability-identifier-naming.FunctionCase
# value: CamelCase
#- key: readability-identifier-naming.EnumCase
# value: camelBack
WarningsAsErrors: '*'
HeaderFilterRegex: '/cuberite/src/\.?[^\.]'
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ Server/cuberite_api.lua
Server/official_undocumented.lua
Server/NewlyUndocumented.lua
Server/.luacheckrc
compile_commands.json

# compile.sh folder
build-cuberite

# clang-tidy
tidy-build
run-clang-tidy.py
10 changes: 9 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@

dependencies:
pre:
- sudo apt-get install lua5.1
- sudo apt-get update
- sudo apt-get install lua5.1 cmake clang-3.9 clang-tidy-3.9
- sudo ln -s /usr/bin/clang-tidy-3.9 /usr/bin/clang-tidy
- sudo ln -s /usr/bin/clang-apply-replacements-3.9 /usr/bin/clang-apply-replacements
- pip install PyYAML

test:
override:
- cd src && find . -name \*.cpp -or -name \*.h > AllFiles.lst && lua CheckBasicStyle.lua
- cd src/Bindings && lua CheckBindingsDependencies.lua
- curl -o "$HOME/bin/run-clang-tidy.py" "https://raw.githubusercontent.com/llvm-mirror/clang-tools-extra/45fb9b20ed7da2f6b95d83e5ef45bb536f49d8ca/clang-tidy/tool/run-clang-tidy.py"
- chmod +x "$HOME/bin/run-clang-tidy.py"
- git submodule update --init
- ./clang-tidy.sh
19 changes: 19 additions & 0 deletions clang-tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

set -e

FIXES_FILE="tidy-fixes.yaml"
REGEX="/cuberite/src/\.?[^\.]"
# TODO: Add -quiet when Circle CI is updated to 2.0 with a newer version of Ubuntu
ARGS="-header-filter $REGEX -export-fixes $FIXES_FILE "$@" $REGEX"

mkdir -p tidy-build
cd tidy-build
cmake --target Cuberite -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..

if run-clang-tidy.py $ARGS; then
echo "clang-tidy: No violations found"
else
echo "clang-tidy: Found violations"
exit 1
fi
Loading

0 comments on commit b9fdaf8

Please sign in to comment.