lib/Perl/PrereqScanner/NotQuiteLite/Parser/Core.pm

filter: Statementstmt 92.5% 87 / 94 Branchbran 84.2% 59 / 70 Conditioncond 68.0% 34 / 50 MC/DCmcdc 47.8% 11 / 23 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 7 totaltotal 79.1% 201 / 254 SCAR 41.9
CC
54
Cov
84%
parse_parent_args
16.5
parse_base_args
13.5
parse_package
9.8
CRAP 65.7
« blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/ClassAccessor.pm ↑ Summary lib/Perl/PrereqScanner/NotQuiteLite/Parser/MooseXDeclare.pm »
1 package Perl::PrereqScanner::NotQuiteLite::Parser::Core;
2  
3 91 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 91 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 91 ▶use Perl::PrereqScanner::NotQuiteLite::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 91 my %feature_since = (
8 say => '5.010',
9 state => '5.010',
10 switch => '5.010',
11 unicode_strings => '5.012',
12 current_sub => '5.016',
13 evalbytes => '5.016',
14 fc => '5.016',
15 arybase => '5.016',
16 unicode_eval => '5.016',
17 lexical_subs => '5.018',
18 postderef => '5.020',
19 postderef_qq => '5.020',
20 signatures => '5.020',
21 bitwise => '5.022',
22 refaliasing => '5.022',
23 declared_refs => '5.026',
24 );
25  
26 sub register { return {
27 90 ▶ use => {
Subroutine register: called CC=1 SCAR=0.0
Pod undocumented
28 if => 'parse_if_args',
29 base => 'parse_base_args',
30 parent => 'parse_parent_args',
31 feature => 'parse_feature_args',
32 },
33 keyword => {
34 package => 'parse_package',
35 exit => 'parse_begin_exit',
36 },
37 }}
38  
39 sub parse_if_args {
40 9 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_if_args: called CC=8 SCAR=22.8
Pod undocumented
41  
42 9 ▶ while(my $token = shift @$raw_tokens) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = shift @$raw_tokens) 20 0 20
43 20 ▶ last if $token->[1] eq 'COMMA';
Branch: 1 branch
BranchTrueFalseTotal
if $token->[1] eq "COMMA" 9 11 20
44 }
45  
46 9 my $tokens = convert_string_tokens($raw_tokens);
47 9 my $module = shift @$tokens;
48 9 ▶ if (ref $module and ($module->[1] eq 'WORD' or $module->[1] eq 'KEYWORD')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $module and $module->[1] eq "WORD" || $module->[1] eq "KEYWORD") 4 5 9
Condition66%4/6
ref $module and $module->[1] eq "WORD" || $module->[1] eq "KEYWORD"
!ll&&!rl&&r
504
$module->[1] eq "WORD" or $module->[1] eq "KEYWORD"
l!l&&r!l&&!r
220
MC/DC33%1/3
ref $module and $module->[1] eq "WORD" || $module->[1] eq "KEYWORD"
ref $module $module->[1] eq "WORD" $module->[1] eq "KEYWORD"
Truth table50%2/4
A and B or C
A= ref $moduleB= $module->[1] eq "WORD"C= $module->[1] eq "KEYWORD"
ABCresult
0XX0
1000
11X1
1011
49 4 $module = $module->[0];
50 }
51 9 ▶ if (is_module_name($module)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_module_name($module)) { } 9 0 9
52 9 ▶ if (is_version($tokens->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_version($tokens->[0])) { } 0 9 9
53 0 my $version = shift @$tokens;
54 0 $c->add_recommendation($module => $version);
55 } else {
56 9 $c->add_recommendation($module => 0);
57 }
58 } else {
59 0 push @{$c->{errors}}, "use if module not found";
60 }
61 }
62  
63 sub parse_base_args {
64 24 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_base_args: called CC=13 SCAR=26.0
Pod undocumented
65  
66 24 my $tokens = convert_string_tokens($raw_tokens);
67 24 ▶ if (is_version($tokens->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_version($tokens->[0])) 0 24 24
68 0 $c->add($used_module => shift @$tokens);
69 }
70 24 ▶ while(my $token = shift @$tokens) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = shift @$tokens) 57 24 81
71 57 my $module = $token;
72 57 ▶ if (ref $module and ($module->[1] || '') eq 'WORD') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $module and ($module->[1] || "") eq "WORD") 2 55 57
Condition100%5/5
ref $module and ($module->[1] || "") eq "WORD"
!ll&&!rl&&r
26292
$module->[1] || ''
l!l
292
MC/DC100%2/2
ref $module and ($module->[1] || "") eq "WORD"
ref $module $module->[1]
Truth table100%3/3
A and B
A= ref $moduleB= $module->[1]
ABresult
0X0
100
111
73 # allow bareword, but disallow function()
74 2 $module = $module->[0];
75 2 ▶ next if @$tokens and ref $tokens->[0] and ($tokens->[0][1] || '') eq '()';
Branch: 1 branch
BranchTrueFalseTotal
if @$tokens and ref $tokens->[0] and ($tokens->[0][1] || "") eq "()" 1 1 2
Condition50%4/8
@$tokens and ref $tokens->[0] and ($tokens->[0][1] || "") eq "()"
!ll&&!rl&&r
011
@$tokens and ref $tokens->[0]
!ll&&!rl&&r
002
$tokens->[0][1] || ''
l!l
20
MC/DC0%0/3
@$tokens and ref $tokens->[0] and ($tokens->[0][1] || "") eq "()"
@$tokens ref $tokens->[0] $tokens->[0][1]
Truth table25%1/4
A and B and C
A= @$tokensB= ref $tokens->[0]C= $tokens->[0][1]
ABCresult
0XX0
10X0
1100
1111
76 }
77 # bareword in parentheses
78 56 ▶ if (ref $module and ref $module->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $module and ref $module->[0]) 3 53 56
Condition100%3/3
ref $module and ref $module->[0]
!ll&&!rl&&r
27263
MC/DC100%2/2
ref $module and ref $module->[0]
ref $module ref $module->[0]
Truth table100%3/3
A and B
A= ref $moduleB= ref $module->[0]
ABresult
0X0
100
111
79 3 $module = $module->[0][0];
80 }
81 56 ▶ if (is_module_name($module)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_module_name($module)) 28 28 56
82 28 $c->add($module => 0);
83 }
84 }
85 }
86  
87 sub parse_parent_args {
88 28 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_parent_args: called CC=16 SCAR=28.0
Pod undocumented
89  
90 28 my $tokens = convert_string_tokens($raw_tokens);
91 28 ▶ if (is_version($tokens->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_version($tokens->[0])) 0 28 28
92 0 $c->add($used_module => shift @$tokens);
93 }
94 28 ▶ while(my $token = shift @$tokens) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = shift @$tokens) 54 21 75
95 54 ▶ last if $token eq '-norequire';
Branch: 1 branch
BranchTrueFalseTotal
if $token eq "-norequire" 2 52 54
96 52 my $module = $token;
97 52 ▶ if (ref $token) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $token) 31 21 52
98 31 ▶ last if $token->[0] eq '-norequire';
Branch: 1 branch
BranchTrueFalseTotal
if $token->[0] eq "-norequire" 5 26 31
99 }
100 47 ▶ if (ref $module and ($module->[1] || '') eq 'WORD') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $module and ($module->[1] || "") eq "WORD") 2 45 47
Condition100%5/5
ref $module and ($module->[1] || "") eq "WORD"
!ll&&!rl&&r
21242
$module->[1] || ''
l!l
242
MC/DC100%2/2
ref $module and ($module->[1] || "") eq "WORD"
ref $module $module->[1]
Truth table100%3/3
A and B
A= ref $moduleB= $module->[1]
ABresult
0X0
100
111
101 # allow bareword, but disallow function()
102 2 $module = $module->[0];
103 2 ▶ next if @$tokens and ref $tokens->[0] and ($tokens->[0][1] || '') eq '()';
Branch: 1 branch
BranchTrueFalseTotal
if @$tokens and ref $tokens->[0] and ($tokens->[0][1] || "") eq "()" 1 1 2
Condition50%4/8
@$tokens and ref $tokens->[0] and ($tokens->[0][1] || "") eq "()"
!ll&&!rl&&r
011
@$tokens and ref $tokens->[0]
!ll&&!rl&&r
002
$tokens->[0][1] || ''
l!l
20
MC/DC0%0/3
@$tokens and ref $tokens->[0] and ($tokens->[0][1] || "") eq "()"
@$tokens ref $tokens->[0] $tokens->[0][1]
Truth table25%1/4
A and B and C
A= @$tokensB= ref $tokens->[0]C= $tokens->[0][1]
ABCresult
0XX0
10X0
1100
1111
104 }
105 # bareword in parentheses
106 46 ▶ if (ref $module and ref $module->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $module and ref $module->[0]) 3 43 46
Condition100%3/3
ref $module and ref $module->[0]
!ll&&!rl&&r
22213
MC/DC100%2/2
ref $module and ref $module->[0]
ref $module ref $module->[0]
Truth table100%3/3
A and B
A= ref $moduleB= ref $module->[0]
ABresult
0X0
100
111
107 3 $module = $module->[0][0];
108 }
109 46 ▶ $c->add($module => 0) if is_module_name($module);
Branch: 1 branch
BranchTrueFalseTotal
if is_module_name($module) 23 23 46
110 }
111 }
112  
113 sub parse_feature_args {
114 10 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_feature_args: called CC=6 SCAR=18.0
Pod undocumented
115  
116 10 $c->add_perl('5.010', 'feature');
117 10 my $tokens = convert_string_tokens($raw_tokens);
118 10 ▶ if (is_version($tokens->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_version($tokens->[0])) 0 10 10
119 0 $c->add($used_module => shift @$tokens);
120 }
121 10 ▶ while(my $token = shift @$tokens) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = shift @$tokens) 19 10 29
122 19 ▶ next if ref $token;
Branch: 1 branch
BranchTrueFalseTotal
if ref $token 10 9 19
123 9 ▶ if (exists $feature_since{$token}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $feature_since{$token}) 5 4 9
124 5 $c->add_perl($feature_since{$token} => "feature $token");
125 5 next;
126 }
127 4 ▶ if ($token =~ /^:5\.([0-9]+)(\.\[0-9]+)?/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token =~ /^:5\.([0-9]+)(\.\[0-9]+)?/) 4 0 4
128 4 my $version = sprintf '5.%03d', $1;
129 4 $c->add_perl($version, $token);
130 4 next;
131 }
132 }
133 }
134  
135 sub parse_begin_exit {
136 8 ▶ my ($class, $c, $raw_tokens) = @_;
Subroutine parse_begin_exit: called CC=7 SCAR=19.6
Pod undocumented
137  
138 8 ▶ my @stack = @{$c->{stack} || []};
Branch: 1 branch
BranchTrueFalseTotal
$c->{"stack"} or [] 0 8 8
139 8 ▶ if (grep {$_->[0] eq '{' and $_->[2] eq 'BEGIN'} @stack) {
Branch: 2 branches
BranchTrueFalseTotal
if (grep {$_->[0] eq "{" and $_->[2] eq "BEGIN";} @stack) 4 4 8
$_->[0] eq "{" and $_->[2] eq "BEGIN" 7 0 7
140 4 ▶ if (grep {$c->token_is_conditional($_->[0])} @$raw_tokens) {
Branch: 2 branches
BranchTrueFalseTotal
if (grep {$c->token_is_conditional($_->[0]);} @$raw_tokens) { } 1 3 4
elsif (grep {$_->[0] eq '{' and $c->token_is_conditional($_->[2]);} @stack) { } 1 2 3
141 1 $c->{force_cond} = 1;
142 4 ▶ } elsif (grep {$_->[0] eq '{' and $c->token_is_conditional($_->[2])} @stack) {
Branch: 1 branch
BranchTrueFalseTotal
$_->[0] eq "{" and $c->token_is_conditional($_->[2]) 4 0 4
143 1 $c->{force_cond} = 1;
144 } else {
145 2 $c->{ended} = 1;
146 2 @{$c->{stack}} = ();
147 }
148 }
149 }
150  
151 sub parse_package {
152 32 ▶ my ($class, $c, $raw_tokens) = @_;
Subroutine parse_package: called CC=9 SCAR=22.8
Pod undocumented
153  
154 32 my $tokens = convert_string_tokens($raw_tokens);
155 32 shift @$tokens; # drop "package"
156 32 my $token = shift @$tokens;
157 32 ▶ if (ref $token && $token->[1] && $token->[1] eq 'WORD') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $token and $token->[1] and $token->[1] eq "WORD") 31 1 32
Condition50%3/6
ref $token and $token->[1] and $token->[1] eq "WORD"
!ll&&!rl&&r
0131
ref $token and $token->[1]
!ll&&!rl&&r
0032
MC/DC33%1/3
ref $token and $token->[1] and $token->[1] eq "WORD"
ref $token $token->[1] $token->[1] eq "WORD"
Truth table50%2/4
A and B and C
A= ref $tokenB= $token->[1]C= $token->[1] eq "WORD"
ABCresult
0XX0
10X0
1100
1111
158 31 $c->add_package($token->[0]);
159 }
160 32 ▶ if (@$tokens) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$tokens) 32 0 32
161 32 $token = shift @$tokens;
162 32 ▶ if (is_version($token)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_version($token)) 5 27 32
163 5 $c->add_perl("5.012", "package PACKAGE VERSION");
164 5 $token = shift @$tokens;
165 }
166 32 ▶ if (ref $token && $token->[1] && $token->[1] =~ /^\{/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $token and $token->[1] and $token->[1] =~ /^\{/) 6 26 32
Condition50%3/6
ref $token and $token->[1] and $token->[1] =~ /^\{/
!ll&&!rl&&r
0266
ref $token and $token->[1]
!ll&&!rl&&r
0032
MC/DC33%1/3
ref $token and $token->[1] and $token->[1] =~ /^\{/
ref $token $token->[1] $token->[1] =~ /^\{/
Truth table50%2/4
A and B and C
A= ref $tokenB= $token->[1]C= $token->[1] =~ /^\{/
ABCresult
0XX0
10X0
1100
1111
167 6 $c->add_perl("5.014", "package PACKAGE (VERSION) {}");
168 }
169 }
170 }
171  
172 91 1;
173  
174 __END__
« blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/ClassAccessor.pm ↑ Summary lib/Perl/PrereqScanner/NotQuiteLite/Parser/MooseXDeclare.pm »