Analizo/Metric/LinesOfCode.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 2 / 2 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 6 / 6 Podpod 33.3% 1 / 3 totaltotal 94.5% 35 / 37 CC 4 SCAR 8.5
CC
4
Cov
100%
calculate
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« Analizo/Metric/AverageNumberOfParameters.pm ↑ Summary Analizo/GlobalMetric/ChangeCost.pm »
1 package Analizo::Metric::LinesOfCode;
2 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 21 ▶use parent qw(Class::Accessor::Fast Analizo::ModuleMetric);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use Statistics::Descriptive;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Analizo::Metric::LinesOfCode - Lines of Code (LOC) metric
9  
10 =head1 DESCRIPTION
11  
12 The metric calculation is based on the following article and calculates the
13 program size in lines of code, excluding blank lines and comments.
14  
15 Article: I<The Lines of Code Metric as a Predictor of Program Faults: A
16 Critical Analysis> by Taghi M. Khoshgoftaar and John C. Munson.
17  
18 See the paragraph about Lines of Code in the article:
19  
20 A description of the specific quantitative complexity data collected for
21 each program is as follows:
22  
23 ... program size in lines of code (non-comment, non-blank lines) in program
24 (LOC).
25  
26 =cut
27  
28 21 __PACKAGE__->mk_accessors(qw( model ));
29  
30 15 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
31 15 my ($package, %args) = @_;
32 my @instance_variables = (
33 model => $args{model}
34 15 );
35 15 return bless { @instance_variables }, $package;
36 }
37  
38 4 ▶sub description {
Subroutine description: called CC=1 SCAR=0.0
Pod undocumented
39 4 return "Lines of Code";
40 }
41  
42 10 ▶sub calculate {
Subroutine calculate: called CC=4 SCAR=13.9
Pod undocumented
43 10 my ($self, $module) = @_;
44  
45 10 my @functions = $self->model->functions($module);
46 10 ▶ if (scalar(@functions) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @functions == 0) 1 9 10
47 1 return 0;
48 }
49  
50 9 my $statisticalCalculator = Statistics::Descriptive::Full->new();
51  
52 9 for my $function (@functions) {
53 14 ▶ $statisticalCalculator->add_data($self->model->{lines}->{$function} || 0);
Condition100%2/2
$self->model->{'lines'}{$function} || 0
l!l
59
MC/DC100%1/1
$self->model->{'lines'}{$function} || 0
$self->model->{'lines'}{$function}
Truth table100%2/2
A
A= $self->model->{'lines'}{$function}
Aresult
11
00
54 }
55  
56 9 return $statisticalCalculator->sum();
57 }
58  
59 21 1;
60  
« Analizo/Metric/AverageNumberOfParameters.pm ↑ Summary Analizo/GlobalMetric/ChangeCost.pm »