File Coverage

blib/lib/App/MigrateToTest2V0/Rule/ReplaceIsaOkHASHOrArrayToRefOk.pm
Criterion Covered Total %
statement 23 23 100.0
branch 6 8 75.0
condition 3 3 100.0
subroutine 6 6 100.0
pod 0 1 0.0
total 38 41 92.6


line stmt bran cond sub pod time code
1             package App::MigrateToTest2V0::Rule::ReplaceIsaOkHASHOrArrayToRefOk;
2 4     4   1474 use strict;
  4         10  
  4         127  
3 4     4   23 use warnings;
  4         8  
  4         171  
4 4     4   27 use parent 'App::MigrateToTest2V0::Rule';
  4         10  
  4         75  
5 4     4   1790 use PPIx::Utils qw(parse_arg_list);
  4         46609  
  4         1172  
6              
7             sub apply {
8 14     14 0 58 my ($class, $doc) = @_;
9              
10             my $stmts = $doc->find(sub {
11 339     339   4654 my (undef, $elem) = @_;
12 339   100     1379 return $elem->isa('PPI::Statement') && $elem->first_token && $elem->first_token->content eq 'isa_ok';
13 14         125 });
14 14 100       244 return unless $stmts;
15              
16 4         16 for my $stmt (@$stmts) {
17 4         16 my $second_arg = (parse_arg_list($stmt->first_token))[1]->[0];
18 4 50       1099 next unless $second_arg;
19 4 50       21 next unless $second_arg->isa('PPI::Token::Quote');
20              
21 4 100       14 if ($second_arg->content =~ /HASH|ARRAY/) {
22 2         30 $stmt->first_token->set_content('ref_ok');
23             }
24             }
25             }
26              
27             1;