« 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
| |||||||||||||||||||||||||||||
| 21 | 0 | $c->add($used_module => shift @$tokens); | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 7 | ▶ | while(my $token = shift @$tokens) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 18 | ▶ | next if ref $token; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 61 | 15 | ▶ | if (!ref $token) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 4 | ▶ | if ($saw_any_moose) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 73 | 3 | $saw_any_moose = 1; | |||||||||||||||||||||||||||
| 74 | 3 | next; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | 8 | ▶ | my $desc = $token->[1] || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$token->[1] || ''
MC/DC0%0/1
$token->[1] || ''
$token->[1]
Truth table50%1/2
A
A= $token->[1]
| |||||||||||||||||||||||||||||
| 77 | 8 | ▶ | if ($desc eq '{}') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my @hash_tokens = @{$token->[0] || []}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | for(my $i = 0, my $len = @hash_tokens; $i < $len; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($hash_tokens[$i][0] eq '-version' and $i < $len - 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$hash_tokens[$i][0] eq "-version" and $i < $len - 2
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 84 | 0 | $maybe_version = $maybe_version->[0]; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ($prev and is_version($maybe_version)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$prev and is_version($maybe_version)
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)
| |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($saw_any_moose) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
$saw_any_moose and $desc eq "()"
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 "()"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 100 | 2 | my $module = "Mouse$token_in_parentheses"; | |||||||||||||||||||||||||||
| 101 | 2 | ▶ | $c->add_recommendation($module => 0) if is_module_name($module); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 88 | 1; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | __END__ | ||||||||||||||||||||||||||||