diff --git a/base/common/DateLUTImpl.h b/base/common/DateLUTImpl.h index 7f1e8c74313..2f2e431f950 100644 --- a/base/common/DateLUTImpl.h +++ b/base/common/DateLUTImpl.h @@ -391,9 +391,9 @@ public: /* The bits in week_mode has the following meaning: - WeekModeFlag::MONDAY_FIRST (0) If not set Sunday is first day of week - If set Monday is first day of week - WeekModeFlag::YEAR (1) If not set Week is in range 0-53 + WeekModeFlag::MONDAY_FIRST (0) If not set Sunday is first day of week + If set Monday is first day of week + WeekModeFlag::YEAR (1) If not set Week is in range 0-53 Week 0 is returned for the the last week of the previous year (for a date at start of january) In this case one can get 53 for the @@ -401,19 +401,19 @@ public: relevant for the given year. Note that this flag is only releveant if WeekModeFlag::JANUARY is not set. - If set Week is in range 1-53. + If set Week is in range 1-53. In this case one may get week 53 for a date in January (when the week is that last week of previous year) and week 1 for a date in December. - WeekModeFlag::FIRST_WEEKDAY (2) If not set Weeks are numbered according + WeekModeFlag::FIRST_WEEKDAY (2) If not set Weeks are numbered according to ISO 8601:1988 - If set The week that contains the first + If set The week that contains the first 'first-day-of-week' is week 1. - WeekModeFlag::NEWYEAR_DAY (3) If not set no meaning - If set The week that contains the January 1 is week 1. + WeekModeFlag::NEWYEAR_DAY (3) If not set no meaning + If set The week that contains the January 1 is week 1. Week is in range 1-53. And ignore WeekModeFlag::YEAR, WeekModeFlag::FIRST_WEEKDAY diff --git a/base/common/JSON.cpp b/base/common/JSON.cpp index 1d2c94e37ae..c6c0c843a16 100644 --- a/base/common/JSON.cpp +++ b/base/common/JSON.cpp @@ -399,7 +399,7 @@ JSON::Pos JSON::skipElement() const ElementType type = getType(); - switch(type) + switch (type) { case TYPE_NULL: return skipNull(); @@ -587,7 +587,7 @@ std::string JSON::getString() const ++s; checkPos(s); - switch(*s) + switch (*s) { case '"': buf += '"'; @@ -665,7 +665,7 @@ StringRef JSON::getRawString() const if (*s != '"') throw JSONException(std::string("JSON: expected \", got ") + *s); while (++s != ptr_end && *s != '"'); - if (s != ptr_end ) + if (s != ptr_end) return StringRef(ptr_begin + 1, s - ptr_begin - 1); throw JSONException("JSON: incorrect syntax (expected end of string, found end of JSON)."); } diff --git a/base/common/getMemoryAmount.cpp b/base/common/getMemoryAmount.cpp index fb5592d3aa3..a16a701bd8f 100644 --- a/base/common/getMemoryAmount.cpp +++ b/base/common/getMemoryAmount.cpp @@ -33,7 +33,7 @@ uint64_t getMemoryAmountOrZero() /* New 64-bit MEMORYSTATUSEX isn't available. Use old 32.bit */ MEMORYSTATUS status; status.dwLength = sizeof(status); - GlobalMemoryStatus( &status ); + GlobalMemoryStatus(&status); return status.dwTotalPhys; #elif defined(WIN32) || defined(_WIN32) @@ -41,7 +41,7 @@ uint64_t getMemoryAmountOrZero() /* Use new 64-bit MEMORYSTATUSEX, not old 32-bit MEMORYSTATUS */ MEMORYSTATUSEX status; status.dwLength = sizeof(status); - GlobalMemoryStatusEx( &status ); + GlobalMemoryStatusEx(&status); return status.ullTotalPhys; #else @@ -58,24 +58,24 @@ uint64_t getMemoryAmountOrZero() #endif uint64_t size = 0; /* 64-bit */ size_t len = sizeof(size); - if ( sysctl( mib, 2, &size, &len, NULL, 0 ) == 0 ) { + if (sysctl(mib, 2, &size, &len, NULL, 0) == 0) return size; - } + return 0; /* Failed? */ #elif defined(_SC_AIX_REALMEM) /* AIX. ----------------------------------------------------- */ - return sysconf( _SC_AIX_REALMEM ) * 1024; + return sysconf(_SC_AIX_REALMEM) * 1024; #elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) /* FreeBSD, Linux, OpenBSD, and Solaris. -------------------- */ - return (uint64_t)sysconf( _SC_PHYS_PAGES ) - * (uint64_t)sysconf( _SC_PAGESIZE ); + return (uint64_t)sysconf(_SC_PHYS_PAGES) + * (uint64_t)sysconf(_SC_PAGESIZE); #elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE) /* Legacy. -------------------------------------------------- */ - return (uint64_t)sysconf( _SC_PHYS_PAGES ) - * (uint64_t)sysconf( _SC_PAGE_SIZE ); + return (uint64_t)sysconf(_SC_PHYS_PAGES) + * (uint64_t)sysconf(_SC_PAGE_SIZE); #elif defined(CTL_HW) && (defined(HW_PHYSMEM) || defined(HW_REALMEM)) /* DragonFly BSD, FreeBSD, NetBSD, OpenBSD, and OSX. -------- */ @@ -87,10 +87,10 @@ uint64_t getMemoryAmountOrZero() mib[1] = HW_PHYSMEM; /* Others. ------------------ */ #endif unsigned int size = 0; /* 32-bit */ - size_t len = sizeof( size ); - if ( sysctl( mib, 2, &size, &len, NULL, 0 ) == 0 ) { + size_t len = sizeof(size); + if (sysctl(mib, 2, &size, &len, NULL, 0) == 0) return size; - } + return 0; /* Failed? */ #endif /* sysctl and sysconf variants */ diff --git a/base/daemon/src/BaseDaemon.cpp b/base/daemon/src/BaseDaemon.cpp index 9e614380722..b9e94d288d6 100644 --- a/base/daemon/src/BaseDaemon.cpp +++ b/base/daemon/src/BaseDaemon.cpp @@ -382,7 +382,7 @@ enum class InstructionFail static std::string instructionFailToString(InstructionFail fail) { - switch(fail) + switch (fail) { case InstructionFail::NONE: return "NONE"; diff --git a/base/ext/singleton.h b/base/ext/singleton.h index ed4be05de09..a58a0601335 100644 --- a/base/ext/singleton.h +++ b/base/ext/singleton.h @@ -2,7 +2,8 @@ #include -namespace ext { +namespace ext +{ template class Singleton diff --git a/utils/check-style/check-style b/utils/check-style/check-style index deed481f043..6848b8510de 100755 --- a/utils/check-style/check-style +++ b/utils/check-style/check-style @@ -13,21 +13,22 @@ # and then to run formatter only for the specified files. ROOT_PATH=$(git rev-parse --show-toplevel) +EXCLUDE_DIRS='build/|integration/|widechar_width/|glibc-compatibility/|memcpy/|consistent-hashing' -find $ROOT_PATH/dbms -name '*.h' -or -name '*.cpp' | - grep -vP 'Compiler|build' | +find $ROOT_PATH/{dbms,base} -name '*.h' -or -name '*.cpp' 2>/dev/null | + grep -vP $EXCLUDE_DIRS | xargs grep $@ -P '((class|struct|namespace|enum|if|for|while|else|throw|switch).*|\)(\s*const)?(\s*override)?\s*)\{$|\s$|\t|^ {1,3}[^\* ]\S|\t|^\s*(if|else if|if constexpr|else if constexpr|for|while|catch|switch)\(|\( [^\s\\]|\S \)' | # a curly brace not in a new line, but not for the case of C++11 init or agg. initialization | trailing whitespace | number of ws not a multiple of 4, but not in the case of comment continuation | a tab character | missing whitespace after for/if/while... before opening brace | whitespaces inside braces grep -v -P '(//|:\s+\*|\$\(\()| \)"' # single-line comment | continuation of a multiline comment | a typical piece of embedded shell code | something like ending of raw string literal # // namespace comments are unneeded -find $ROOT_PATH/dbms -name '*.h' -or -name '*.cpp' | - grep -vP 'Compiler|build' | +find $ROOT_PATH/{dbms,base} -name '*.h' -or -name '*.cpp' 2>/dev/null | + grep -vP $EXCLUDE_DIRS | xargs grep $@ -P '}\s*//+\s*namespace\s*' # Broken symlinks -find -L $ROOT_PATH -type l | grep -v contrib && echo "^ Broken symlinks found" +find -L $ROOT_PATH -type l 2>/dev/null | grep -v contrib && echo "^ Broken symlinks found" # Double whitespaces -find $ROOT_PATH/dbms -name '*.h' -or -name '*.cpp' | while read i; do $ROOT_PATH/utils/check-style/double-whitespaces.pl < $i || echo -e "^ File $i contains double whitespaces\n"; done +find $ROOT_PATH/{dbms,base} -name '*.h' -or -name '*.cpp' 2>/dev/null | while read i; do $ROOT_PATH/utils/check-style/double-whitespaces.pl < $i || echo -e "^ File $i contains double whitespaces\n"; done