LINT: Switch whitelist check from egrep to awk

Bonus: make CI happy with the last rules fix
This commit is contained in:
Loïc Blot 2017-04-06 16:03:29 +02:00 committed by Loic Blot
parent 88b9b9652a
commit 3a90b78a03
No known key found for this signature in database
GPG Key ID: EFAA458E8C153987
6 changed files with 12 additions and 7 deletions

@ -25,7 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class KeyType class KeyType
{ {
public: public:
enum T { enum T
{
// Player movement // Player movement
FORWARD, FORWARD,
BACKWARD, BACKWARD,

@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "daynightratio.h" #include "daynightratio.h"
#include "emerge.h" #include "emerge.h"
Environment::Environment(IGameDef *gamedef): Environment::Environment(IGameDef *gamedef):
m_time_of_day_speed(0), m_time_of_day_speed(0),
m_time_of_day(9000), m_time_of_day(9000),

@ -24,7 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct SubgameSpec; struct SubgameSpec;
struct GameParams { struct GameParams
{
u16 socket_port; u16 socket_port;
std::string world_path; std::string world_path;
SubgameSpec game_spec; SubgameSpec game_spec;

@ -31,7 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Normal build: main.cpp Normal build: main.cpp
Server build: servermain.cpp Server build: servermain.cpp
*/ */
enum TimePrecision { enum TimePrecision
{
PRECISION_SECONDS = 0, PRECISION_SECONDS = 0,
PRECISION_MILLI, PRECISION_MILLI,
PRECISION_MICRO, PRECISION_MICRO,

@ -212,8 +212,8 @@ int ModApiClient::l_sound_play(lua_State *L)
if (!lua_isnil(L, -1)) { if (!lua_isnil(L, -1)) {
v3f pos = read_v3f(L, -1) * BS; v3f pos = read_v3f(L, -1) * BS;
lua_pop(L, 1); lua_pop(L, 1);
handle = handle = sound->playSoundAt(
sound->playSoundAt(spec.name, looped, gain * spec.gain, pos); spec.name, looped, gain * spec.gain, pos);
lua_pushinteger(L, handle); lua_pushinteger(L, handle);
return 1; return 1;
} }

@ -6,6 +6,7 @@ function perform_lint() {
else else
CLANG_FORMAT=clang-format CLANG_FORMAT=clang-format
fi fi
echo "LINT: Using binary $CLANG_FORMAT"
CLANG_FORMAT_WHITELIST="util/travis/clang-format-whitelist.txt" CLANG_FORMAT_WHITELIST="util/travis/clang-format-whitelist.txt"
if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then
@ -22,10 +23,10 @@ function perform_lint() {
d=$(diff -u "$f" <(${CLANG_FORMAT} "$f") || true) d=$(diff -u "$f" <(${CLANG_FORMAT} "$f") || true)
if ! [ -z "$d" ]; then 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 file is not whitelisted, mark a failure
if [ ${whitelisted} -eq 0 ]; then if [ -z ${whitelisted} ]; then
errorcount=$((errorcount+1)) errorcount=$((errorcount+1))
printf "The file %s is not compliant with the coding style" "$f" printf "The file %s is not compliant with the coding style" "$f"