evil.pm

filter: Statementstmt 100% 43 / 43 Branchbran 100% 20 / 20 Conditioncond 100% 9 / 9 MC/DCmcdc 100% 5 / 5 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 83 / 83 CC 15 SCAR 19.0
CC
15
Cov
100%
import
9.0
unimport
7.0
BEGIN
1.0
CRAP 6.7
↑ Summary Acme/Evil.pm »
1 #!/usr/bin/perl
2 package evil;
3  
4 11 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 11 my $INTERMEDIATE = __PACKAGE__.'/intermediate';
11 11 my $LAX = __PACKAGE__.'/lax';
12  
13 11 our $VERSION = 0.003002;
14  
15 11 our %tainted;
16 11 our %wants_strict;
17  
18 15 ▶sub import {
Subroutine import: called CC=9 SCAR=22.0
19 15 ▶ croak "Cannot load evil module when \"no evil ':strict'\" is in effect" if %wants_strict;
Branch: 1 branch
BranchTrueFalseTotal
if %evil::wants_strict 2 13 15
20  
21 13 ▶ my $hinthash = (caller 0)[10] || {};
Condition100%2/2
(caller 0)[10] || {}
l!l
211
MC/DC100%1/1
(caller 0)[10] || {}
(caller 0)[10]
Truth table100%2/2
A
A= (caller 0)[10]
Aresult
11
00
22 13 ▶ croak "Current module requested no evilness" if $hinthash->{$LAX};
Branch: 1 branch
BranchTrueFalseTotal
if $hinthash->{$LAX} 2 11 13
23  
24 11 ▶ $hinthash = (caller 3)[10] || {};
Condition100%2/2
(caller 3)[10] || {}
l!l
38
MC/DC100%1/1
(caller 3)[10] || {}
(caller 3)[10]
Truth table100%2/2
A
A= (caller 3)[10]
Aresult
11
00
25 11 ▶ croak "Cannot load evil module when parent requested \"no evil ':lax'\"" if $hinthash->{$LAX};
Branch: 1 branch
BranchTrueFalseTotal
if $hinthash->{$LAX} 2 9 11
26  
27 9 my $level = 4;
28 9 my @caller;
29 9 ▶ while (@caller = caller $level) {
Branch: 1 branch
BranchTrueFalseTotal
if (@caller = caller $level) 30 8 38
30 30 ▶ $hinthash = $caller[10] || {};
Condition100%2/2
$caller[10] || {}
l!l
624
MC/DC100%1/1
$caller[10] || {}
$caller[10]
Truth table100%2/2
A
A= $caller[10]
Aresult
11
00
31 croak "Cannot load evil module when ancestor requested \"no evil ':intermediate'\""
32 30 ▶ if $hinthash->{$INTERMEDIATE};
Branch: 1 branch
BranchTrueFalseTotal
if $hinthash->{$INTERMEDIATE} 1 29 30
33 29 $level++;
34 }
35  
36 8 $tainted{caller()} = 1;
37 }
38  
39 19 ▶sub unimport {
Subroutine unimport: called CC=7 SCAR=19.5
40 19 my $strict_arg = grep /^:strict$/i, @_;
41 19 my $intermediate_arg = grep /^:intermediate$/i, @_;
42 19 my $lax_arg = grep /^:lax$/i, @_;
43 19 my $disable_arg = grep /^:disable$/i, @_;
44  
45 19 ▶ if (!$disable_arg && $tainted{caller()}) { # caller is evil
Branch: 1 branch
BranchTrueFalseTotal
if (not $disable_arg and $evil::tainted{caller()}) 3 16 19
Condition100%3/3
not $disable_arg and $evil::tainted{caller()}
!ll&&!rl&&r
2143
MC/DC100%2/2
not $disable_arg and $evil::tainted{caller()}
not $disable_arg $evil::tainted{caller()}
Truth table100%3/3
not(A) and B
A= not $disable_argB= $evil::tainted{caller()}
ABresult
0X0
100
111
46 3 croak 'Current module is evil'
47 }
48  
49 16 ▶ if ($strict_arg) {
Branch: 3 branches
BranchTrueFalseTotal
if ($strict_arg) { } 6 10 16
elsif ($lax_arg) { } 4 6 10
elsif ($disable_arg) { } 2 4 6
50 6 $wants_strict{caller()} = 1;
51 6 ▶ croak "Evil module already loaded. Cannot enforce \"no evil ':strict'\"" if %tainted
Branch: 1 branch
BranchTrueFalseTotal
if %evil::tainted 1 5 6
52 } elsif ($lax_arg) {
53 4 $^H{$LAX} = 1
54 } elsif ($disable_arg) {
55 2 delete $wants_strict{caller()};
56 2 delete $^H{$LAX};
57 2 delete $^H{$INTERMEDIATE};
58 } else { # $intermediate_arg or no arg
59 4 $^H{$INTERMEDIATE} = $^H{$LAX} = 1
60 }
61 }
62  
63 11 1;
64 __END__
↑ Summary Acme/Evil.pm »