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

filter: Statementstmt 95.5% 64 / 67 Branchbran 81.2% 26 / 32 Conditioncond 44.8% 13 / 29 MC/DCmcdc 13.3% 2 / 15 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 7 totaltotal 71.2% 114 / 160 SCAR 36.0
CC
30
Cov
80%
parse_load_first_existing_class_args
13.1
parse_load_class_args
7.6
parse_try_load_class_args
7.6
CRAP 36.7
« lib/Perl/PrereqScanner/NotQuiteLite/Parser/ClassAccessor.pm ↑ Summary lib/Perl/PrereqScanner/NotQuiteLite/Util.pm »
1 package Perl::PrereqScanner::NotQuiteLite::Parser::ClassLoad;
2  
3 88 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 88 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 88 ▶use Perl::PrereqScanner::NotQuiteLite::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 88 my %known_functions = map {$_ => 1} qw/
8 load_class try_load_class load_optional_class
9 load_first_existing_class
10 /;
11  
12 sub register { return {
13 87 ▶ use => {
Subroutine register: called CC=1 SCAR=0.0
Pod undocumented
14 'Class::Load' => 'parse_class_load_args',
15 },
16 }}
17  
18 sub register_fqfn { return {
19 743 ▶ map { "Class::Load::".$_ => "parse_".$_."_args" }
Subroutine register_fqfn: called CC=1 SCAR=0.0
Pod undocumented
20 keys %known_functions
21 }}
22  
23 sub parse_class_load_args {
24 11 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_class_load_args: called CC=7 SCAR=19.8
Pod undocumented
25  
26 11 my $tokens = convert_string_tokens($raw_tokens);
27 11 ▶ if (is_version($tokens->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_version($tokens->[0])) 0 11 11
28 0 $c->add($used_module => shift @$tokens);
29 }
30  
31 11 for my $token (@$tokens) {
32 21 ▶ next if ref $token;
Branch: 1 branch
BranchTrueFalseTotal
if ref $token 11 10 21
33  
34 10 ▶ if ($known_functions{$token}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($known_functions{$token}) { } 7 3 10
elsif ($token eq ':all') { } 3 0 3
35 7 $c->register_keyword_parser(
36 $token,
37 [$class, 'parse_'.$token.'_args', $used_module],
38 );
39 } elsif ($token eq ':all') {
40 3 for my $func (keys %known_functions) {
41 12 $c->register_keyword_parser(
42 $func,
43 [$class, 'parse_'.$func.'_args', $used_module],
44 );
45 }
46 }
47 }
48 }
49  
50 sub parse_load_class_args {
51 6 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_load_class_args: called CC=7 SCAR=20.3
Pod undocumented
52  
53 6 my $tokens = convert_string_tokens($raw_tokens);
54 6 shift @$tokens; # function
55 6 my ($module, undef, $options) = @$tokens;
56 6 my $version = 0;
57 6 ▶ if (ref $options and $options->[1] eq '{}') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $options and $options->[1] eq "{}") 1 5 6
Condition66%2/3
ref $options and $options->[1] eq "{}"
!ll&&!rl&&r
501
MC/DC50%1/2
ref $options and $options->[1] eq "{}"
ref $options $options->[1] eq "{}"
Truth table66%2/3
A and B
A= ref $optionsB= $options->[1] eq "{}"
ABresult
0X0
100
111
58 1 my $tokens_in_hashref = convert_string_tokens($options->[0]);
59 1 ▶ while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($key, undef, $value, undef) = splice(@$tokens_in_hashref, 0, 4)) 1 1 2
60 1 ▶ if (ref $key and $key->[0] eq '-version' and is_version($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $key and $key->[0] eq "-version" and is_version($value)) 1 0 1
Condition33%2/6
ref $key and $key->[0] eq "-version" and is_version($value)
!ll&&!rl&&r
001
ref $key and $key->[0] eq "-version"
!ll&&!rl&&r
001
MC/DC0%0/3
ref $key and $key->[0] eq "-version" and is_version($value)
ref $key $key->[0] eq "-version" is_version($value)
Truth table25%1/4
A and B and C
A= ref $keyB= $key->[0] eq "-version"C= is_version($value)
ABCresult
0XX0
10X0
1100
1111
61 1 $version = $value;
62 }
63 }
64 }
65 6 $c->add_conditional($module => $version);
66 }
67  
68 sub parse_try_load_class_args {
69 3 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_try_load_class_args: called CC=7 SCAR=20.3
Pod undocumented
70  
71 3 my $tokens = convert_string_tokens($raw_tokens);
72 3 shift @$tokens; # function
73 3 my ($module, undef, $options) = @$tokens;
74 3 my $version = 0;
75 3 ▶ if (ref $options and $options->[1] eq '{}') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $options and $options->[1] eq "{}") 1 2 3
Condition66%2/3
ref $options and $options->[1] eq "{}"
!ll&&!rl&&r
201
MC/DC50%1/2
ref $options and $options->[1] eq "{}"
ref $options $options->[1] eq "{}"
Truth table66%2/3
A and B
A= ref $optionsB= $options->[1] eq "{}"
ABresult
0X0
100
111
76 1 my $tokens_in_hashref = convert_string_tokens($options->[0]);
77 1 ▶ while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($key, undef, $value, undef) = splice(@$tokens_in_hashref, 0, 4)) 1 1 2
78 1 ▶ if (ref $key and $key->[0] eq '-version' and is_version($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $key and $key->[0] eq "-version" and is_version($value)) 1 0 1
Condition33%2/6
ref $key and $key->[0] eq "-version" and is_version($value)
!ll&&!rl&&r
001
ref $key and $key->[0] eq "-version"
!ll&&!rl&&r
001
MC/DC0%0/3
ref $key and $key->[0] eq "-version" and is_version($value)
ref $key $key->[0] eq "-version" is_version($value)
Truth table25%1/4
A and B and C
A= ref $keyB= $key->[0] eq "-version"C= is_version($value)
ABCresult
0XX0
10X0
1100
1111
79 1 $version = $value;
80 }
81 }
82 }
83 3 $c->add_suggestion($module => $version);
84 }
85  
86 sub parse_load_optional_class_args {
87 0 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_load_optional_class_args: not called CC=1 SCAR=6.9
Pod undocumented
88  
89 0 $class->parse_try_load_class_args($c, $used_module, $raw_tokens);
90 }
91  
92 sub parse_load_first_existing_class_args {
93 2 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_load_first_existing_class_args: called CC=12 SCAR=25.7
Pod undocumented
94  
95 2 my $tokens = convert_string_tokens($raw_tokens);
96 2 shift @$tokens; # function
97 2 my ($module, $version);
98 2 for my $token (@$tokens) {
99 14 ▶ if (is_module_name($token)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_module_name($token)) 5 9 14
100 5 ▶ if ($module) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module) 3 2 5
101 3 $c->add_suggestion($module => $version);
102 }
103 5 $module = $token;
104 5 $version = 0;
105 5 next;
106 }
107 9 ▶ if (ref $token and ($token->[1] || '') eq '{}') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $token and ($token->[1] || "") eq "{}") 2 7 9
Condition60%3/5
ref $token and ($token->[1] || "") eq "{}"
!ll&&!rl&&r
072
$token->[1] || ''
l!l
90
MC/DC0%0/2
ref $token and ($token->[1] || "") eq "{}"
ref $token $token->[1]
Truth table33%1/3
A and B
A= ref $tokenB= $token->[1]
ABresult
0X0
100
111
108 2 my $tokens_in_hashref = convert_string_tokens($token->[0]);
109 2 ▶ while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($key, undef, $value, undef) = splice(@$tokens_in_hashref, 0, 4)) 2 2 4
110 2 ▶ if (ref $key and $key->[0] eq '-version' and is_version($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $key and $key->[0] eq "-version" and is_version($value)) 2 0 2
Condition33%2/6
ref $key and $key->[0] eq "-version" and is_version($value)
!ll&&!rl&&r
002
ref $key and $key->[0] eq "-version"
!ll&&!rl&&r
002
MC/DC0%0/3
ref $key and $key->[0] eq "-version" and is_version($value)
ref $key $key->[0] eq "-version" is_version($value)
Truth table25%1/4
A and B and C
A= ref $keyB= $key->[0] eq "-version"C= is_version($value)
ABCresult
0XX0
10X0
1100
1111
111 2 $version = $value;
112 }
113 }
114 }
115 }
116 2 ▶ if ($module) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module) 2 0 2
117 2 $c->add_suggestion($module => $version);
118 }
119 }
120  
121 88 1;
122  
123 __END__
« lib/Perl/PrereqScanner/NotQuiteLite/Parser/ClassAccessor.pm ↑ Summary lib/Perl/PrereqScanner/NotQuiteLite/Util.pm »