/usr/local/lib/perl5/5.44.0/strict.pm

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 35 CC 7 SCAR 29.6
CC
7
Cov
0%
bits
30.0
import
6.0
unimport
6.0
CRAP 19.3
« /usr/local/lib/perl5/5.44.0/overload.pm ↑ Summary /usr/local/lib/perl5/5.44.0/CPAN/Meta.pm »
1 package strict;
2  
3 $strict::VERSION = "1.14";
4  
5 my ( %bitmask, %explicit_bitmask );
6  
7 BEGIN {
8 # Verify that we're called correctly so that strictures will work.
9 # Can't use Carp, since Carp uses us!
10 # see also warnings.pm.
11 die sprintf "Incorrect use of pragma '%s' at %s line %d.\n", __PACKAGE__, +(caller)[1,2]
12 if __FILE__ !~ ( '(?x) \b '.__PACKAGE__.' \.pmc? \z' )
13 && __FILE__ =~ ( '(?x) \b (?i:'.__PACKAGE__.') \.pmc? \z' );
14  
15 # which strictures are actually in force
16 %bitmask = (
17 refs => 0x00000002,
18 subs => 0x00000200,
19 vars => 0x00000400,
20 );
21  
22 # which strictures have at some point been turned on or off explicitly
23 # and must therefore not be touched by any subsequent `use VERSION` or `no VERSION`
24 %explicit_bitmask = (
25 refs => 0x00000020,
26 subs => 0x00000040,
27 vars => 0x00000080,
28 );
29  
30 my $bits = 0;
31 $bits |= $_ for values %bitmask;
32  
33 my $inline_all_bits = $bits;
34 *all_bits = sub () { $inline_all_bits };
35  
36 $bits = 0;
37 $bits |= $_ for values %explicit_bitmask;
38  
39 my $inline_all_explicit_bits = $bits;
40 *all_explicit_bits = sub () { $inline_all_explicit_bits };
41 }
42  
43 sub bits {
44 0 ▶ my $do_explicit = caller eq __PACKAGE__;
Subroutine bits: not called CC=5 SCAR=34.0
Pod undocumented
45 0 my $bits = 0;
46 0 my @wrong;
47 0 foreach my $s (@_) {
48 0 ▶ if (exists $bitmask{$s}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $bitmask{$s}) { } 0 0 0
49 0 ▶ $bits |= $explicit_bitmask{$s} if $do_explicit;
Branch: 1 branch
BranchTrueFalseTotal
if $do_explicit 0 0 0
50 0 $bits |= $bitmask{$s};
51 }
52 else {
53 0 push @wrong, $s;
54 }
55 }
56 0 ▶ if (@wrong) {
Branch: 1 branch
BranchTrueFalseTotal
if (@wrong) 0 0 0
57 0 require Carp;
58 0 Carp::croak("Unknown 'strict' tag(s) '@wrong'");
59 }
60 0 $bits;
61 }
62  
63 sub import {
64 0 ▶ shift;
Subroutine import: not called CC=2 SCAR=17.9
65 0 ▶ $^H |= @_ ? &bits : all_bits | all_explicit_bits;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
66 }
67  
68 sub unimport {
69 0 ▶ shift;
Subroutine unimport: not called CC=2 SCAR=17.9
70  
71 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
72 0 my $bits = &bits;
73 0 $^H &= ~$bits;
74 0 $^H |= all_explicit_bits & $bits;
75 }
76 else {
77 0 $^H &= ~all_bits;
78 0 $^H |= all_explicit_bits;
79 }
80 }
81  
82 1;
83  
84 __END__
« /usr/local/lib/perl5/5.44.0/overload.pm ↑ Summary /usr/local/lib/perl5/5.44.0/CPAN/Meta.pm »