Perl-Critic-Policy-CompileTime
view release on metacpan or search on metacpan
lib/Perl/Critic/Policy/CompileTime.pm view on Meta::CPAN
my @violations;
$node->find(
sub {
my ( $begin_block, $statement ) = @_;
return 0 unless $statement->isa('PPI::Statement');
push @violations,
$self->violation(
'Performs process image operations',
$POLICY, $statement
) if $statement->performs_process_ops;
push @violations,
$self->violation(
'Assignment to special var',
$POLICY, $statement
) if $statement->mutates_special_var;
push @violations, $self->violation( 'System I/O', $POLICY, $statement )
if $statement->performs_system_io;
return 0;
}
);
return @violations;
}
1;
__END__
=head1 NAME
Perl::Critic::Policy::CompileTime - Provide Perl::Critic support for hunting
down compile-time side effects
=head1 SUMMARY
Perl::Critic::Policy::CompileTime and PPIx::PerlCompiler: A dynamic duo for
finding abberant code with bad compile-time side effects!
=head1 SYNOPSIS
~$ cat ~/.perlcriticrc
include = CompileTime
=head1 DESCRIPTION
Perl::Critic::Policy::CompileTime is a Perl::Critic module which allows one to
quickly find code in a large codebase or installation which may not run the way
one expects when compiled by the Perl compiler, B::C. With the help of the
underlying code in PPIx::PerlCompiler, it does so by performing some rudimentary
pattern matching against statements and subexpressions in specific instances.
=head2 FEATURES
PPIx::PerlCompiler provides the ability to check compile time code blocks,
BEGIN, UNITCHECK, and CHECK, for code that may likely have system-wide side
effects, or may perform I/O that may invalidate dependent state of compiled
binaries when they run.
Perl::Critic::Policy::CompileTime issues severity level 40 advisories regarding
the aforementioned features in Perl code. To use this module with Perl::Critic,
simply add something like the following to your .perlcriticrc file:
include = CompileTime
=head1 SEE ALSO
=over
=item L<Perl::Critic>
=back
=head1 AUTHOR
Xan Tronix <xan@cpan.org>
( run in 2.414 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )