blib/lib/PM/Packages.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 82.1% 23 / 28 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 88.6% 70 / 79 CC 16 SCAR 26.4
CC
16
Cov
90%
pm_packages
16.4
BEGIN
1.0
BEGIN
1.0
CRAP 14.0
↑ Summary
1 package PM::Packages;
2  
3 5 ▶use 5.00405;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 our $VERSION = '0.01';
7  
8 5 our @EXPORT_OK = qw( pm_packages );
9 5 our @EXPORT = @EXPORT_OK;
10  
11 5 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub pm_packages
14 5 ▶{
Subroutine pm_packages: called CC=16 SCAR=28.0
Pod undocumented
15 5 my( $pmfile ) = @_;
16 5 my @ret;
17  
18 5 ▶ open my $fh, "<", "$pmfile" or return;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", "$pmfile" or return 5 0 5
19  
20 5 local $/ = "\n";
21 5 my $inpod = 0;
22 5 ▶ PLINE: while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 86 3 89
23 86 chomp;
24 86 my($pline) = $_;
25 86 ▶ $inpod = $pline =~ /^=(?!cut)/ ? 1 :
Branch: 2 branches
BranchTrueFalseTotal
$pline =~ /^=(?!cut)/ ? : 1 85 86
$pline =~ /^=cut/ ? : 1 84 85
26 $pline =~ /^=cut/ ? 0 : $inpod;
27 86 ▶ next if $inpod;
Branch: 1 branch
BranchTrueFalseTotal
if $inpod 4 82 86
28 82 ▶ next if substr($pline,0,4) eq "=cut";
Branch: 1 branch
BranchTrueFalseTotal
if substr($pline, 0, 4) eq "=cut" 1 81 82
29  
30 81 $pline =~ s/\#.*//;
31 81 ▶ next if $pline =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $pline =~ /^\s*$/ 42 39 81
32 39 ▶ if ($pline =~ /^__(?:END|DATA)__\b/
Branch: 1 branch
BranchTrueFalseTotal
if ($pline =~ /^__(?:END|DATA)__\b/ and not $pmfile =~ /\.PL$/) 2 37 39
Condition66%2/3
$pline =~ /^__(?:END|DATA)__\b/ and not $pmfile =~ /\.PL$/
!ll&&!rl&&r
3702
MC/DC50%1/2
$pline =~ /^__(?:END|DATA)__\b/ and not $pmfile =~ /\.PL$/
$pline =~ /^__(?:END|DATA)__\b/ not $pmfile =~ /\.PL$/
Truth table66%2/3
A and not(B)
A= $pline =~ /^__(?:END|DATA)__\b/B= not $pmfile =~ /\.PL$/
ABresult
0X0
100
111
33 and $pmfile !~ /\.PL$/ # PL files may well have code after __DATA__
34 ){
35 2 last PLINE;
36 }
37  
38 37 my $pkg;
39 my $strict_version;
40  
41 37 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($pline =~ / (.*) (?<![*\$\\\@%&]) # no sigils \bpackage\s+ ([\w\:\']+) \s* (?: $ | [\}\;] | \{ | \s+($version::STRICT) ) /x) 6 31 37
42 $pline =~ m{
43 (.*)
44 (?<![*\$\\@%&]) # no sigils
45 \bpackage\s+
46 ([\w\:\']+)
47 \s*
48 (?: $ | [\}\;] | \{ | \s+($version::STRICT) )
49 }x) {
50 6 $pkg = $2;
51 6 $strict_version = $3;
52 6 ▶ if ($pkg eq "DB"){
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg eq "DB") 0 6 6
53 # XXX if pumpkin and perl make him comaintainer! I
54 # think I always made the pumpkins comaint on DB
55 # without further ado (?)
56 0 next PLINE;
57 }
58 }
59  
60 37 ▶ if ($pkg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg) 6 31 37
61 # Found something
62  
63 # from package
64 6 $pkg =~ s/\'/::/;
65 # next PLINE unless $pkg =~ /^[A-Za-z]/;
66 6 ▶ next PLINE unless $pkg =~ /\w$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $pkg =~ /\w$/ 0 6 6
67 6 ▶ next PLINE if $pkg eq "main";
Branch: 1 branch
BranchTrueFalseTotal
if $pkg eq "main" 0 6 6
68 # Perl::Critic::Policy::TestingAndDebugging::ProhibitShebangWarningsArg
69 # database for modid in mods, package in packages, package in perms
70 # alter table mods modify modid varchar(128) binary NOT NULL default '';
71 # alter table packages modify package varchar(128) binary NOT NULL default '';
72 6 ▶ next PLINE if length($pkg) > 128;
Branch: 1 branch
BranchTrueFalseTotal
if length $pkg > 128 0 6 6
73 6 push @ret, $pkg;
74 }
75 }
76  
77 5 $fh->close;
78 5 return @ret;
79 }
80  
81  
82 5 1;
83 __END__
↑ Summary