Subject: | ProhibitUnreachableCode on "package" statement |
Date: | Tue, 16 Dec 2008 10:36:48 +1100 |
To: | bug-perl-critic [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
With perlcritic 1.092 and a recent debian perl 5.10.0, the foo.pl below
criticized as
perlcritic --single-policy=ProhibitUnreachableCode foo.pl
gives
Unreachable code at line 4, column 1. Consider removing it. (Severity: 4)
whereas I hoped the "package" statement there would be ok after an
exit().
Foo::foo();
exit 0;
package Foo;
sub foo { print "hello\n"; }
--- ProhibitUnreachableCode.pm.old 2008-12-13 15:14:32.000000000 +1100
+++ ProhibitUnreachableCode.pm 2008-12-13 15:18:18.000000000 +1100
@@ -76,6 +76,7 @@
next if $stmnt->isa('PPI::Statement::Sub');
next if $stmnt->isa('PPI::Statement::End');
next if $stmnt->isa('PPI::Statement::Data');
+ next if $stmnt->isa('PPI::Statement::Package');
next if $stmnt->isa('PPI::Statement::Include') &&
$stmnt->type() ne 'require';