Midgen/Role/UseOk.pm

filter: Statementstmt 30.4% 25 / 82 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 70.0% 7 / 10 Podpod 100% 1 / 1 totaltotal 21.8% 33 / 151 CC 31 SCAR 65.5
CC
31
Cov
19%
xtests_use_ok
930.0
__ANON__
6.0
__ANON__
2.0
CRAP 698.0
↑ Summary Midgen/Role/TestRequires.pm »
1 package App::Midgen::Role::UseOk;
2  
3 2 ▶use constant {BLANK => q{ }, NONE => q{}, TWO => 2, THREE => 3,};
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 requires
7 qw( ppi_document debug verbose format xtest _process_found_modules develop meta2 );
8  
9 # Load time and dependencies negate execution time
10 # use namespace::clean -except => 'meta';
11  
12 2 our $VERSION = '0.34';
13 2 $VERSION = eval $VERSION; ## no critic
14  
15 2 ▶use PPI;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Data::Printer {caller_info => 1,};
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Tie::Static qw(static);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 #use List::MoreUtils qw( lastidx );
21  
22 #######
23 # composed method - _xtests_in_single_quote
24 #######
25 0 ▶sub xtests_use_ok {
Subroutine xtests_use_ok: not called CC=30 SCAR=68.4
Pod documented
26 0 my $self = shift;
27 0 ▶ my $phase_relationship = shift || NONE;
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
28 0 my @modules;
29 my @version_strings;
30  
31 #PPI::Document
32 # PPI::Statement::Scheduled
33 # PPI::Token::Word 'BEGIN'
34 # PPI::Token::Whitespace ' '
35 # PPI::Structure::Block { ... }
36 # PPI::Token::Whitespace '\n'
37 # PPI::Token::Whitespace '\t'
38 # PPI::Statement
39 # PPI::Token::Word 'use_ok'
40 # PPI::Structure::List ( ... )
41 # PPI::Token::Whitespace ' '
42 # PPI::Statement::Expression
43 # PPI::Token::Quote::Single ''Term::ReadKey''
44 # PPI::Token::Operator ','
45 # PPI::Token::Whitespace ' '
46 # PPI::Token::Quote::Single ''2.30''
47  
48 my @chunks =
49  
50 0 map { [$_->schildren] }
51 0 grep { $_->child(0)->literal =~ m{\A(?:BEGIN)\z} }
52 0 grep { $_->child(0)->isa('PPI::Token::Word') }
53 0 ▶ @{$self->ppi_document->find('PPI::Statement::Scheduled') || []};
Condition0%0/2
$self->ppi_document->find('PPI::Statement::Scheduled') || []
l!l
00
MC/DC0%0/1
$self->ppi_document->find('PPI::Statement::Scheduled') || []
$self->ppi_document->find('PPI::Statement::Scheduled')
Truth table0%0/2
A
A= $self->ppi_document->find('PPI::Statement::Scheduled')
Aresult
11
00
54  
55 0 foreach my $hunk (@chunks) {
56  
57 # looking for use_ok { 'Term::ReadKey' => '2.30' };
58 0 ▶ if (grep { $_->isa('PPI::Structure::Block') } @$hunk) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_->isa("PPI::Structure::Block");} @$hunk) 0 0 0
59  
60 # hack for List
61 0 my @hunkdata = @$hunk;
62  
63 0 foreach my $ppi_sb (@hunkdata) {
64 0 ▶ if ($ppi_sb->isa('PPI::Structure::Block')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ppi_sb->isa("PPI::Structure::Block")) 0 0 0
65 0 foreach my $ppi_s (@{$ppi_sb->{children}}) {
66 0 ▶ if ($ppi_s->isa('PPI::Statement')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ppi_s->isa("PPI::Statement")) 0 0 0
67 0 ▶ p $ppi_s if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
68 0 ▶ if ($ppi_s->{children}[0]->content eq 'use_ok') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ppi_s->{"children"}[0]->content eq "use_ok") 0 0 0
69 0 my $ppi_sl = $ppi_s->{children}[1];
70 0 foreach my $ppi_se (@{$ppi_sl->{children}}) {
71 0 ▶ if ($ppi_se->isa('PPI::Statement::Expression')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ppi_se->isa("PPI::Statement::Expression")) 0 0 0
72 0 foreach my $element (@{$ppi_se->{children}}) {
73  
74 # some fudge to remember the module name if falied
75 0 static \my $previous_module;
76 0 ▶ if ( $element->isa('PPI::Token::Quote::Single')
Branch: 1 branch
BranchTrueFalseTotal
if ($element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::Quote::Double")) 0 0 0
Condition0%0/3
$element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::Quote::Double")
l!l&&r!l&&!r
000
MC/DC0%0/2
$element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::Quote::Double")
$element->isa("PPI::Token::Quote::Single") $element->isa("PPI::Token::Quote::Double")
Truth table0%0/3
A or B
A= $element->isa("PPI::Token::Quote::Single")B= $element->isa("PPI::Token::Quote::Double")
ABresult
1X1
011
000
77 || $element->isa('PPI::Token::Quote::Double'))
78 {
79  
80 0 my $module = $element->content;
81 0 $module =~ s/^(?:['|"])//;
82 0 $module =~ s/(?:['|"])$//;
83 0 ▶ if ($module =~ m{\A(?:[[a-zA-Z])}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module =~ /\A(?:[[a-zA-Z])/) 0 0 0
84  
85 0 ▶ print "found module - $module\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
86 0 push @modules, $module;
87 0 $version_strings[$#modules] = undef;
88 0 $previous_module = $module;
89 }
90 }
91  
92  
93 0 ▶ if ( $element->isa('PPI::Token::Number::Float')
Branch: 1 branch
BranchTrueFalseTotal
if ($element->isa("PPI::Token::Number::Float") or $element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::Quote::Double")) 0 0 0
Condition0%0/6
$element->isa("PPI::Token::Number::Float") or $element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::Quote::Double")
l!l&&r!l&&!r
000
$element->isa("PPI::Token::Number::Float") or $element->isa("PPI::Token::Quote::Single")
l!l&&r!l&&!r
000
MC/DC0%0/3
$element->isa("PPI::Token::Number::Float") or $element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::Quote::Double")
$element->isa("PPI::Token::Number::Float") $element->isa("PPI::Token::Quote::Single") $element->isa("PPI::Token::Quote::Double")
Truth table0%0/4
A or B or C
A= $element->isa("PPI::Token::Number::Float")B= $element->isa("PPI::Token::Quote::Single")C= $element->isa("PPI::Token::Quote::Double")
ABCresult
1XX1
01X1
0011
0000
94 || $element->isa('PPI::Token::Quote::Single')
95 || $element->isa('PPI::Token::Quote::Double'))
96 {
97  
98 0 my $version_string = $element->content;
99  
100 0 $version_string =~ s/^(?:['|"])//;
101 0 $version_string =~ s/(?:['|"])$//;
102 0 ▶ next if $version_string !~ m{\A(?:[\d|v])};
Branch: 1 branch
BranchTrueFalseTotal
unless $version_string =~ /\A(?:[\d|v])/ 0 0 0
103  
104 0 ▶ $version_string
Branch: 1 branch
BranchTrueFalseTotal
version::is_lax($version_string) ? : 0 0 0
105 = version::is_lax($version_string)
106 ? $version_string
107 : 0;
108  
109 0 ▶ print "found version_string - $version_string\n"
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
110 if $self->debug;
111 0 ▶ try {
Subroutine __ANON__: not called CC=2 SCAR=17.9
112 0 ▶ if ($previous_module) {
Branch: 1 branch
BranchTrueFalseTotal
if ($previous_module) 0 0 0
113 0 $self->{found_version}{$previous_module}
114 = $version_string;
115 0 $version_strings[$#modules] = $version_string;
116 }
117  
118 0 $previous_module = undef;
119 0 };
120 }
121 }
122 }
123 }
124 }
125 }
126 }
127 }
128 }
129 }
130 }
131  
132 0 ▶ @version_strings = map { defined $_ ? $_ : 0 } @version_strings;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
133 0 ▶ p @modules if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
134 0 ▶ p @version_strings if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
135  
136 0 ▶ if (scalar @modules > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @modules > 0) 0 0 0
137  
138 0 for (0 .. $#modules) {
139 0 ▶ print "Info: UseOk -> Sending $modules[$_] - $version_strings[$_]\n"
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose == 2 0 0 0
140 if ($self->verbose == TWO);
141 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
142 0 $self->_process_found_modules(
143 $phase_relationship, $modules[$_], $version_strings[$_],
144 __PACKAGE__, $phase_relationship,
145 );
146 0 };
147 }
148 }
149 0 return;
150 }
151  
152 2 ▶no Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
153  
154 2 1;
155  
156 __END__
↑ Summary Midgen/Role/TestRequires.pm »