« lib/Perl/ToPerl6/Exception/Configuration/Option/Transformer/ParameterValue.pm
↑ Summary
lib/Perl/ToPerl6/TransformerParameter/Behavior/StringList.pm »
| 1 | package Perl::ToPerl6::Statistics; | ||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||
| 3 | 12 | ▶ | use 5.006001; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 4 | 12 | ▶ | use strict; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 5 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||
| 7 | 12 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||
| 9 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||
| 11 | 7 | ▶ | sub new { | ||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||
| 12 | 7 | my ( $class ) = @_; | |||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||
| 14 | 7 | my $self = bless {}, $class; | |||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||
| 16 | 7 | $self->{_modules} = 0; | |||||||||||||||||||||||||
| 17 | 7 | $self->{_subs} = 0; | |||||||||||||||||||||||||
| 18 | 7 | $self->{_statements} = 0; | |||||||||||||||||||||||||
| 19 | 7 | $self->{_lines} = 0; | |||||||||||||||||||||||||
| 20 | 7 | $self->{_transformations_by_transformer} = {}; | |||||||||||||||||||||||||
| 21 | 7 | $self->{_transformations_by_necessity} = {}; | |||||||||||||||||||||||||
| 22 | 7 | $self->{_total_transformations} = 0; | |||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||
| 24 | 7 | return $self; | |||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||
| 27 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||
| 29 | 5 | ▶ | sub accumulate { | ||||||||||||||||||||||||
|
Subroutine
accumulate: called CC=12 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||
| 30 | 5 | my ($self, $doc, $transformations) = @_; | |||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||
| 32 | 5 | $self->{_modules}++; | |||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||
| 34 | 5 | my $subs = $doc->find('PPI::Statement::Sub'); | |||||||||||||||||||||||||
| 35 | 5 | ▶ | if ($subs) { | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 36 | 1 | foreach my $sub ( @{$subs} ) { | |||||||||||||||||||||||||
| 37 | 1 | $self->{_subs}++; | |||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||
| 41 | 5 | my $statements = $doc->find('PPI::Statement'); | |||||||||||||||||||||||||
| 42 | 5 | ▶ | $self->{_statements} += $statements ? scalar @{$statements} : 0; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||
| 44 | 5 | my @lines = split /$INPUT_RECORD_SEPARATOR/, $doc->serialize(); | |||||||||||||||||||||||||
| 45 | ## use mogrify | ||||||||||||||||||||||||||
| 46 | 5 | $self->{_lines} += scalar @lines; | |||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||
| 48 | 5 | my ( $in_data, $in_pod ); | |||||||||||||||||||||||||
| 49 | 5 | foreach ( @lines ) { | |||||||||||||||||||||||||
| 50 | 9 | ▶ | if ( q{=} eq substr $_, 0, 1 ) { | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 51 | 0 | $in_pod = not m/ \A \s* =cut \b /smx; | |||||||||||||||||||||||||
| 52 | } elsif ( $in_pod ) { | ||||||||||||||||||||||||||
| 53 | ▶ | } elsif ( q{__END__} eq $_ || q{__DATA__} eq $_ ) { | |||||||||||||||||||||||||
|
Condition33%1/3
"__END__" eq $_ or "__DATA__" eq $_
MC/DC0%0/2
"__END__" eq $_ or "__DATA__" eq $_
"__END__" eq $_
"__DATA__" eq $_
Truth table33%1/3
A or B
A= "__END__" eq $_B= "__DATA__" eq $_
| |||||||||||||||||||||||||||
| 54 | 0 | $in_data = 1; | |||||||||||||||||||||||||
| 55 | } elsif ( $in_data ) { | ||||||||||||||||||||||||||
| 56 | } elsif ( m/ \A \s* \# /smx ) { | ||||||||||||||||||||||||||
| 57 | } else { | ||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||
| 62 | 5 | foreach my $transformation ( @{ $transformations } ) { | |||||||||||||||||||||||||
| 63 | 24 | $self->{_transformations_by_necessity}->{ $transformation->necessity() }++; | |||||||||||||||||||||||||
| 64 | 24 | $self->{_transformations_by_transformer}->{ $transformation->transformer() }++; | |||||||||||||||||||||||||
| 65 | 24 | $self->{_total_transformations}++; | |||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||
| 68 | 5 | return; | |||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||
| 71 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub modules { | ||||||||||||||||||||||||
|
Subroutine
modules: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||
| 74 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||
| 76 | 0 | return $self->{_modules}; | |||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||
| 79 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub subs { | ||||||||||||||||||||||||
|
Subroutine
subs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||
| 82 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||
| 84 | 0 | return $self->{_subs}; | |||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||
| 87 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub statements { | ||||||||||||||||||||||||
|
Subroutine
statements: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||
| 90 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||
| 92 | 0 | return $self->{_statements}; | |||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||
| 95 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub lines { | ||||||||||||||||||||||||
|
Subroutine
lines: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||
| 98 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||
| 100 | 0 | return $self->{_lines}; | |||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||
| 103 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub transformations_by_necessity { | ||||||||||||||||||||||||
|
Subroutine
transformations_by_necessity: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||
| 106 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||
| 108 | 0 | return $self->{_transformations_by_necessity}; | |||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||
| 111 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub transformations_by_transformer { | ||||||||||||||||||||||||
|
Subroutine
transformations_by_transformer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||
| 114 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||
| 116 | 0 | return $self->{_transformations_by_transformer}; | |||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||
| 119 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub total_transformations { | ||||||||||||||||||||||||
|
Subroutine
total_transformations: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||
| 122 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||
| 124 | 0 | return $self->{_total_transformations}; | |||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||
| 127 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||
| 129 | 0 | ▶ | sub statements_other_than_subs { | ||||||||||||||||||||||||
|
Subroutine
statements_other_than_subs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||
| 130 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||
| 132 | 0 | return $self->statements() - $self->subs(); | |||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||
| 135 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||
| 137 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub transformations_per_file { | ||||||||||||||||||||||||
|
Subroutine
transformations_per_file: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||
| 140 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||
| 142 | 0 | ▶ | return if $self->modules() == 0; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||
| 144 | 0 | return $self->total_transformations() / $self->modules(); | |||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||
| 147 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub transformations_per_statement { | ||||||||||||||||||||||||
|
Subroutine
transformations_per_statement: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||
| 150 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||
| 152 | 0 | my $statements = $self->statements_other_than_subs(); | |||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||
| 154 | 0 | ▶ | return if $statements == 0; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||
| 156 | 0 | return $self->total_transformations() / $statements; | |||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||
| 159 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub transformations_per_line_of_code { | ||||||||||||||||||||||||
|
Subroutine
transformations_per_line_of_code: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||
| 162 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||
| 164 | 0 | ▶ | return if $self->lines() == 0; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||
| 166 | 0 | return $self->total_transformations() / $self->lines(); | |||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||
| 169 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||
| 171 | 12 | 1; | |||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||
| 173 | __END__ | ||||||||||||||||||||||||||