blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/ClassAutouse.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 12 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 66 SCAR 40.3
CC
7
Cov
0%
parse_class_autouse_args
20.0
parse_autouse_method_args
20.0
register
2.0
CRAP 56.0
1 package Perl::PrereqScanner::NotQuiteLite::Parser::ClassAutouse;
2  
3 use strict;
4 use warnings;
5 use Perl::PrereqScanner::NotQuiteLite::Util;
6  
7 sub register { return {
8 use => {
9 'Class::Autouse' => 'parse_class_autouse_args',
10 },
11 }}
12  
13 sub parse_class_autouse_args {
14 my ($class, $c, $used_module, $raw_tokens) = @_;
15  
16 my $tokens = convert_string_tokens($raw_tokens);
17 if (is_version($tokens->[0])) {
18 $c->add($used_module => shift @$tokens);
19 }
20 while(my $token = shift @$tokens) {
21 my $module = $token;
22 if (ref $module) {
23 $module = $module->[0];
24 }
25 if (is_module_name($module)) {
26 $c->add_recommendation($module => 0);
27 }
28 }
29  
30 $c->register_method_parser(
31 'autouse',
32 [$class, 'parse_autouse_method_args', $used_module],
33 );
34 }
35  
36 sub parse_autouse_method_args {
37 my ($class, $c, $used_module, $raw_tokens) = @_;
38 my $tokens = convert_string_tokens($raw_tokens);
39  
40 # Check class
41 my ($klass, $arrow, $method, @args) = @$tokens;
42 return unless $klass and ref $klass and $klass->[0] eq $used_module;
43 return unless $method and ref $method and $method->[0] eq 'autouse';
44 for my $arg (@args) {
45 next if ref $arg;
46 $c->add_recommendation($arg => 0);
47 }
48 }
49  
50 1;
51  
52 __END__