line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Metrics::Simple::Output::JSON; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
834
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
487
|
use parent qw(Perl::Metrics::Simple::Output); |
|
1
|
|
|
|
|
368
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
1230
|
use JSON::PP qw(encode_json); |
|
1
|
|
|
|
|
15353
|
|
|
1
|
|
|
|
|
442
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 'v1.0.3'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub make_report { |
12
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $report = +{ |
15
|
|
|
|
|
|
|
statistics => +{ |
16
|
|
|
|
|
|
|
file_count => $self->analysis()->file_count(), |
17
|
|
|
|
|
|
|
counts => $self->make_counts(), |
18
|
|
|
|
|
|
|
subroutine_sizes => $self->make_subroutine_size(), |
19
|
|
|
|
|
|
|
mccabe_complexity => $self->make_code_complexity(), |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
subs => $self->make_list_of_subs()->[1], |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
return encode_json($report); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub make_counts { |
28
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $analysis = $self->analysis(); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return +{ |
33
|
|
|
|
|
|
|
total_code_lines => $analysis->lines(), |
34
|
0
|
|
|
|
|
|
lines_of_non_sub_code => $analysis->main_stats()->{'lines'}, |
35
|
|
|
|
|
|
|
packages_found => $analysis->package_count(), |
36
|
|
|
|
|
|
|
subs_and_methods_count => $analysis->sub_count(), |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub make_subroutine_size { |
41
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $stats = $self->analysis->summary_stats(); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return +{ |
46
|
|
|
|
|
|
|
min => $stats->{'sub_length'}->{min}, |
47
|
|
|
|
|
|
|
max => $stats->{'sub_length'}->{max}, |
48
|
|
|
|
|
|
|
mean => $stats->{'sub_length'}->{mean}, |
49
|
|
|
|
|
|
|
standard_deviation => $stats->{'sub_length'}->{standard_deviation}, |
50
|
|
|
|
|
|
|
median => $stats->{'sub_length'}->{median}, |
51
|
0
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub make_code_complexity { |
55
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return +{ |
58
|
0
|
|
|
|
|
|
code_not_in_any_subroutine => $self->make_complexity_section('main_complexity'), |
59
|
|
|
|
|
|
|
sub_complexity => $self->make_complexity_section('sub_complexity'), |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub make_complexity_section { |
64
|
0
|
|
|
0
|
0
|
|
my ( $self, $key ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $analysis = $self->analysis(); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
return { |
69
|
|
|
|
|
|
|
min => $analysis->summary_stats()->{$key}->{'min'}, |
70
|
|
|
|
|
|
|
max => $analysis->summary_stats()->{$key}->{'max'}, |
71
|
|
|
|
|
|
|
mean => $analysis->summary_stats()->{$key}->{'mean'}, |
72
|
|
|
|
|
|
|
standard_deviation => $analysis->summary_stats()->{$key}->{'standard_deviation'}, |
73
|
0
|
|
|
|
|
|
median => $analysis->summary_stats()->{$key}->{'median'}, |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |