| 1 | package Analizo::Metric::NumberOfAttributes; | ||
| 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 | =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 | 21 | __PACKAGE__->mk_accessors(qw( model )); | |
| 27 | |||
| 28 | 15 | ▶ | sub new { |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 29 | 15 | my ($package, %args) = @_; | |
| 30 | my @instance_variables = ( | ||
| 31 | model => $args{model} | ||
| 32 | 15 | ); | |
| 33 | 15 | return bless { @instance_variables }, $package; | |
| 34 | } | ||
| 35 | |||
| 36 | 4 | ▶ | sub description { |
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 37 | 4 | return "Number of Attributes"; | |
| 38 | } | ||
| 39 | |||
| 40 | 10 | ▶ | sub calculate { |
|
Subroutine
calculate: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 41 | 10 | my ($self, $module) = @_; | |
| 42 | 10 | my @variables = $self->model->variables($module); | |
| 43 | 10 | return scalar(@variables); | |
| 44 | } | ||
| 45 | |||
| 46 | 21 | 1; | |
| 47 | |||