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 | ecbceb20b7a21d5a31108e24106d162622044924 (patch) | |
tree | a37490ea89dfa65682bd4ef75b966d6c217f18a8 /perl_checker.src | |
parent | b96cd37954da7ce53d43d1444740ddd7e81d6480 (diff) | |
download | perl_checker-ecbceb20b7a21d5a31108e24106d162622044924.tar perl_checker-ecbceb20b7a21d5a31108e24106d162622044924.tar.gz perl_checker-ecbceb20b7a21d5a31108e24106d162622044924.tar.bz2 perl_checker-ecbceb20b7a21d5a31108e24106d162622044924.tar.xz perl_checker-ecbceb20b7a21d5a31108e24106d162622044924.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) { |