X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FPerl%2FCritic%2FPolicy%2FDynamic%2FNoIndirect.pm;h=893398271f6093dbd0fc5eceb9d07236f680c6c9;hb=7b4e2c7a41cf9f8f9fe08d1f0d8bb67f015460b2;hp=b14ecf53f801d2d4bb5af05352085b8e60f7ffb1;hpb=9a658054acd1d628ba4f98c49127fcdf8fd1512b;p=perl%2Fmodules%2FPerl-Critic-Policy-Dynamic-NoIndirect.git diff --git a/lib/Perl/Critic/Policy/Dynamic/NoIndirect.pm b/lib/Perl/Critic/Policy/Dynamic/NoIndirect.pm index b14ecf5..8933982 100644 --- a/lib/Perl/Critic/Policy/Dynamic/NoIndirect.pm +++ b/lib/Perl/Critic/Policy/Dynamic/NoIndirect.pm @@ -11,11 +11,11 @@ Perl::Critic::Policy::Dynamic::NoIndirect - Perl::Critic policy against indirect =head1 VERSION -Version 0.04 +Version 0.05 =cut -our $VERSION = '0.04'; +our $VERSION = '0.05'; =head1 DESCRIPTION @@ -26,12 +26,12 @@ Since it wraps around L, it needs to compile the audited code and as s =cut -use base qw/Perl::Critic::DynamicPolicy/; +use base qw; -use Perl::Critic::Utils qw/:severities/; +use Perl::Critic::Utils qw<:severities>; sub default_severity { $SEVERITY_HIGH } -sub default_themes { qw/dynamic maintenance/ } +sub default_themes { qw } sub applies_to { 'PPI::Document' } my $tag_obj = sub { @@ -57,25 +57,26 @@ sub violates_dynamic { $file =~ s/(? sub { push \@errs, [ \@_ ] }; - { - ; + no strict; + no warnings; + no indirect hook => \$hook; + do { #line 1 "$file" $src } - } WRAPPER { local ($@, *_); eval $wrapper; ## no critic - if ($@) { + if (my $err = $@) { require Carp; - Carp::confess("Couldn't compile the source wrapper: $@"); + Carp::croak("Couldn't compile the source wrapper: $err"); } } @@ -118,7 +119,7 @@ sub violates_dynamic { =head1 CAVEATS -The uses of the L pragma inside the auditted code take precedence over this policy. +The uses of the L pragma inside the audited code take precedence over this policy. Hence no violations will be reported for indirect method calls that are located inside the lexical scope of C or C<< no indirect hook => ... >>. Occurrences of C won't be a problem. @@ -130,7 +131,7 @@ L 5.8, L. L, L. -L. +L 0.20. =head1 SEE ALSO @@ -158,7 +159,7 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2009 Vincent Pit, all rights reserved. +Copyright 2009,2010,2011 Vincent Pit, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.