Midgen/Role/InDistribution.pm

filter: Statementstmt 39.0% 16 / 41 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 100% 1 / 1 totaltotal 28.0% 21 / 75 CC 14 SCAR 40.3
CC
14
Cov
24%
_confirm_perlfile
90.0
is_perlfile
42.0
BEGIN
1.0
CRAP 56.1
« Midgen/Role/Output/EUMM.pm ↑ Summary Midgen/Role/Heuristics.pm »
1 package App::Midgen::Role::InDistribution;
2  
3 2 ▶use constant {TWO => 2, TRUE => 1, FALSE => 0,};
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Types::Standard qw( Bool );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 requires qw( ppi_document debug );
8  
9 2 our $VERSION = '0.34';
10 2 $VERSION = eval $VERSION; ## no critic
11  
12  
13 ########
14 # is this a perl file
15 # more files found than File-Find-Rule-Perl (!psgi)
16 ########
17 0 ▶sub is_perlfile {
Subroutine is_perlfile: not called CC=6 SCAR=37.4
Pod documented
18 0 my $self = shift;
19 0 my $filename = $_;
20  
21 0 for (qw(pm t psgi pl)) {
22 0 ▶ if ($filename =~ m/[.]$_$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename =~ /[.]$_$/) 0 0 0
23 0 ▶ print "looking for requires in (.$_)-> $filename\n"
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose >= 2 0 0 0
24 if $self->verbose >= TWO;
25 0 return TRUE;
26 }
27 }
28 0 ▶ if ($filename =~ m/[.]\w{2,4}$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename =~ /[.]\w{2,4}$/) { } 0 0 0
29 0 ▶ print "rejecting $filename\n" if $self->verbose >= TWO;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose >= 2 0 0 0
30 0 return FALSE;
31 }
32 else {
33 0 return $self->_confirm_perlfile($filename);
34 }
35 }
36  
37 ########
38 # confirm if this a perl file
39 #######
40 0 ▶sub _confirm_perlfile {
Subroutine _confirm_perlfile: not called CC=9 SCAR=45.0
41 0 my $self = shift;
42 0 my $filename = shift;
43  
44 # ignore dirs - bug found by farabi, azawawi++
45 0 ▶ return FALSE if -d $filename;
Branch: 1 branch
BranchTrueFalseTotal
if -d $filename 0 0 0
46  
47 0 $self->_set_ppi_document(PPI::Document->new($filename));
48  
49 0 my $ppi_tc = $self->ppi_document->find('PPI::Token::Comment');
50  
51 0 my $a_pl_file = 0;
52  
53 0 ▶ if ($ppi_tc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ppi_tc) 0 0 0
54  
55 # check first token-comment for a she-bang
56 0 ▶ $a_pl_file = 1 if $ppi_tc->[0]->content =~ m/^#!.*perl.*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $ppi_tc->[0]->content =~ /^#!.*perl.*$/ 0 0 0
57 }
58  
59  
60 0 ▶ if ($self->ppi_document->find('PPI::Statement::Package') || $a_pl_file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->ppi_document->find('PPI::Statement::Package') or $a_pl_file) { } 0 0 0
Condition0%0/3
$self->ppi_document->find("PPI::Statement::Package") or $a_pl_file
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->ppi_document->find("PPI::Statement::Package") or $a_pl_file
$self->ppi_document->find("PPI::Statement::Package") $a_pl_file
Truth table0%0/3
A or B
A= $self->ppi_document->find("PPI::Statement::Package")B= $a_pl_file
ABresult
1X1
011
000
61 0 ▶ if ($self->verbose >= TWO) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verbose >= 2) 0 0 0
62  
63 0 ▶ print "looking for requires in (package) -> "
Branch: 1 branch
BranchTrueFalseTotal
if $self->ppi_document->find("PPI::Statement::Package") 0 0 0
64 if $self->ppi_document->find('PPI::Statement::Package');
65 0 ▶ print "looking for requires in (shebang) -> "
Branch: 1 branch
BranchTrueFalseTotal
if $ppi_tc->[0]->content =~ /perl/ 0 0 0
66 if $ppi_tc->[0]->content =~ /perl/;
67 0 print "$filename\n";
68 }
69 0 return TRUE;
70 }
71 else {
72 0 return FALSE;
73 }
74  
75 }
76  
77 2 ▶no Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
78  
79 2 1;
80  
81 __END__
« Midgen/Role/Output/EUMM.pm ↑ Summary Midgen/Role/Heuristics.pm »