diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-11-17 12:23:28 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-11-17 12:23:28 +0000 |
commit | c01730aac021a10c13cdbaf99813b0869e045889 (patch) | |
tree | 999b41837f5f3b0c1056bb267907981fc50fa8ce /perl_checker.src | |
parent | c3940ee6ff3f630fff35f282851c10804ac52b71 (diff) | |
download | perl-MDK-Common-c01730aac021a10c13cdbaf99813b0869e045889.tar perl-MDK-Common-c01730aac021a10c13cdbaf99813b0869e045889.tar.gz perl-MDK-Common-c01730aac021a10c13cdbaf99813b0869e045889.tar.bz2 perl-MDK-Common-c01730aac021a10c13cdbaf99813b0869e045889.tar.xz perl-MDK-Common-c01730aac021a10c13cdbaf99813b0869e045889.zip |
warn unneeded ";" after some blocks
Diffstat (limited to 'perl_checker.src')
-rw-r--r-- | perl_checker.src/parser.mly | 2 | ||||
-rw-r--r-- | perl_checker.src/test/force_layout.t | 3 | ||||
-rwxr-xr-x | perl_checker.src/test/test_it | 4 |
3 files changed, 7 insertions, 2 deletions
diff --git a/perl_checker.src/parser.mly b/perl_checker.src/parser.mly index 572969f..adecfac 100644 --- a/perl_checker.src/parser.mly +++ b/perl_checker.src/parser.mly @@ -112,7 +112,7 @@ line: | loop { new_1esp [$1.any] $1 } | LABEL { sp_cr($1); new_1esp [Label $1.any] $1 } | PERL_CHECKER_COMMENT {sp_p($1); new_1esp [Perl_checker_comment($1.any, get_pos $1)] $1 } -| semi_colon {new_1esp [Semi_colon] $1 } +| semi_colon {warn_rule [Warn_white_space] "unneeded \";\""; new_1esp [Semi_colon] $1 } | sideff semi_colon {new_1esp [$1.any ; Semi_colon] $1 } | BRACKET lines BRACKET_END {new_esp $2.mcontext [lines_to_Block $2 $3] $1 $3} | BRACKET lines BRACKET_END semi_colon {new_esp $2.mcontext [lines_to_Block $2 $3] $1 $4} diff --git a/perl_checker.src/test/force_layout.t b/perl_checker.src/test/force_layout.t index 0ebd202..bb5494e 100644 --- a/perl_checker.src/test/force_layout.t +++ b/perl_checker.src/test/force_layout.t @@ -18,3 +18,6 @@ if ($xxx) { missing ";" xxx() } +if ($xxx) { unneeded ";" + xxx(); +}; diff --git a/perl_checker.src/test/test_it b/perl_checker.src/test/test_it index 85214b7..fc2e70f 100755 --- a/perl_checker.src/test/test_it +++ b/perl_checker.src/test/test_it @@ -65,7 +65,9 @@ foreach my $test (@tests) { if ($l[-1] !~ /(;|[\s{]\})\s+$/) { $l[-1] =~ s/^(.*?)(\s+$)/xxx($1);$2/; } else { - $l[-1] =~ s/(\s+$)/; nop();$1/; + my $no_comma = $l[-1] =~ /(^\s*(for|foreach|if|unless|while|sub)\s)|(;\s+$)/; + my $opt_comma = $no_comma ? '' : ';'; + $l[-1] =~ s/(\s+$)/$opt_comma nop();$1/; } } if (! any { /^(sub|use) / } @l) { |