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

filter: Statementstmt 74.1% 46 / 62 Branchbran 52.7% 19 / 36 Conditioncond 36.3% 4 / 11 MC/DCmcdc 28.5% 2 / 7 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 5 totaltotal 60.7% 79 / 130 SCAR 39.6
CC
24
Cov
63%
_parse_loader_args
57.3
parse_any_moose_args
5.1
remove_extends_and_with
2.0
CRAP 52.5
« blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/UniversalVersion.pm ↑ Summary blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/Inline.pm »
1 package Perl::PrereqScanner::NotQuiteLite::Parser::AnyMoose;
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 sub register {{
8 87 ▶ use => {
Subroutine register: called CC=1 SCAR=0.0
Pod undocumented
9 'Any::Moose' => 'parse_any_moose_args',
10 },
11 no => {
12 'Any::Moose' => 'remove_extends_and_with',
13 },
14 }}
15  
16 sub parse_any_moose_args {
17 7 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_any_moose_args: called CC=5 SCAR=16.3
Pod undocumented
18  
19 7 my $tokens = convert_string_tokens($raw_tokens);
20 7 ▶ if (is_version($tokens->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_version($tokens->[0])) 0 7 7
21 0 $c->add($used_module => shift @$tokens);
22 }
23 7 ▶ while(my $token = shift @$tokens) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = shift @$tokens) 18 7 25
24 18 ▶ next if ref $token;
Branch: 1 branch
BranchTrueFalseTotal
if ref $token 13 5 18
25  
26 # As Any::Moose falls back to Mouse, it's nice to have
27 # a Mouse variant, but that should not be required.
28 5 my $module = "Mouse$token";
29 5 ▶ $c->add_recommendation($module => 0) if is_module_name($module);
Branch: 1 branch
BranchTrueFalseTotal
if is_module_name($module) 5 0 5
30 }
31  
32 $c->register_keyword_parser(
33 7 'extends',
34 [$class, 'parse_extends_args', $used_module],
35 );
36 7 $c->register_keyword_parser(
37 'with',
38 [$class, 'parse_with_args', $used_module],
39 );
40 }
41  
42 sub remove_extends_and_with {
43 0 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine remove_extends_and_with: not called CC=1 SCAR=6.9
Pod undocumented
44  
45 0 $c->remove_keyword('extends');
46 0 $c->remove_keyword('with');
47 }
48  
49 4 ▶sub parse_extends_args { shift->_parse_loader_args(@_) }
Subroutine parse_extends_args: called CC=1 SCAR=0.0
Pod undocumented
50 1 ▶sub parse_with_args { shift->_parse_loader_args(@_) }
Subroutine parse_with_args: called CC=1 SCAR=0.0
Pod undocumented
51  
52 sub _parse_loader_args {
53 5 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine _parse_loader_args: called CC=20 SCAR=40.5
54  
55 5 my $tokens = convert_string_tokens($raw_tokens);
56 5 shift @$tokens; # discard extends, with;
57  
58 5 my $prev;
59 my $saw_any_moose;
60 5 ▶ while(my $token = shift @$tokens) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = shift @$tokens) 15 5 20
61 15 ▶ if (!ref $token) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $token) 4 11 15
62 4 ▶ if ($saw_any_moose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($saw_any_moose) { } 2 2 4
63 2 my $module = "Mouse$token";
64 2 $c->add_recommendation($module => 0);
65 2 $prev = $module;
66 } else {
67 2 $c->add($token => 0);
68 2 $prev = $token;
69 }
70 4 next;
71 }
72 11 ▶ if ($token->[0] eq 'any_moose') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[0] eq "any_moose") 3 8 11
73 3 $saw_any_moose = 1;
74 3 next;
75 }
76 8 ▶ my $desc = $token->[1] || '';
Condition50%1/2
$token->[1] || ''
l!l
80
MC/DC0%0/1
$token->[1] || ''
$token->[1]
Truth table50%1/2
A
A= $token->[1]
Aresult
11
00
77 8 ▶ if ($desc eq '{}') {
Branch: 1 branch
BranchTrueFalseTotal
if ($desc eq "{}") 0 8 8
78 0 ▶ my @hash_tokens = @{$token->[0] || []};
Branch: 1 branch
BranchTrueFalseTotal
$token->[0] or [] 0 0 0
79 0 ▶ for(my $i = 0, my $len = @hash_tokens; $i < $len; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $len) 0 0 0
80 0 ▶ if ($hash_tokens[$i][0] eq '-version' and $i < $len - 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash_tokens[$i][0] eq "-version" and $i < $len - 2) 0 0 0
Condition0%0/3
$hash_tokens[$i][0] eq "-version" and $i < $len - 2
!ll&&!rl&&r
000
MC/DC0%0/2
$hash_tokens[$i][0] eq "-version" and $i < $len - 2
$hash_tokens[$i][0] eq "-version" $i < $len - 2
Truth table0%0/3
A and B
A= $hash_tokens[$i][0] eq "-version"B= $i < $len - 2
ABresult
0X0
100
111
81 0 my $maybe_version_token = $hash_tokens[$i + 2];
82 0 my $maybe_version = $maybe_version_token->[0];
83 0 ▶ if (ref $maybe_version) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $maybe_version) 0 0 0
84 0 $maybe_version = $maybe_version->[0];
85 }
86 0 ▶ if ($prev and is_version($maybe_version)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prev and is_version($maybe_version)) 0 0 0
Condition0%0/3
$prev and is_version($maybe_version)
!ll&&!rl&&r
000
MC/DC0%0/2
$prev and is_version($maybe_version)
$prev is_version($maybe_version)
Truth table0%0/3
A and B
A= $prevB= is_version($maybe_version)
ABresult
0X0
100
111
87 0 ▶ if ($saw_any_moose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($saw_any_moose) { } 0 0 0
88 0 $c->add_recommendation($prev => $maybe_version);
89 } else {
90 0 $c->add($prev => $maybe_version);
91 }
92 }
93 }
94 }
95 }
96 8 ▶ if ($saw_any_moose and $desc eq '()') {
Branch: 1 branch
BranchTrueFalseTotal
if ($saw_any_moose and $desc eq "()") 2 6 8
Condition100%3/3
$saw_any_moose and $desc eq "()"
!ll&&!rl&&r
242
MC/DC100%2/2
$saw_any_moose and $desc eq "()"
$saw_any_moose $desc eq "()"
Truth table100%3/3
A and B
A= $saw_any_mooseB= $desc eq "()"
ABresult
0X0
100
111
97 2 my $tokens_in_parentheses = convert_string_tokens($token->[0]);
98 2 for my $token_in_parentheses (@$tokens_in_parentheses) {
99 2 ▶ next if ref $token_in_parentheses;
Branch: 1 branch
BranchTrueFalseTotal
if ref $token_in_parentheses 0 2 2
100 2 my $module = "Mouse$token_in_parentheses";
101 2 ▶ $c->add_recommendation($module => 0) if is_module_name($module);
Branch: 1 branch
BranchTrueFalseTotal
if is_module_name($module) 2 0 2
102 }
103 }
104 }
105 }
106  
107 88 1;
108  
109 __END__
« blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/UniversalVersion.pm ↑ Summary blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/Inline.pm »