PRT/Command/IntroduceVariables.pm

filter: Statementstmt 100% 31 / 31 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 4 totaltotal 89.3% 42 / 47 CC 5 SCAR 7.7
CC
5
Cov
97%
collect_variables
4.0
execute
2.0
BEGIN
1.0
CRAP 2.2
« PRT/Command/MoveClassMethod.pm ↑ Summary PRT/Collector/AllFiles.pm »
1 package App::PRT::Command::IntroduceVariables;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use PPI;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
7 4 my ($class) = @_;
8 4 bless {}, $class;
9 }
10  
11 1 ▶sub parse_arguments {
Subroutine parse_arguments: called CC=1 SCAR=0.0
Pod undocumented
12 1 my ($self, @arguments) = @_;
13 2 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 @arguments;
15 }
16  
17 1 ▶sub execute {
Subroutine execute: called CC=2 SCAR=6.9
Pod undocumented
18 1 my ($self, $file, $out) = @_;
19  
20 1 my $variables = $self->collect_variables($file);
21 1 for my $variable (@$variables) {
22 6 say $out $variable;
23 }
24 }
25  
26 2 ▶sub collect_variables {
Subroutine collect_variables: called CC=4 SCAR=13.9
Pod undocumented
27 2 my ($self, $file) = @_;
28 2 my $document = PPI::Document->new($file);
29  
30 2 my $knowns = {};
31 2 my $variables = [];
32 2 my $tokens = $document->find('PPI::Token::Symbol');
33 2 ▶ return [] unless $tokens;
Branch: 1 branch
BranchTrueFalseTotal
unless $tokens 0 2 2
34  
35 2 for my $token (@$tokens) {
36 20 ▶ next if $knowns->{$token}++;
Branch: 1 branch
BranchTrueFalseTotal
if $knowns->{$token}++ 8 12 20
37  
38 12 push @$variables, $token->content;
39 }
40  
41 2 $variables;
42 }
43  
44 2 1;
« PRT/Command/MoveClassMethod.pm ↑ Summary PRT/Collector/AllFiles.pm »