Analizo/Metric/StructuralComplexity.pm

filter: Statementstmt 100% 22 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 33.3% 1 / 3 totaltotal 93.7% 30 / 32 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Test/Analizo/Class.pm ↑ Summary Test/Analizo/Git.pm »
1 package Analizo::Metric::StructuralComplexity;
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  
5 21 ▶use Analizo::Metric::CouplingBetweenObjects;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 21 ▶use Analizo::Metric::LackOfCohesionOfMethods;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Analizo::Metric::StructuralComplexity - Structural Complexity (SC) metric
11  
12 =head1 DESCRIPTION
13  
14 The metric calculation is based on the following article and calculates the
15 structural complexity.
16  
17 Article: I<Monitoring of source code metrics in open source projects> by Paulo
18 Roberto Miranda Meirelles.
19  
20 See the adaptation of the paragraph about Structural Complexity in the article:
21  
22 When combined with a metric, the coupling and cohesion product is positively
23 correlated to the maintenance effort. Therefore, we use in this PhD research
24 the coupling product (CBO) and cohesion (LCOM4) as our structural complexity
25 metric (Darcy et al., 2005).
26  
27 =cut
28  
29  
30 21 __PACKAGE__->mk_accessors(qw( model cbo lcom4 ));
31  
32 18 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
33 18 my ($package, %args) = @_;
34 my @instance_variables = (
35 model => $args{model},
36 cbo => $args{cbo},
37 lcom4 => $args{lcom4},
38 18 );
39  
40 18 return bless { @instance_variables }, $package;
41 }
42  
43 4 ▶sub description {
Subroutine description: called CC=1 SCAR=0.0
Pod undocumented
44 4 return "Structural Complexity";
45 }
46  
47 9 ▶sub calculate {
Subroutine calculate: called CC=1 SCAR=0.0
Pod undocumented
48 9 my ($self, $module) = @_;
49  
50 9 my $cbo = $self->cbo->value($module);
51 9 my $lcom4 = $self->lcom4->value($module);
52  
53 9 return ($cbo * $lcom4);
54 }
55  
56 21 1;
« Test/Analizo/Class.pm ↑ Summary Test/Analizo/Git.pm »