From: Vincent Pit Date: Tue, 14 Jul 2009 19:37:42 +0000 (+0200) Subject: Document and test using indirect inside the auditted code X-Git-Tag: v0.04~2 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FPerl-Critic-Policy-Dynamic-NoIndirect.git;a=commitdiff_plain;h=05870b723b862a0daadd62a71b81e3e8bca7f881 Document and test using indirect inside the auditted code --- diff --git a/lib/Perl/Critic/Policy/Dynamic/NoIndirect.pm b/lib/Perl/Critic/Policy/Dynamic/NoIndirect.pm index cb88e6b..556ecc6 100644 --- a/lib/Perl/Critic/Policy/Dynamic/NoIndirect.pm +++ b/lib/Perl/Critic/Policy/Dynamic/NoIndirect.pm @@ -115,6 +115,12 @@ sub violates_dynamic { } @violations; } +=head1 CAVEATS + +The uses of the L pragma inside the auditted 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. + =head1 DEPENDENCIES L 5.8, L. diff --git a/t/10-basic.t b/t/10-basic.t index 55215c4..0c1c23d 100644 --- a/t/10-basic.t +++ b/t/10-basic.t @@ -5,7 +5,7 @@ use warnings; my ($tests, $reports, $subtests); BEGIN { - $tests = 25; + $tests = 27; $reports = 42; $subtests = 3; } @@ -71,6 +71,9 @@ my $x = new X; ---- [ 'new', 'X', 1, 9 ] #### +use indirect; my $x = new X; +---- +#### my $x = new X; $x = new X; ---- [ 'new', 'X', 1, 9 ], [ 'new', 'X', 1, 21 ] @@ -104,6 +107,10 @@ my $x = new new; [ 'new', 'new', 1, 9 ] #### our $obj; +use indirect; my $x = new $obj; +---- +#### +our $obj; my $x = new $obj; ---- [ 'new', '$obj', 2, 9 ]