File Coverage

blib/lib/App/MigrateToTest2V0/Rule/Translate2ndArgumentOfIsaOkWithArrayRef.pm
Criterion Covered Total %
statement 24 24 100.0
branch 3 4 75.0
condition 3 3 100.0
subroutine 6 6 100.0
pod 0 1 0.0
total 36 38 94.7


line stmt bran cond sub pod time code
1             package App::MigrateToTest2V0::Rule::Translate2ndArgumentOfIsaOkWithArrayRef;
2 4     4   1258 use strict;
  4         10  
  4         136  
3 4     4   22 use warnings;
  4         12  
  4         135  
4 4     4   20 use parent 'App::MigrateToTest2V0::Rule';
  4         11  
  4         32  
5 4     4   1409 use PPIx::Utils qw(parse_arg_list);
  4         15  
  4         1328  
6              
7             sub apply {
8 14     14 0 54 my ($class, $doc) = @_;
9              
10             my $stmts = $doc->find(sub {
11 339     339   4455 my (undef, $elem) = @_;
12 339   100     1294 return $elem->isa('PPI::Statement') && $elem->first_token && $elem->first_token->content eq 'isa_ok';
13 14         98 });
14 14 100       234 return unless $stmts;
15              
16 2         9 for my $stmt (@$stmts) {
17 2         7 my $second_arg = (parse_arg_list($stmt->first_token))[1]->[0];
18 2 50       413 next unless $second_arg;
19              
20 2         10 my $first_paren = PPI::Token::Structure->new('[');
21 2         19 my $last_paren = PPI::Token::Structure->new(']');
22 2         23 $second_arg->insert_before($first_paren);
23 2         143 $second_arg->insert_after($last_paren);
24             }
25             }
26              
27             1;