mirror of
https://github.com/curl/curl.git
synced 2026-07-24 13:07:16 +03:00
spacecheck: check long lines and repeat spaces, fix fallouts
Verify if lines are not longer than 192 characters. Also verify if lines have less than 79 repeat spaces (and fix one fallout). To improve readability by avoiding long lines and to prevent adding overly long lines with text that may go unnoticed in an editor or diff viewer. In addition to pre-existing line length limits: 79 for C, 132 for CMake sources. Also: - spacecheck: fix/harden allowlist regexes. - spacecheck: tidy-up quotes and simplify escaping. - spacecheck: allow folding strings with repeat spaces. - GHA: fix a suppressed shellcheck warning. - GHA/macos: simplify by dropping brew bundle. - test1119.pl: precompile a regex. - FAQ.md: delete very long link to a Windows 7/2008 support article that's lost it relevance. Closes #21087
This commit is contained in:
parent
ff3251a538
commit
62d77b12fc
28 changed files with 468 additions and 179 deletions
|
|
@ -173,7 +173,9 @@ sub HELP_MESSAGE() {
|
|||
print "\t-l\tprint license info about certdata.txt\n";
|
||||
print "\t-m\tinclude meta data in output\n";
|
||||
print "\t-n\tno download of certdata.txt (to use existing)\n";
|
||||
print wrap("\t","\t\t", "-p\tlist of Mozilla trust purposes and levels for certificates to include in output. Takes the form of a comma separated list of purposes, a colon, and a comma separated list of levels. (default: $default_mozilla_trust_purposes:$default_mozilla_trust_levels)"), "\n";
|
||||
print wrap("\t","\t\t", "-p\tlist of Mozilla trust purposes and levels for certificates to include in output. " .
|
||||
"Takes the form of a comma separated list of purposes, a colon, and a comma separated list of levels. " .
|
||||
"(default: $default_mozilla_trust_purposes:$default_mozilla_trust_levels)"), "\n";
|
||||
print "\t\t Valid purposes are:\n";
|
||||
print wrap("\t\t ","\t\t ", join(", ", "ALL", @valid_mozilla_trust_purposes)), "\n";
|
||||
print "\t\t Valid levels are:\n";
|
||||
|
|
|
|||
|
|
@ -27,24 +27,33 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
my @tabs = (
|
||||
"^m4/zz40-xc-ovr.m4",
|
||||
"Makefile\\.(am|example)\$",
|
||||
"\\.sln\$",
|
||||
"^tests/data/data1706-stdout.txt",
|
||||
"^tests/data/test",
|
||||
'^m4/zz40-xc-ovr\.m4$',
|
||||
'Makefile\.(am|example)$',
|
||||
'\.sln$',
|
||||
'^tests/data/data1706-stdout\.txt',
|
||||
'^tests/data/test',
|
||||
);
|
||||
|
||||
my @need_crlf = (
|
||||
"\\.(bat|sln)\$",
|
||||
'\.(bat|sln)$',
|
||||
);
|
||||
|
||||
my @double_empty_lines = (
|
||||
"RELEASE-NOTES",
|
||||
"^lib/.+\\.(c|h)\$",
|
||||
"^projects/OS400",
|
||||
"^projects/vms",
|
||||
"^tests/data/test",
|
||||
"\\.(m4|py)\$",
|
||||
'^RELEASE-NOTES$',
|
||||
'^lib/.+\.(c|h)$',
|
||||
'^projects/OS400/',
|
||||
'^projects/vms/',
|
||||
'^tests/data/test',
|
||||
'\.(m4|py)$',
|
||||
);
|
||||
|
||||
my @longline = (
|
||||
'\.github/workflows/windows\.yml$',
|
||||
'^renovate\.json$',
|
||||
'^docs/DISTROS\.md$',
|
||||
'^projects/Windows/tmpl/.+\.vcxproj$',
|
||||
'^tests/certs/srp-verifier-',
|
||||
'^tests/data/test',
|
||||
);
|
||||
|
||||
my @non_ascii_allowed = (
|
||||
|
|
@ -54,12 +63,12 @@ my @non_ascii_allowed = (
|
|||
my $non_ascii_allowed = join(', ', @non_ascii_allowed);
|
||||
|
||||
my @non_ascii = (
|
||||
".github/scripts/pyspelling.words",
|
||||
".mailmap",
|
||||
"RELEASE-NOTES",
|
||||
"docs/BINDINGS.md",
|
||||
"docs/THANKS",
|
||||
"docs/THANKS-filter",
|
||||
'^\.github/scripts/pyspelling\.words$',
|
||||
'^\.mailmap$',
|
||||
'^RELEASE-NOTES$',
|
||||
'^docs/BINDINGS\.md$',
|
||||
'^docs/THANKS$',
|
||||
'^docs/THANKS-filter$',
|
||||
);
|
||||
|
||||
sub fn_match {
|
||||
|
|
@ -80,19 +89,19 @@ sub eol_detect {
|
|||
my $lf = () = $content =~ /\n/g;
|
||||
|
||||
if($cr > 0 && $lf == 0) {
|
||||
return "cr";
|
||||
return 'cr';
|
||||
}
|
||||
elsif($cr == 0 && $lf > 0) {
|
||||
return "lf";
|
||||
return 'lf';
|
||||
}
|
||||
elsif($cr == 0 && $lf == 0) {
|
||||
return "bin";
|
||||
return 'bin';
|
||||
}
|
||||
elsif($cr == $lf) {
|
||||
return "crlf";
|
||||
return 'crlf';
|
||||
}
|
||||
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
my $issues = 0;
|
||||
|
|
@ -109,23 +118,23 @@ while(my $filename = <$git_ls_files>) {
|
|||
|
||||
if(!fn_match($filename, @tabs) &&
|
||||
$content =~ /\t/) {
|
||||
push @err, "content: has tab";
|
||||
push @err, 'content: has tab';
|
||||
}
|
||||
|
||||
my $eol = eol_detect($content);
|
||||
|
||||
if($eol eq "") {
|
||||
push @err, "content: has mixed EOL types";
|
||||
if($eol eq '') {
|
||||
push @err, 'content: has mixed EOL types';
|
||||
}
|
||||
|
||||
if($eol ne "crlf" &&
|
||||
if($eol ne 'crlf' &&
|
||||
fn_match($filename, @need_crlf)) {
|
||||
push @err, "content: must use CRLF EOL for this file type";
|
||||
push @err, 'content: must use CRLF EOL for this file type';
|
||||
}
|
||||
|
||||
if($eol ne "lf" && $content ne "" &&
|
||||
if($eol ne 'lf' && $content ne '' &&
|
||||
!fn_match($filename, @need_crlf)) {
|
||||
push @err, "content: must use LF EOL for this file type";
|
||||
push @err, 'content: must use LF EOL for this file type';
|
||||
}
|
||||
|
||||
if($content =~ /[ \t]\n/) {
|
||||
|
|
@ -138,14 +147,14 @@ while(my $filename = <$git_ls_files>) {
|
|||
}
|
||||
}
|
||||
|
||||
if($content ne "" &&
|
||||
if($content ne '' &&
|
||||
$content !~ /\n\z/) {
|
||||
push @err, "content: has no EOL at EOF";
|
||||
push @err, 'content: has no EOL at EOF';
|
||||
}
|
||||
|
||||
if($content =~ /\n\n\z/ ||
|
||||
$content =~ /\r\n\r\n\z/) {
|
||||
push @err, "content: has multiple EOL at EOF";
|
||||
push @err, 'content: has multiple EOL at EOF';
|
||||
}
|
||||
|
||||
if((!fn_match($filename, @double_empty_lines) &&
|
||||
|
|
@ -159,7 +168,7 @@ while(my $filename = <$git_ls_files>) {
|
|||
$line++;
|
||||
if($l =~ /^$/) {
|
||||
if($blank) {
|
||||
my $lineno = sprintf("duplicate empty line @ line %d", $line);
|
||||
my $lineno = sprintf('duplicate empty line @ line %d', $line);
|
||||
push @err, $lineno;
|
||||
}
|
||||
$blank = 1;
|
||||
|
|
@ -170,13 +179,33 @@ while(my $filename = <$git_ls_files>) {
|
|||
}
|
||||
}
|
||||
|
||||
if(!fn_match($filename, @longline)) {
|
||||
my $line = 0;
|
||||
my $max = 192;
|
||||
for my $l (split(/\n/, $content)) {
|
||||
$line++;
|
||||
if(length($l) > $max) {
|
||||
push @err, sprintf('line %d: long (%d > %d) line', $line, length($l), $max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $line = 0;
|
||||
my $max = 79;
|
||||
for my $l (split(/\n/, $content)) {
|
||||
$line++;
|
||||
if($l =~ /( {$max,})/) {
|
||||
push @err, sprintf('line %d: repeat spaces (%d > %d)', $line, length($1), $max);
|
||||
}
|
||||
}
|
||||
|
||||
my $search = $content;
|
||||
my $linepos = 0;
|
||||
while($search =~ / "\n *" /) {
|
||||
while($search =~ /[^ ] "\n *" [^ ]/) {
|
||||
my $part = substr($search, 0, $+[0]);
|
||||
$search = substr($search, $+[0]);
|
||||
my $line = ($part =~ tr/\n//);
|
||||
push @err, sprintf("line %d: double spaces in folded string", $linepos + $line);
|
||||
push @err, sprintf('line %d: double spaces in folded string', $linepos + $line);
|
||||
$linepos += $line;
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +230,7 @@ while(my $filename = <$git_ls_files>) {
|
|||
}
|
||||
|
||||
if($content =~ /([\x00-\x08\x0b\x0c\x0e-\x1f\x7f])/) {
|
||||
push @err, "content: has binary contents";
|
||||
push @err, 'content: has binary contents';
|
||||
}
|
||||
|
||||
if($filename !~ /tests\/data/) {
|
||||
|
|
@ -214,7 +243,7 @@ while(my $filename = <$git_ls_files>) {
|
|||
my $non = $1;
|
||||
my $hex;
|
||||
for my $e (split(//, $non)) {
|
||||
$hex .= sprintf("%s%02x", $hex ? " ": "", ord($e));
|
||||
$hex .= sprintf('%s%02x', $hex ? ' ': '', ord($e));
|
||||
}
|
||||
my $line;
|
||||
for my $l (split(/\n/, $content)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue