Debian Codegraph @

lib/Analizo/Metric/NumberOfAttributes.pm

raw
1 package Analizo::Metric::NumberOfAttributes;
2 use strict;
3 use parent qw(Class::Accessor::Fast Analizo::ModuleMetric);
4
5 =head1 NAME
6
7 Analizo::Metric::NumerOfAttributes - Number of Attributes (NOA) metric
8
9 =head1 DESCRIPTION
10
11 The metric calculation is based on the following article and calculates the
12 number of attributes of a class.
13
14 Article: I<Monitoring of source code metrics in open source projects> by Paulo
15 Roberto Miranda Meirelles.
16
17 See the adaptation of the paragraph about Number of Attributes in the article:
18
19 Calculates the number of attributes of a class. Its minimum value is zero and
20 there is no upper limit to its result. A class with many attributes may
21 indicate that it has many responsibilities and presents a low cohesion, i. e.,
22 is probably dealing with several different subjects.
23
24 =cut
25
26 __PACKAGE__->mk_accessors(qw( model ));
27
28 sub new {
29 my ($package, %args) = @_;
30 my @instance_variables = (
31 model => $args{model}
32 );
33 return bless { @instance_variables }, $package;
34 }
35
36 sub description {
37 return "Number of Attributes";
38 }
39
40 sub calculate {
41 my ($self, $module) = @_;
42 my @variables = $self->model->variables($module);
43 return scalar(@variables);
44 }
45
46 1;
47