line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Metrics::Lite::Analysis; |
2
|
4
|
|
|
4
|
|
30
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
124
|
|
3
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
156
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
24
|
use Carp qw(confess); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
225
|
|
6
|
4
|
|
|
4
|
|
1787
|
use Perl::Metrics::Lite::Analysis::Util; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
2390
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my %_ANALYSIS_DATA = (); |
11
|
|
|
|
|
|
|
my %_FILES = (); |
12
|
|
|
|
|
|
|
my %_FILE_STATS = (); |
13
|
|
|
|
|
|
|
my %_MAIN = (); |
14
|
|
|
|
|
|
|
my %_SUBS = (); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
7
|
|
|
7
|
1
|
38
|
my ( $class, $analysis_data ) = @_; |
18
|
7
|
100
|
|
|
|
28
|
if (!Perl::Metrics::Lite::Analysis::Util::is_ref( |
19
|
|
|
|
|
|
|
$analysis_data, 'ARRAY' |
20
|
|
|
|
|
|
|
) |
21
|
|
|
|
|
|
|
) |
22
|
|
|
|
|
|
|
{ |
23
|
1
|
|
|
|
|
300
|
confess 'Did not supply an arryref of analysis data.'; |
24
|
|
|
|
|
|
|
} |
25
|
6
|
|
|
|
|
18
|
my $self = {}; |
26
|
6
|
|
|
|
|
16
|
bless $self, $class; |
27
|
6
|
|
|
|
|
26
|
$self->_init($analysis_data); # Load object properties |
28
|
6
|
|
|
|
|
18
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub files { |
32
|
2
|
|
|
2
|
1
|
15
|
my ($self) = @_; |
33
|
2
|
|
|
|
|
15
|
return $_FILES{$self}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub data { |
37
|
9
|
|
|
9
|
1
|
30
|
my $self = shift; |
38
|
9
|
|
|
|
|
42
|
return $_ANALYSIS_DATA{$self}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub file_count { |
42
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
43
|
1
|
|
|
|
|
2
|
return scalar @{ $self->files }; |
|
1
|
|
|
|
|
4
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub file_stats { |
47
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
48
|
0
|
|
|
|
|
0
|
return $_FILE_STATS{$self}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub main_stats { |
52
|
2
|
|
|
2
|
1
|
10
|
my $self = shift; |
53
|
2
|
|
|
|
|
16
|
return $_MAIN{$self}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub subs { |
57
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
58
|
1
|
|
|
|
|
7
|
return $_SUBS{$self}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub sub_stats { |
62
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
63
|
0
|
|
|
|
|
0
|
my $sub_stats = {}; |
64
|
0
|
0
|
|
|
|
0
|
foreach my $sub (@{ $self->subs || []}) { |
|
0
|
|
|
|
|
0
|
|
65
|
0
|
|
0
|
|
|
0
|
$sub_stats->{$sub->{path}} ||= []; |
66
|
0
|
|
|
|
|
0
|
push @{$sub_stats->{$sub->{path}}}, $sub ; |
|
0
|
|
|
|
|
0
|
|
67
|
|
|
|
|
|
|
} |
68
|
0
|
|
|
|
|
0
|
return $sub_stats; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub sub_count { |
72
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
73
|
1
|
|
|
|
|
3
|
return scalar @{ $self->subs }; |
|
1
|
|
|
|
|
3
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _init { |
77
|
6
|
|
|
6
|
|
19
|
my ( $self, $file_objects ) = @_; |
78
|
6
|
|
|
|
|
27
|
$_ANALYSIS_DATA{$self} = $file_objects; |
79
|
|
|
|
|
|
|
|
80
|
6
|
|
|
|
|
13
|
my @all_files = (); |
81
|
6
|
|
|
|
|
12
|
my @packages = (); |
82
|
6
|
|
|
|
|
14
|
my $lines = 0; |
83
|
6
|
|
|
|
|
12
|
my @subs = (); |
84
|
6
|
|
|
|
|
12
|
my @file_stats = (); |
85
|
6
|
|
|
|
|
22
|
my %main_stats = ( lines => 0 ); |
86
|
|
|
|
|
|
|
|
87
|
6
|
|
|
|
|
11
|
foreach my $file ( @{ $self->data() } ) { |
|
6
|
|
|
|
|
21
|
|
88
|
15
|
|
|
|
|
41
|
$lines += $file->lines(); |
89
|
15
|
|
|
|
|
45
|
$main_stats{lines} += $file->main_stats()->{lines}; |
90
|
15
|
|
|
|
|
41
|
push @all_files, $file->path(); |
91
|
15
|
|
|
|
|
38
|
push @file_stats, |
92
|
|
|
|
|
|
|
{ path => $file->path, main_stats => $file->main_stats }; |
93
|
15
|
|
|
|
|
30
|
push @packages, @{ $file->packages }; |
|
15
|
|
|
|
|
39
|
|
94
|
15
|
|
|
|
|
25
|
push @subs, @{ $file->subs }; |
|
15
|
|
|
|
|
35
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
6
|
|
|
|
|
21
|
$_FILE_STATS{$self} = \@file_stats; |
98
|
6
|
|
|
|
|
14
|
$_FILES{$self} = \@all_files; |
99
|
6
|
|
|
|
|
16
|
$_MAIN{$self} = \%main_stats; |
100
|
6
|
|
|
|
|
16
|
$_SUBS{$self} = \@subs; |
101
|
6
|
|
|
|
|
18
|
return 1; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
__END__ |