view release on metacpan or search on metacpan
lib/Analizo/Batch.pm view on Meta::CPAN
package Analizo::Batch;
use strict;
use warnings;
use parent qw( Analizo::Filter::Client );
sub new {
my ($class, @options) = @_;
return bless { @options }, $class;
}
sub next {
my ($self) = @_;
my $next_job = $self->fetch_next();
if ($next_job) {
$self->share_filters_with($next_job);
}
return $next_job;
}
lib/Analizo/Batch/Job.pm view on Meta::CPAN
use Analizo;
use Analizo::Model;
use Analizo::Extractor;
use Analizo::Metrics;
__PACKAGE__->mk_accessors(qw(model metrics id directory extractor));
__PACKAGE__->mk_accessors(qw(includedirs libdirs libs));
sub new {
my ($class, @options) = @_;
return bless { @options }, $class;
}
# This method must be overriden by by subclasses.
#
# This method must do all the work required to leave the current process in the
# directory whose source code must be analysed. B<This may include changing the
# current directory>.
#
# Everything that is done in this method must be undone in the I<cleanup>
# method.
lib/Analizo/Batch/Output.pm view on Meta::CPAN
#
package Analizo::Batch::Output;
use strict;
use warnings;
use parent qw(Class::Accessor::Fast);
sub new {
my ($class) = @_;
return bless {}, $class;
}
# This method must be overriden by subclasses, and must return 0 or 1 based on
# whether the given output format requires calculation of metrics or not.
#
# Given that calculating metrics requires a significant amount of processing,
# by default we return 0 here.
sub requires_metrics {
0;
}
lib/Analizo/Batch/Runner.pm view on Meta::CPAN
package Analizo::Batch::Runner;
use parent qw(Class::Accessor::Fast);
sub new {
my ($class, @args) = @_;
return bless { @args }, $class;
}
sub run($$$) {
my ($self, $batch, $output) = @_;
$output->initialize();
$self->actually_run($batch, $output);
$output->flush();
}
# must be implemented by subclasses. Will receive as argument:
lib/Analizo/Extractor/Doxyparse.pm view on Meta::CPAN
use parent qw(Analizo::Extractor);
use File::Temp qw/ tempfile /;
use Cwd;
use YAML::XS;
use File::Spec::Functions qw/ tmpdir /;
sub new {
my ($package, @options) = @_;
return bless { files => [], @options }, $package;
}
sub _add_file {
my ($self, $file) = @_;
push(@{$self->{files}}, $file);
}
sub _cpp_hack {
my ($self, $module) = @_;
my $current = $self->current_file;
lib/Analizo/FilenameFilter.pm view on Meta::CPAN
use strict;
use warnings;
sub new {
my ($package, @options) = @_;
my $self = {
regex => '.',
reverse => 0,
@options
};
return bless $self, __PACKAGE__;
}
sub exclude {
my ($package, @paths) = @_;
my $regex = sprintf("^(./)?(%s)", join('|', @paths));
return $package->new(regex => $regex, reverse => 1);
}
sub matches {
my ($self, $filename) = @_;
lib/Analizo/GlobalMetric/ChangeCost.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model},
);
return bless { @instance_variables }, $package;
}
sub description {
return "Change Cost";
}
sub calculate {
my ($self) = @_;
my $reachability_matrix = $self->model->files_graph->transitive_closure_matrix;
my @vertices = sort $reachability_matrix->vertices;
lib/Analizo/GlobalMetric/MethodsPerAbstractClass.pm view on Meta::CPAN
use strict;
use parent qw(Class::Accessor::Fast);
__PACKAGE__->mk_accessors(qw( model));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model},
);
return bless { @instance_variables }, $package;
}
sub description {
return "Methods per Abstract Class";
}
sub calculate {
my ($self) = @_;
my $total_number_of_methods = 0;
my @abstract_classes = $self->model->abstract_classes;
lib/Analizo/GlobalMetric/TotalAbstractClasses.pm view on Meta::CPAN
use strict;
use parent qw(Class::Accessor::Fast);
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model},
);
return bless { @instance_variables }, $package;
}
sub description {
return "Total Abstract Classes";
}
sub calculate {
my ($self)= @_;
my @total_of_abstract_classes = $self->model->abstract_classes;
return scalar(@total_of_abstract_classes) || 0;
lib/Analizo/GlobalMetrics.pm view on Meta::CPAN
));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model},
calculators => _initialize_calculators($args{model}),
metric_report => _initialize_metric_report(),
values_lists => {},
);
return bless { @instance_variables }, $package;
}
sub _initialize_calculators {
my ($model) = @_;
my %calculators = (
total_abstract_classes => Analizo::GlobalMetric::TotalAbstractClasses->new(model => $model),
total_methods_per_abstract_class => Analizo::GlobalMetric::MethodsPerAbstractClass->new(model => $model),
change_cost => Analizo::GlobalMetric::ChangeCost->new(model => $model),
);
return \%calculators;
lib/Analizo/LanguageFilter.pm view on Meta::CPAN
sub new {
my ($package, $filter_type) = @_;
$filter_type ||= 'all';
my $regex = $FILTERS->{$filter_type};
if (!defined($regex)) {
croak "E: Unknown language filter $filter_type";
}
my $self = {
regex => '\.(' . $regex . '|' . uc($regex) . ')$',
};
return bless $self, $package;
}
sub list {
my ($self) = @_;
sort keys %$FILTERS;
}
1;
lib/Analizo/Metric/AfferentConnections.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model analized_module));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model},
analized_modules => undef
);
return bless { @instance_variables }, $package;
}
sub description {
return 'Afferent Connections per Class (used to calculate COF - Coupling Factor)';
}
sub calculate {
my ($self, $module) = @_;
$self->analized_module($module);
my $acc_result = $self->model->modules_graph->in_degree($module);
lib/Analizo/Metric/AverageCycloComplexity.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return 'Average Cyclomatic Complexity per Method';
}
sub calculate {
my ($self, $module) = @_;
my @functions = $self->model->functions($module);
lib/Analizo/Metric/AverageMethodLinesOfCode.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Average Method Lines of Code";
}
sub calculate {
my ($self, $module) = @_;
my @functions = $self->model->functions($module);
lib/Analizo/Metric/AverageNumberOfParameters.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Average Number of Parameters per Method";
}
sub calculate {
my ($self, $module) = @_;
my @functions = $self->model->functions($module);
lib/Analizo/Metric/CouplingBetweenObjects.pm view on Meta::CPAN
__PACKAGE__->mk_accessors(qw( model analized_module calls_to ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model},
analized_module => undef,
calls_to => {},
);
return bless { @instance_variables }, $package;
}
sub description {
return "Coupling Between Objects";
}
sub calculate {
my ($self, $module) = @_;
$self->analized_module($module);
$self->calls_to({});
lib/Analizo/Metric/DepthOfInheritanceTree.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Depth of Inheritance Tree";
}
sub calculate {
my ($self, $module) = @_;
my @parents = $self->model->inheritance($module);
lib/Analizo/Metric/LackOfCohesionOfMethods.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model graph ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model},
graph => Graph->new,
);
return bless { @instance_variables }, $package;
}
sub description {
return "Lack of Cohesion of Methods";
}
sub calculate {
my ($self, $module) = @_;
my $graph = Graph->new;
my @functions = $self->model->functions($module);
lib/Analizo/Metric/LinesOfCode.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Lines of Code";
}
sub calculate {
my ($self, $module) = @_;
my @functions = $self->model->functions($module);
lib/Analizo/Metric/MaximumMethodLinesOfCode.pm view on Meta::CPAN
use parent qw(Class::Accessor::Fast Analizo::ModuleMetric);
use Statistics::Descriptive;
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Max Method LOC";
}
sub calculate {
my ($self, $module) = @_;
my $statisticalCalculator = Statistics::Descriptive::Full->new();
lib/Analizo/Metric/NumberOfAttributes.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Number of Attributes";
}
sub calculate {
my ($self, $module) = @_;
my @variables = $self->model->variables($module);
return scalar(@variables);
lib/Analizo/Metric/NumberOfChildren.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Number of Children";
}
sub calculate {
my ($self, $module) = @_;
my $number_of_children = 0;
lib/Analizo/Metric/NumberOfMethods.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Number of Methods";
}
sub calculate {
my ($self, $module) = @_;
my @functions = $self->model->functions($module);
return scalar(@functions);
lib/Analizo/Metric/NumberOfPublicAttributes.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Number of Public Attributes";
}
sub calculate {
my ($self, $module) = @_;
my $count = 0;
lib/Analizo/Metric/NumberOfPublicMethods.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Number of Public Methods";
}
sub calculate {
my ($self, $module) = @_;
my $count = 0;
lib/Analizo/Metric/ResponseForClass.pm view on Meta::CPAN
=cut
__PACKAGE__->mk_accessors(qw( model ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model}
);
return bless { @instance_variables }, $package;
}
sub description {
return "Response for a Class";
}
sub calculate {
my ($self, $module) = @_;
my @functions = $self->model->functions($module);
lib/Analizo/Metric/StructuralComplexity.pm view on Meta::CPAN
__PACKAGE__->mk_accessors(qw( model cbo lcom4 ));
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model},
cbo => $args{cbo},
lcom4 => $args{lcom4},
);
return bless { @instance_variables }, $package;
}
sub description {
return "Structural Complexity";
}
sub calculate {
my ($self, $module) = @_;
my $cbo = $self->cbo->value($module);
lib/Analizo/Metrics.pm view on Meta::CPAN
sub new {
my ($package, %args) = @_;
my @instance_variables = (
model => $args{model},
global_metrics => Analizo::GlobalMetrics->new(model => $args{model}),
module_metrics => Analizo::ModuleMetrics->new(model => $args{model}),
module_data => [],
by_module => {},
);
return bless { @instance_variables }, $package;
}
sub list_of_global_metrics {
my ($self) = @_;
return $self->global_metrics->list;
}
sub list_of_metrics {
my ($self) = @_;
return $self->module_metrics->list;
lib/Analizo/Model.pm view on Meta::CPAN
lines => {},
protection => {},
inheritance => {},
parameters => {},
conditional_paths => {},
abstract_classes => [],
module_names => [],
modules_graph => undef,
files_graph => undef,
);
return bless { @defaults }, __PACKAGE__;
}
sub modules {
my ($self) = @_;
return $self->{modules};
}
sub module_names {
my ($self) = @_;
return @{$self->{module_names}};
lib/Analizo/ModuleMetric.pm view on Meta::CPAN
package Analizo::ModuleMetric;
sub new {
return bless { cache => {} }, __PACKAGE__;
}
sub value {
my ($self, $module) = @_;
if (!defined $self->{cache}->{$module}) {
$self->{cache}->{$module} = $self->calculate($module);
}
my $value = $self->{cache}->{$module};
return $value;
}