| 1 |
package Analizo::Metric::StructuralComplexity; |
| 2 |
use strict; |
| 3 |
use parent qw(Class::Accessor::Fast Analizo::ModuleMetric); |
| 4 |
|
| 5 |
use Analizo::Metric::CouplingBetweenObjects; |
| 6 |
use Analizo::Metric::LackOfCohesionOfMethods; |
| 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 |
__PACKAGE__->mk_accessors(qw( model cbo lcom4 )); |
| 31 |
|
| 32 |
sub new { |
| 33 |
my ($package, %args) = @_; |
| 34 |
my @instance_variables = ( |
| 35 |
model => $args{model}, |
| 36 |
cbo => $args{cbo}, |
| 37 |
lcom4 => $args{lcom4}, |
| 38 |
); |
| 39 |
|
| 40 |
return bless { @instance_variables }, $package; |
| 41 |
} |
| 42 |
|
| 43 |
sub description { |
| 44 |
return "Structural Complexity"; |
| 45 |
} |
| 46 |
|
| 47 |
sub calculate { |
| 48 |
my ($self, $module) = @_; |
| 49 |
|
| 50 |
my $cbo = $self->cbo->value($module); |
| 51 |
my $lcom4 = $self->lcom4->value($module); |
| 52 |
|
| 53 |
return ($cbo * $lcom4); |
| 54 |
} |
| 55 |
|
| 56 |
1; |