mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #60496 from Algunenano/double-whitespaces
Speedup check-whitespaces check
This commit is contained in:
commit
079e916c8e
@ -50,11 +50,6 @@ find $ROOT_PATH/{src,base,programs,utils} -name '*.h' -or -name '*.cpp' 2>/dev/n
|
|||||||
# Broken symlinks
|
# Broken symlinks
|
||||||
find -L $ROOT_PATH -type l 2>/dev/null | 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/{src,base,programs,utils} -name '*.h' -or -name '*.cpp' 2>/dev/null |
|
|
||||||
grep -vP $EXCLUDE_DIRS |
|
|
||||||
while read i; do $ROOT_PATH/utils/check-style/double-whitespaces.pl < $i || echo -e "^ File $i contains double whitespaces\n"; done
|
|
||||||
|
|
||||||
# Unused/Undefined/Duplicates ErrorCodes/ProfileEvents/CurrentMetrics
|
# Unused/Undefined/Duplicates ErrorCodes/ProfileEvents/CurrentMetrics
|
||||||
declare -A EXTERN_TYPES
|
declare -A EXTERN_TYPES
|
||||||
EXTERN_TYPES[ErrorCodes]=int
|
EXTERN_TYPES[ErrorCodes]=int
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
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/|Parsers/New'
|
EXCLUDE_DIRS='build/|integration/|widechar_width/|glibc-compatibility/|memcpy/|consistent-hashing/|Parsers/New'
|
||||||
|
NPROC=$(($(nproc) + 3))
|
||||||
|
|
||||||
# Double whitespaces
|
# Double whitespaces
|
||||||
find $ROOT_PATH/{src,base,programs,utils} -name '*.h' -or -name '*.cpp' 2>/dev/null |
|
find $ROOT_PATH/{src,base,programs,utils} -name '*.h' -or -name '*.cpp' 2>/dev/null |
|
||||||
grep -vP $EXCLUDE_DIRS |
|
grep -vP $EXCLUDE_DIRS |
|
||||||
while read i; do $ROOT_PATH/utils/check-style/double-whitespaces.pl < $i || echo -e "^ File $i contains double whitespaces\n"; done
|
xargs -P "$NPROC" -n 20 "${ROOT_PATH}/utils/check-style/double-whitespaces.pl"
|
||||||
|
@ -5,27 +5,31 @@ use strict;
|
|||||||
# Find double whitespace such as "a, b, c" that looks very ugly and annoying.
|
# Find double whitespace such as "a, b, c" that looks very ugly and annoying.
|
||||||
# But skip double whitespaces if they are used as an alignment - by comparing to surrounding lines.
|
# But skip double whitespaces if they are used as an alignment - by comparing to surrounding lines.
|
||||||
|
|
||||||
my @array;
|
|
||||||
|
|
||||||
while (<>)
|
|
||||||
{
|
|
||||||
push @array, $_;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $ret = 0;
|
my $ret = 0;
|
||||||
|
|
||||||
for (my $i = 1; $i < $#array; ++$i)
|
foreach my $file (@ARGV)
|
||||||
{
|
{
|
||||||
if ($array[$i] =~ ',( {2,3})[^ /]')
|
my @array;
|
||||||
{
|
|
||||||
# https://stackoverflow.com/questions/87380/how-can-i-find-the-location-of-a-regex-match-in-perl
|
|
||||||
|
|
||||||
if ((substr($array[$i - 1], $+[1] - 1, 2) !~ /^[ -][^ ]$/) # whitespaces are not part of alignment
|
open (FH,'<',$file);
|
||||||
&& (substr($array[$i + 1], $+[1] - 1, 2) !~ /^[ -][^ ]$/)
|
while (<FH>)
|
||||||
&& $array[$i] !~ /(-?\d+\w*,\s+){3,}/) # this is not a number table like { 10, -1, 2 }
|
{
|
||||||
|
push @array, $_;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (my $i = 1; $i < $#array; ++$i)
|
||||||
|
{
|
||||||
|
if ($array[$i] =~ ',( {2,3})[^ /]')
|
||||||
{
|
{
|
||||||
print(($i + 1) . ":" . $array[$i]);
|
# https://stackoverflow.com/questions/87380/how-can-i-find-the-location-of-a-regex-match-in-perl
|
||||||
$ret = 1;
|
|
||||||
|
if ((substr($array[$i - 1], $+[1] - 1, 2) !~ /^[ -][^ ]$/) # whitespaces are not part of alignment
|
||||||
|
&& (substr($array[$i + 1], $+[1] - 1, 2) !~ /^[ -][^ ]$/)
|
||||||
|
&& $array[$i] !~ /(-?\d+\w*,\s+){3,}/) # this is not a number table like { 10, -1, 2 }
|
||||||
|
{
|
||||||
|
print($file . ":" . ($i + 1) . $array[$i]);
|
||||||
|
$ret = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user