Fix check-style #9161

This commit is contained in:
Alexey Milovidov 2020-02-17 22:09:56 +03:00
parent 146109fe27
commit c76ff369bb
6 changed files with 33 additions and 31 deletions

View File

@ -399,7 +399,7 @@ JSON::Pos JSON::skipElement() const
ElementType type = getType(); ElementType type = getType();
switch(type) switch (type)
{ {
case TYPE_NULL: case TYPE_NULL:
return skipNull(); return skipNull();
@ -587,7 +587,7 @@ std::string JSON::getString() const
++s; ++s;
checkPos(s); checkPos(s);
switch(*s) switch (*s)
{ {
case '"': case '"':
buf += '"'; buf += '"';
@ -665,7 +665,7 @@ StringRef JSON::getRawString() const
if (*s != '"') if (*s != '"')
throw JSONException(std::string("JSON: expected \", got ") + *s); throw JSONException(std::string("JSON: expected \", got ") + *s);
while (++s != ptr_end && *s != '"'); while (++s != ptr_end && *s != '"');
if (s != ptr_end ) if (s != ptr_end)
return StringRef(ptr_begin + 1, s - ptr_begin - 1); return StringRef(ptr_begin + 1, s - ptr_begin - 1);
throw JSONException("JSON: incorrect syntax (expected end of string, found end of JSON)."); throw JSONException("JSON: incorrect syntax (expected end of string, found end of JSON).");
} }

View File

@ -33,7 +33,7 @@ uint64_t getMemoryAmountOrZero()
/* New 64-bit MEMORYSTATUSEX isn't available. Use old 32.bit */ /* New 64-bit MEMORYSTATUSEX isn't available. Use old 32.bit */
MEMORYSTATUS status; MEMORYSTATUS status;
status.dwLength = sizeof(status); status.dwLength = sizeof(status);
GlobalMemoryStatus( &status ); GlobalMemoryStatus(&status);
return status.dwTotalPhys; return status.dwTotalPhys;
#elif defined(WIN32) || defined(_WIN32) #elif defined(WIN32) || defined(_WIN32)
@ -41,7 +41,7 @@ uint64_t getMemoryAmountOrZero()
/* Use new 64-bit MEMORYSTATUSEX, not old 32-bit MEMORYSTATUS */ /* Use new 64-bit MEMORYSTATUSEX, not old 32-bit MEMORYSTATUS */
MEMORYSTATUSEX status; MEMORYSTATUSEX status;
status.dwLength = sizeof(status); status.dwLength = sizeof(status);
GlobalMemoryStatusEx( &status ); GlobalMemoryStatusEx(&status);
return status.ullTotalPhys; return status.ullTotalPhys;
#else #else
@ -58,24 +58,24 @@ uint64_t getMemoryAmountOrZero()
#endif #endif
uint64_t size = 0; /* 64-bit */ uint64_t size = 0; /* 64-bit */
size_t len = sizeof(size); 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 size;
}
return 0; /* Failed? */ return 0; /* Failed? */
#elif defined(_SC_AIX_REALMEM) #elif defined(_SC_AIX_REALMEM)
/* AIX. ----------------------------------------------------- */ /* AIX. ----------------------------------------------------- */
return sysconf( _SC_AIX_REALMEM ) * 1024; return sysconf(_SC_AIX_REALMEM) * 1024;
#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) #elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
/* FreeBSD, Linux, OpenBSD, and Solaris. -------------------- */ /* FreeBSD, Linux, OpenBSD, and Solaris. -------------------- */
return (uint64_t)sysconf( _SC_PHYS_PAGES ) return (uint64_t)sysconf(_SC_PHYS_PAGES)
* (uint64_t)sysconf( _SC_PAGESIZE ); * (uint64_t)sysconf(_SC_PAGESIZE);
#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE) #elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE)
/* Legacy. -------------------------------------------------- */ /* Legacy. -------------------------------------------------- */
return (uint64_t)sysconf( _SC_PHYS_PAGES ) return (uint64_t)sysconf(_SC_PHYS_PAGES)
* (uint64_t)sysconf( _SC_PAGE_SIZE ); * (uint64_t)sysconf(_SC_PAGE_SIZE);
#elif defined(CTL_HW) && (defined(HW_PHYSMEM) || defined(HW_REALMEM)) #elif defined(CTL_HW) && (defined(HW_PHYSMEM) || defined(HW_REALMEM))
/* DragonFly BSD, FreeBSD, NetBSD, OpenBSD, and OSX. -------- */ /* DragonFly BSD, FreeBSD, NetBSD, OpenBSD, and OSX. -------- */
@ -87,10 +87,10 @@ uint64_t getMemoryAmountOrZero()
mib[1] = HW_PHYSMEM; /* Others. ------------------ */ mib[1] = HW_PHYSMEM; /* Others. ------------------ */
#endif #endif
unsigned int size = 0; /* 32-bit */ unsigned int size = 0; /* 32-bit */
size_t len = sizeof( size ); 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 size;
}
return 0; /* Failed? */ return 0; /* Failed? */
#endif /* sysctl and sysconf variants */ #endif /* sysctl and sysconf variants */

View File

@ -382,7 +382,7 @@ enum class InstructionFail
static std::string instructionFailToString(InstructionFail fail) static std::string instructionFailToString(InstructionFail fail)
{ {
switch(fail) switch (fail)
{ {
case InstructionFail::NONE: case InstructionFail::NONE:
return "NONE"; return "NONE";

View File

@ -2,7 +2,8 @@
#include <memory> #include <memory>
namespace ext { namespace ext
{
template <class T> template <class T>
class Singleton class Singleton

View File

@ -13,21 +13,22 @@
# and then to run formatter only for the specified files. # and then to run formatter only for the specified files.
ROOT_PATH=$(git rev-parse --show-toplevel) 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' | find $ROOT_PATH/{dbms,base} -name '*.h' -or -name '*.cpp' 2>/dev/null |
grep -vP 'Compiler|build' | 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 \)' | 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 # 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+\*|\$\(\()| \)"' 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 # 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 # // namespace comments are unneeded
find $ROOT_PATH/dbms -name '*.h' -or -name '*.cpp' | find $ROOT_PATH/{dbms,base} -name '*.h' -or -name '*.cpp' 2>/dev/null |
grep -vP 'Compiler|build' | grep -vP $EXCLUDE_DIRS |
xargs grep $@ -P '}\s*//+\s*namespace\s*' xargs grep $@ -P '}\s*//+\s*namespace\s*'
# Broken symlinks # 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 # 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