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

filter: Statementstmt 94.2% 33 / 35 Branchbran 72.2% 13 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 85.0% 51 / 60 SCAR 24.2
CC
11
Cov
87%
parse_syntax_collector_args
11.6
BEGIN
1.0
BEGIN
1.0
CRAP 11.3
« lib/Perl/PrereqScanner/NotQuiteLite/Parser/Superclass.pm ↑ Summary lib/Perl/PrereqScanner/NotQuiteLite/Parser/Unless.pm »
1 package Perl::PrereqScanner::NotQuiteLite::Parser::SyntaxCollector;
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 { return {
8 87 ▶ use => {
Subroutine register: called CC=1 SCAR=0.0
Pod undocumented
9 'Syntax::Collector' => 'parse_syntax_collector_args',
10 },
11 }}
12  
13 sub parse_syntax_collector_args {
14 3 ▶ my ($class, $c, $used_module, $raw_tokens) = @_;
Subroutine parse_syntax_collector_args: called CC=11 SCAR=24.5
Pod undocumented
15  
16 3 my $tokens = convert_string_token_list($raw_tokens);
17  
18 3 ▶ if (is_version($tokens->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_version($tokens->[0])) 0 3 3
19 0 $c->add($used_module => shift @$tokens);
20 }
21  
22 3 my $spec;
23 3 ▶ if (!(@$tokens % 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @$tokens % 2) { } 2 1 3
24 2 ▶ while(my ($key, $value) = splice @$tokens, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@$tokens, 0, 2)) 1 1 2
25 1 ▶ my $keystr = ref $key ? $key->[0] : $key;
Branch: 1 branch
BranchTrueFalseTotal
ref $key ? : 1 0 1
26 1 ▶ if ($keystr eq '-collect') {
Branch: 1 branch
BranchTrueFalseTotal
if ($keystr eq "-collect") 1 0 1
27 1 $spec = $value;
28 1 last;
29 }
30 }
31 } else {
32 1 $spec = $tokens->[0];
33 }
34 3 ▶ if (ref $spec) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $spec) 0 3 3
35 0 $spec = $spec->[0];
36 }
37 3 ▶ return unless $spec;
Branch: 1 branch
BranchTrueFalseTotal
unless $spec 1 2 3
38  
39 my @features =
40 map {
41 6 ▶ m{^
Branch: 2 branches
BranchTrueFalseTotal
/^ (use|no) \s+ # "use" or "no" (\S+) \s+ # module name ([\d\._v]+) # module version (?: # everything else \s* (.+) )? # ... perhaps [;] \s* # semicolon $/x ? : 6 0 6
defined $4 ? : 4 2 6
42 (use|no) \s+ # "use" or "no"
43 (\S+) \s+ # module name
44 ([\d\._v]+) # module version
45 (?: # everything else
46 \s* (.+)
47 )? # ... perhaps
48 [;] \s* # semicolon
49 $}x
50 ? [$1, $2, $3, [ defined($4) ? eval "($4)" : ()] ]
51 : die("Line q{$_} doesn't conform to 'use MODULE VERSION [ARGS];'")
52 }
53 6 grep { ! m/^#/ } # not a comment
54 16 grep { m/[A-Z0-9]/i } # at least one alphanum
55 16 map { s/(^\s+)|(\s+$)//; $_ } # trim
56 2 map { split /(\r?\n|\r)/ } # split lines
57 $spec;
58  
59 2 for my $feature (@features) {
60 6 $c->add($feature->[1], $feature->[2]);
61 }
62 }
63  
64 88 1;
65  
66 __END__
« lib/Perl/PrereqScanner/NotQuiteLite/Parser/Superclass.pm ↑ Summary lib/Perl/PrereqScanner/NotQuiteLite/Parser/Unless.pm »