diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2002-07-31 00:07:30 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2002-07-31 00:07:30 +0000 |
commit | e14829cc6aa3bcb315e330b1bcb5f82676fb26d3 (patch) | |
tree | d757593d3190d53a41943ae5da29efd4db19ab35 /perl_checker | |
parent | bce512bc41bf288fc6f94d3e092f525dd8541345 (diff) | |
download | perl-MDK-Common-e14829cc6aa3bcb315e330b1bcb5f82676fb26d3.tar perl-MDK-Common-e14829cc6aa3bcb315e330b1bcb5f82676fb26d3.tar.gz perl-MDK-Common-e14829cc6aa3bcb315e330b1bcb5f82676fb26d3.tar.bz2 perl-MDK-Common-e14829cc6aa3bcb315e330b1bcb5f82676fb26d3.tar.xz perl-MDK-Common-e14829cc6aa3bcb315e330b1bcb5f82676fb26d3.zip |
- perl_checker: add *much* stricter syntax rules
- adapt *.pm's to those rules
Diffstat (limited to 'perl_checker')
-rwxr-xr-x | perl_checker | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/perl_checker b/perl_checker index 9401956..594fc98 100755 --- a/perl_checker +++ b/perl_checker @@ -38,6 +38,8 @@ if (/^# perl_checker: RE-EXPORT-ALL/) { /^=head/ .. /^=cut/ and next; /^\s*#/ and next; +$explicit_no_warning = /#-#/; + if (/^\s*require\s+([\w:]+);/) { add_use($1); } elsif (my ($r) = /^\s*require (.*)/) { @@ -46,6 +48,31 @@ if (/^\s*require\s+([\w:]+);/) { next; } + +if (/\(\s+[^#\s({\[]/ && !/qq\(/) { + warn_(q(spurious space after opening parenthesis), info()); +} + +if (/[^#\s)}\]]\s+\)/) { + warn_(q(spurious space before closing parenthesis), info()); +} + +if (/;([^\s\\].{0,10})/ && !/^sub/ && !/;-\)/ && !/=~/ && !/^\s+;;$/) { + warn_(qq(missing space after ";$1"), info()); +} + +if (/;\s*\}/) { + warn_(q(spurious ";" before closing block), info()); +} + +if (/(.*\s\{)[^\s{}]/ && !/\{[\d,]+\}/ && !/Usage:/) { #- eg of Usage: cmd {foo|bar} + warn_(qq(missing space after "$1"), info()); +} + +if (/\{\s[^{}]*[^\s{}]\}/) { + warn_(qq(missing space before "}$'"), info()); +} + if (/%_\W/ || /[^@]\$_{/) { err(q(do not use %_), info()); } @@ -64,7 +91,8 @@ if (/[}>]{(['"])([a-z][a-z0-9_]*)\1}/i) { # special case for {'y'} otherwise the emacs mode goes wild # special case for {'x'} to have the same as {'y'} (since they usually go together) } -if (/%$\w+(->|\{)/ || /%{([^{}]|{[^{}]*})*}(->|\{)/) { +if (/%\$\w+(->|\{)/ || /%\{([^{}]|\{[^{}]*\})*\}(->|\{)/ || + /@\$\w+->/ || /@\{([^{}]|\{[^{}]*\})*\}->/) { err(q(bad expression, tell pixel@mandrakesoft.com), info()); } @@ -93,7 +121,7 @@ if ((my ($op) = /([<>]{2})/) && (/[+-]\s*[\w\$]+\s*[<>]{2}/ || /[<>]{2}\s*[\w\$] err(qq(parentheses needed around operator $op), info()); } if (/=.*:\s*\$\w+\s*=/) { - err(q(do not use ``cond ? $v1 = XX1 : $v2 = XX2'' which is parted as ``(cond ? $v1 = XX1 : $v2) = XX2''), info()); + err(q(do not use ``cond ? $v1 = XX1 : $v2 = XX2'' which is parsed as ``(cond ? $v1 = XX1 : $v2) = XX2''), info()); } if (/^\s*package ([\w:]+)/) { @@ -216,6 +244,8 @@ sub err { sub warn_ { my ($m, $i) = @_; + return if $explicit_no_warning; + if ($i) { print STDERR "$i->{file}:$i->{line}: $m\n"; } else { |