From 3a90b78a037df3eb9098d4fddb1289ed8ee21329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Thu, 6 Apr 2017 16:03:29 +0200 Subject: [PATCH] LINT: Switch whitelist check from egrep to awk Bonus: make CI happy with the last rules fix --- src/client/keys.h | 3 ++- src/environment.cpp | 1 + src/gameparams.h | 3 ++- src/gettime.h | 3 ++- src/script/lua_api/l_client.cpp | 4 ++-- util/travis/lint.sh | 5 +++-- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/client/keys.h b/src/client/keys.h index b446d3a1e..76ae38ff0 100644 --- a/src/client/keys.h +++ b/src/client/keys.h @@ -25,7 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc., class KeyType { public: - enum T { + enum T + { // Player movement FORWARD, BACKWARD, diff --git a/src/environment.cpp b/src/environment.cpp index d1ea5f8bb..9c2ea8896 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "daynightratio.h" #include "emerge.h" + Environment::Environment(IGameDef *gamedef): m_time_of_day_speed(0), m_time_of_day(9000), diff --git a/src/gameparams.h b/src/gameparams.h index bf9953c39..4afc0fdce 100644 --- a/src/gameparams.h +++ b/src/gameparams.h @@ -24,7 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc., struct SubgameSpec; -struct GameParams { +struct GameParams +{ u16 socket_port; std::string world_path; SubgameSpec game_spec; diff --git a/src/gettime.h b/src/gettime.h index 6e70b8533..b2f09a7bb 100644 --- a/src/gettime.h +++ b/src/gettime.h @@ -31,7 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc., Normal build: main.cpp Server build: servermain.cpp */ -enum TimePrecision { +enum TimePrecision +{ PRECISION_SECONDS = 0, PRECISION_MILLI, PRECISION_MICRO, diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 0f4d7eaae..be3a749de 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -212,8 +212,8 @@ int ModApiClient::l_sound_play(lua_State *L) if (!lua_isnil(L, -1)) { v3f pos = read_v3f(L, -1) * BS; lua_pop(L, 1); - handle = - sound->playSoundAt(spec.name, looped, gain * spec.gain, pos); + handle = sound->playSoundAt( + spec.name, looped, gain * spec.gain, pos); lua_pushinteger(L, handle); return 1; } diff --git a/util/travis/lint.sh b/util/travis/lint.sh index c1df2d5fa..4e816bd94 100644 --- a/util/travis/lint.sh +++ b/util/travis/lint.sh @@ -6,6 +6,7 @@ function perform_lint() { else CLANG_FORMAT=clang-format fi + echo "LINT: Using binary $CLANG_FORMAT" CLANG_FORMAT_WHITELIST="util/travis/clang-format-whitelist.txt" if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then @@ -22,10 +23,10 @@ function perform_lint() { d=$(diff -u "$f" <(${CLANG_FORMAT} "$f") || true) if ! [ -z "$d" ]; then - whitelisted=$(egrep -c "^${f}" "${CLANG_FORMAT_WHITELIST}") + whitelisted=$(awk '$1 == "'$f'" { print 1 }' "$CLANG_FORMAT_WHITELIST") # If file is not whitelisted, mark a failure - if [ ${whitelisted} -eq 0 ]; then + if [ -z ${whitelisted} ]; then errorcount=$((errorcount+1)) printf "The file %s is not compliant with the coding style" "$f"