LINT: Switch whitelist check from egrep to awk
authorLoïc Blot <loic.blot@unix-experience.fr>
Thu, 6 Apr 2017 14:03:29 +0000 (16:03 +0200)
committerLoic Blot <loic.blot@unix-experience.fr>
Thu, 6 Apr 2017 21:21:40 +0000 (23:21 +0200)
Bonus: make CI happy with the last rules fix

src/client/keys.h
src/environment.cpp
src/gameparams.h
src/gettime.h
src/script/lua_api/l_client.cpp
util/travis/lint.sh

index b446d3a1e87e5408ad19d737b1f68401d594ee9d..76ae38ff0aacea92cb5d746e6ad9c104337a3b94 100644 (file)
@@ -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,
index d1ea5f8bba7a159a5fe12ad5eb1f090d742a2e9b..9c2ea88963338771984d271dac6df37e928ec764 100644 (file)
@@ -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),
index bf9953c39173b8f8d62194f404eb7dc1160f0798..4afc0fdce0001c3814d42ca0fc9334f1673e610b 100644 (file)
@@ -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;
index 6e70b85338b7a72b55bd20376dcef6a9a785a68c..b2f09a7bb9ee7882aa35b3eee969a9b21a670c6a 100644 (file)
@@ -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,
index 0f4d7eaae4a5bfc58334f53cd6b2999f3e40b3b4..be3a749deef4bd28a599c57900ffb9dbb3a57923 100644 (file)
@@ -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;
                }
index c1df2d5fa5310795bd44660a71627b71fbe8d9db..4e816bd94e402b76b98e6ee7456846a266937836 100644 (file)
@@ -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"