mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 13:32:13 +00:00
Added a check for double whitespaces
This commit is contained in:
parent
e40c05fde0
commit
b42f85e16b
@ -28,3 +28,6 @@ find $ROOT_PATH/dbms -name '*.h' -or -name '*.cpp' |
|
|||||||
|
|
||||||
# Broken symlinks
|
# Broken symlinks
|
||||||
find -L $ROOT_PATH -type l | grep -v contrib && echo "^ Broken symlinks found"
|
find -L $ROOT_PATH -type l | 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
|
||||||
|
33
utils/check-style/double-whitespaces.pl
Executable file
33
utils/check-style/double-whitespaces.pl
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
my @array;
|
||||||
|
|
||||||
|
while (<>)
|
||||||
|
{
|
||||||
|
push @array, $_;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $ret = 0;
|
||||||
|
|
||||||
|
for (my $i = 1; $i < $#array; ++$i)
|
||||||
|
{
|
||||||
|
if ($array[$i] =~ ',( {2,3})[^ /]')
|
||||||
|
{
|
||||||
|
# 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
|
||||||
|
&& (substr($array[$i + 1], $+[1] - 1, 2) !~ /^[ -][^ ]$/)
|
||||||
|
&& $array[$i] !~ /(-?\d+\w*,\s+){3,}/) # this is not a number table like { 10, -1, 2 }
|
||||||
|
{
|
||||||
|
print(($i + 1) . ":" . $array[$i]);
|
||||||
|
$ret = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit $ret;
|
Loading…
Reference in New Issue
Block a user