view release on metacpan or search on metacpan
CHANGELOG.md view on Meta::CPAN
- Added atomated tests for httpd-2.4.38 errors
- Added samples for bug parsing kdelibs project
### Removed
- Removed the evolution-matrix visualization tool
- Removed the dsm visualization tool
## [1.22.0] - 2018-09-25
### Removed
- Removed global metric `total_eloc`
- Removed dependency for `sloccount` external tool
### Changed
- Development setup installs Doxyparse from latest source master branch
- Improved the performance for ACC metric calculation
### Fixed
- Update to the newer Doxyparse 1.8.14-7 (fix invalid YAML with "\" char)
- Invalid references to function
- Limit Doxyparse YAML output identifiers to 1024 chars
t/features/graph/plain.feature
t/features/language_support.feature
t/features/manpage-on-help.feature
t/features/metrics-batch.feature
t/features/metrics/abstract_classes.feature
t/features/metrics/average_number_of_parameters.feature
t/features/metrics/change_cost.feature
t/features/metrics/coupling_between_objects.feature
t/features/metrics/cyclomatic_complexity.feature
t/features/metrics/deep_inheritance_afferent_connections.feature
t/features/metrics/global_only.feature
t/features/metrics/language_filter.feature
t/features/metrics/list.feature
t/features/metrics/methods_per_abstract_class.feature
t/features/metrics/modules_with_defined_attributes.feature
t/features/metrics/modules_with_defined_methods.feature
t/features/metrics/number_of_attributes.feature
t/features/metrics/number_of_methods.feature
t/features/metrics/number_of_public_methods.feature
t/features/metrics/output_file.feature
t/features/metrics/statistics_values.feature
t/samples/hierarchical_graph/c/main.cc
t/samples/hierarchical_graph/csharp/B.cs
t/samples/hierarchical_graph/csharp/C.cs
t/samples/hierarchical_graph/csharp/D.cs
t/samples/hierarchical_graph/csharp/E.cs
t/samples/hierarchical_graph/csharp/F.cs
t/samples/hierarchical_graph/csharp/Program.cs
t/samples/httpd-2.4.38/http_config.h
t/samples/httpd-2.4.38/mod_suexec.c
t/samples/httpd-2.4.38/mod_suexec.h
t/samples/kdelibs/backportglobal.h
t/samples/kdelibs/daterange.cpp
t/samples/kdelibs/daterange.h
t/samples/kdelibs/parser.cpp
t/samples/macro/using_macro.c
t/samples/macro/using_macro.h
t/samples/mixed/Backend.java
t/samples/mixed/CSharp_Backend.cs
t/samples/mixed/UI.java
t/samples/mixed/native_backend.c
t/samples/mlpack-3.0.0/parse_command_line.hpp
lib/Analizo.pm view on Meta::CPAN
analizo - multi-language source code analysis toolkit
=head1 USAGE
analizo <tool> [tool-options] <toolargs> [<tool-args> ...]
analizo <option>
=cut
sub global_opt_spec {
return (
[ 'help|h', 'displays the help (full manpage)' ],
[ 'usage', 'displays the usage of the command' ],
[ 'version|v', 'displays version information' ],
);
}
sub config {
my ($self) = @_;
$self->{config} ||= (-e '.analizo'
lib/Analizo/Batch/Directories.pm view on Meta::CPAN
use parent qw(Analizo::Batch Class::Accessor::Fast);
use Analizo::Batch::Job::Directories;
__PACKAGE__->mk_accessors(qw(directories));
sub new {
my ($class, @directories) = @_;
my $self = $class->SUPER::new;
if (@directories < 1) {
@directories = glob('*');
}
@directories = grep { -d $_ } @directories;
$self->directories(\@directories);
$self->{index} = 0;
return $self;
}
sub fetch_next {
my ($self) = @_;
my $next_directory = $self->{directories}->[$self->{index}];
lib/Analizo/Batch/Output/DB.pm view on Meta::CPAN
use Analizo::Metrics;
use Analizo::Model;
my $__metric_columns = undef;
sub _metric_columns() {
if (!$__metric_columns) {
my $metrics = Analizo::Metrics->new(model => Analizo::Model->new);
my %module_metrics = $metrics->list_of_metrics();
my @module_metrics= keys(%module_metrics);
my %project_metrics = $metrics->list_of_global_metrics();
my @project_metrics = keys(%project_metrics);
$__metric_columns = {
module => \@module_metrics,
project => \@project_metrics,
};
}
return $__metric_columns;
}
lib/Analizo/Command.pm view on Meta::CPAN
package Analizo::Command;
use App::Cmd::Setup -command;
use strict;
use warnings;
use Class::Inspector;
use Env::Path qw( PATH );
use File::Temp qw( tmpnam );
=head1 NAME
Analizo::Command - global options for tools
=head1 DESCRIPTION
Following the instructions from the L<App::Cmd::Tutorial> we create this module
to be a superclass of every analizo tool, in that way we can have global
options to every analizo tool:
analizo <tool> --help
analizo <tool> --usage
Any analizo tool should implement B<validate()>, method which is called by
B<validate_args()> implemented here. See L<App::Cmd::Command> for details about
B<validate_args()>.
=cut
sub validate_args {
my ($self, $opt, $args) = @_;
if ($self->app->global_options->version) {
$self->usage_error("Invalid option: --version");
}
elsif ($self->app->global_options->usage) {
print $self->app->usage, "\n", $self->usage;
exit 0;
}
$self->validate($opt, $args);
}
sub version_information {
my ($self) = @_;
sprintf("%s version %s", $self->app->arg0, $Analizo::VERSION);
}
lib/Analizo/Command/help.pm view on Meta::CPAN
As documented in L<App::Cmd#default_command> the `help` is the default command,
it is called when the script `analizo` is executed without inform any command.
analizo help is part of the analizo suite.
=cut
sub execute {
my ($self, $opt, $args) = @_;
my $command_name = $args->[0];
if ($self->app->global_options->version) {
printf("%s\n", $self->version_information);
exit 0;
}
elsif ($command_name) {
(my $package_name = $command_name) =~ s/-/_/g;
$self->show_manpage("Analizo::Command::$package_name", $command_name);
exit 0;
}
elsif ($self->app->global_options->help || (@ARGV && $ARGV[0] eq '--help')) {
$self->show_manpage('Analizo', 'analizo');
exit 0;
}
elsif ($self->app->global_options->usage) {
print $self->app->usage;
exit 0;
}
$self->SUPER::execute($opt, $args);
}
1;
=head1 COPYRIGHT AND AUTHORS
lib/Analizo/Command/metrics.pm view on Meta::CPAN
=cut
sub usage_desc { "%c metrics %o [<input>]" }
sub opt_spec {
my ($class, $app) = @_;
return (
[ 'list|l', 'displays metric list' ],
[ 'extractor=s', 'which extractor method use to parse the source code' ],
[ 'globalonly|global-only|g', 'only output global (project-wide) metrics' ],
[ 'output|o=s', 'output file name' ],
[ 'language=s', 'process only filenames matching known extensions for the <lang>> programming' ],
[ 'exclude|x=s', 'exclude <dirs> (a colon-separated list of directories) from the analysis' ],
[ 'includedirs|I=s', 'include <dirs> (a colon-separated list of directories) with C/C++ header files', { default => '.' } ],
[ 'libdirs|L=s', 'include <dirs> (a colon-separated list of directories) with C/C++ static and dynamic libraries files', { default => '.' } ],
[ 'libs=s', 'include <dirs> (a colon-separated list of directories) with C/C++ linked libraries files', { default => '.' } ],
);
}
sub validate {
lib/Analizo/Command/metrics.pm view on Meta::CPAN
if ($opt->output && ! -w dirname($opt->output)) {
$self->usage_error("No such file or directory");
}
}
sub execute {
my ($self, $opt, $args) = @_;
if($opt->list){
my $metrics_handler = Analizo::Metrics->new(model => Analizo::Model->new);
my %metrics = $metrics_handler->list_of_metrics();
my %global_metrics = $metrics_handler->list_of_global_metrics();
print "Global Metrics:\n";
foreach my $key (sort keys %global_metrics){
print "$key - $global_metrics{$key}\n";
}
print "\nModule Metrics:\n";
foreach my $key (sort keys %metrics){
print "$key - $metrics{$key}\n";
}
exit 0;
}
my $tree = $args->[0] || '.';
my $job = Analizo::Batch::Job::Directories->new($tree);
$job->extractor($opt->extractor);
lib/Analizo/Command/metrics.pm view on Meta::CPAN
$job->exclude(@excluded_directories);
}
$job->includedirs($opt->includedirs);
$job->libdirs($opt->libdirs);
$job->libs($opt->libs);
$job->execute();
my $metrics = $job->metrics;
if ($opt->output) {
open STDOUT, '>', $opt->output or die "$!\n";
}
if ($opt->globalonly) {
print $metrics->report_global_metrics_only;
}
else {
print $metrics->report;
}
close STDOUT;
}
=head1 DESCRIPTION
analizo metrics analyzes source code in I<input> and produces a metrics
lib/Analizo/Command/metrics.pm view on Meta::CPAN
supported by doxyparse are processed, unless I<--language> is used.
=item --list, -l
Displays metric list.
=item --output <file>, -o <file>
Writes the output to <file> instead of standard output.
=item --globalonly, --global-only, -g
Don't output the details about modules: only output global (project-wide) metrics.
=item --language <lang>
Process only filenames matching known extensions for the <I<lang>> programming
language. To see which languages are supported, pass B<--language list>.
=item --exclude <dirs>, -x <dirs>
Exclude <I<dirs>> (a colon-separated list of directories) from the analysis.
This is useful, for example, when you want to focus on production code and
lib/Analizo/GlobalMetric/ChangeCost.pm view on Meta::CPAN
package Analizo::GlobalMetric::ChangeCost;
use strict;
use parent qw(Class::Accessor::Fast);
use List::Util qw( sum );
use Graph::TransitiveClosure::Matrix;
=head1 NAME
Analizo::GlobalMetric::ChangeCost - Change Cost global metric
=head1 DESCRIPTION
The metric calculation is based on the following article and calculates the
degree to which a change to any file causes a (potential) change to other files
in the system.
Article: Exploring the Structure of Complex Software Designs: An Empirical
Study of Open Source and Proprietary Code by Alan MacCormack, John Rusnak and
Carliss Baldwin.
lib/Analizo/Metrics.pm view on Meta::CPAN
context of Analizo metrics calculation, both to project-level metrics as to
module-level metrics. You can see a discussion on the
L<issue #60|https://github.com/analizo/analizo/issues/60>
about this decision.
=cut
__PACKAGE__->mk_accessors(qw(
model
module_metrics
global_metrics
module_data
by_module
));
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;
}
sub report {
my ($self) = @_;
return $self->report_global_metrics_only() . $self->report_module_metrics();
}
sub report_global_metrics_only {
my ($self) = @_;
my ($global_metrics, $module_metrics) = $self->data();
return Dump($global_metrics);
}
sub report_module_metrics {
my ($self) = @_;
return join('', map { Dump($_) } @{$self->module_data()});
}
sub data {
my ($self) = @_;
$self->_collect_and_combine_module_metrics;
return ($self->global_metrics->report, $self->module_data());
}
sub _collect_and_combine_module_metrics {
my ($self) = @_;
if (defined $self->{_collect_and_combine_module_metrics}) {
return;
}
for my $module ($self->model->module_names) {
my $module_metrics = $self->_collect($module);
lib/Analizo/Metrics.pm view on Meta::CPAN
sub _combine {
my ($self, $module_metrics) = @_;
my $module = $module_metrics->{_module};
$module_metrics->{_filename} = $self->model->files($module);
push(@{$self->module_data()}, $module_metrics);
$self->{by_module}->{$module} = $module_metrics;
$self->global_metrics->add_module_values($module_metrics);
}
sub metrics_for {
my ($self, $module) = @_;
$self->data(); # FIXME shouldn't be needed
return $self->{by_module}->{$module};
}
1;
lib/Test/Analizo/BDD/Cucumber/Extension.pm view on Meta::CPAN
sub pre_scenario {
my ($self, $scenario, $feature_stash, $scenario_stash) = @_;
$ENV{ANALIZO_CACHE} = tempdir("analizo-XXXXXXXXXX", CLEANUP => 1, DIR => File::Spec->tmpdir);
}
sub post_scenario {
my ($self, $scenario, $feature_stash, $scenario_stash, $failed) = @_;
unlink 'tmp.out';
unlink 'tmp.err';
unlink glob('*.tmp');
remove_tree $ENV{ANALIZO_CACHE};
chdir $top_dir;
}
1;
share/bash-completion/analizo view on Meta::CPAN
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${options}" -- ${cur}))
else
COMPREPLY=( $(compgen -d ${cur}) )
fi
return 0
}
_analizo_metrics() {
local options
options="-e -h -l -o -g -n -d --extractor --help --list --output --global-only --language --exclude --usage"
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${options}" -- ${cur}))
else
COMPREPLY=( $(compgen -d ${cur}) )
fi
return 0
}
_analizo_metrics-batch() {
local options
t/Analizo/Batch/Output/DB.t view on Meta::CPAN
'animal.h' => '1111111111111111111111111111111111111111',
'mammal.h' => '1111111111111111111111111111111111111111',
}
}
}
);
$output->push($job);
select_ok($OUTFILE, "SELECT * FROM module_versions WHERE id = '1111111111111111111111111111111111111111'", 2);
}
sub global_metrics : Tests {
my $output = __create($OUTFILE);
my $job = mock(Analizo::Batch::Job::Directories->new($SAMPLE));
$job->mock('project_name', sub { 'animals'; });
$job->id('foo');
$job->execute();
$output->push($job);
select_one_ok($OUTFILE, "SELECT * FROM commits where total_abstract_classes > 0");
}
sub files_with_multiple_modules : Tests {
t/Analizo/GlobalMetrics.t view on Meta::CPAN
package t::Analizo::GlobalMetrics;
use strict;
use warnings;
use parent qw(Test::Analizo::Class);
use Test::More;
use Statistics::Descriptive;
use Analizo::GlobalMetrics;
use Analizo::Model;
use vars qw($model $global_metrics);
sub setup : Test(setup) {
$model = Analizo::Model->new;
$global_metrics = Analizo::GlobalMetrics->new(model => $model);
}
sub constructor : Tests {
isa_ok($global_metrics, 'Analizo::GlobalMetrics');
}
sub model : Tests {
is($global_metrics->model, $model);
}
sub metric_from_global_metrics_package : Tests{
$model->add_abstract_class('mod');
$model->declare_function('mod', 'f1');
my $report = $global_metrics->report();
is($report->{'total_abstract_classes'}, 1, '1 abstract class');
is($report->{'total_methods_per_abstract_class'}, 1, '1 method per abstract class');
}
sub total_modules : Tests {
my $report = $global_metrics->report;
is($report->{'total_modules'}, 0);
my %dummy_module_values = ();
$global_metrics->add_module_values(\%dummy_module_values);
$report = $global_metrics->report;
is($report->{'total_modules'}, 1);
}
sub total_modules_with_defined_methods_when_no_modules_where_defined : Tests {
my $report = $global_metrics->report;
is($report->{'total_modules_with_defined_methods'}, 0);
}
sub total_modules_with_defined_methods_when_a_module_has_nom : Tests{
my %module_values = (nom => 1);
$global_metrics->add_module_values(\%module_values);
my $report = $global_metrics->report;
is($report->{'total_modules_with_defined_methods'}, 1);
}
sub total_modules_with_defined_methods_when_a_module_has_no_nom : Tests {
my %module_values = (nom => 0);
$global_metrics->add_module_values(\%module_values);
my $report = $global_metrics->report;
is($report->{'total_modules_with_defined_methods'}, 0);
}
sub total_modules_with_defined_attributes_when_no_modules_where_defined : Tests {
my $report = $global_metrics->report;
is($report->{'total_modules_with_defined_attributes'}, 0);
}
sub total_modules_with_defined_attributes_when_a_module_has_noa : Tests{
my %module_values = (noa => 1);
$global_metrics->add_module_values(\%module_values);
my $report = $global_metrics->report;
is($report->{'total_modules_with_defined_attributes'}, 1);
}
sub total_modules_with_defined_attributes_when_a_module_has_no_noa : Tests {
my %module_values = (noa => 0);
$global_metrics->add_module_values(\%module_values);
my $report = $global_metrics->report;
is($report->{'total_modules_with_defined_attributes'}, 0);
}
sub total_nom_with_no_nom_found : Tests {
my $report = $global_metrics->report;
is($report->{'total_nom'}, 0);
}
sub one_total_nom_found : Tests {
my %module_values = (nom => 1);
$global_metrics->add_module_values(\%module_values);
my $report = $global_metrics->report;
is($report->{'total_nom'}, 1);
}
sub sum_the_values_of_nom_found : Tests {
my %module_values = (nom => 1);
$global_metrics->add_module_values(\%module_values);
my %other_values = (nom => 3);
$global_metrics->add_module_values(\%other_values);
my $report = $global_metrics->report;
is($report->{'total_nom'}, 4);
}
sub total_loc_with_no_loc_found : Tests {
my $report = $global_metrics->report;
is($report->{'total_loc'}, 0);
}
sub one_total_loc_found : Tests {
my %module_values = (loc => 1);
$global_metrics->add_module_values(\%module_values);
my $report = $global_metrics->report;
is($report->{'total_loc'}, 1);
}
sub sum_the_values_of_loc_found : Tests {
my %module_values = (loc => 1);
$global_metrics->add_module_values(\%module_values);
my %other_values = (loc => 3);
$global_metrics->add_module_values(\%other_values);
my $report = $global_metrics->report;
is($report->{'total_loc'}, 4);
}
sub add_loc_mean_when_there_was_no_added_values : Tests {
my $report = $global_metrics->report;
is($report->{'loc_mean'}, undef);
}
sub add_loc_mean_when_there_was_one_added_values : Tests {
my %module_values = (loc => 1);
$global_metrics->add_module_values(\%module_values);
my $report = $global_metrics->report;
is($report->{'loc_mean'}, 1);
}
sub add_loc_mean_when_there_were_two_added_values : Tests {
my %module_values = (loc => 1);
$global_metrics->add_module_values(\%module_values);
my %other_values = (loc => 3);
$global_metrics->add_module_values(\%other_values);
my $report = $global_metrics->report;
is($report->{'loc_mean'}, 2);
}
sub add_lcom4_mean_when_there_were_two_added_values : Tests {
my %module_values = (lcom4 => 1);
$global_metrics->add_module_values(\%module_values);
my %other_values = (lcom4 => 3);
$global_metrics->add_module_values(\%other_values);
my $report = $global_metrics->report;
is($report->{'lcom4_mean'}, 2);
}
sub add_rfc_sum_when_there_were_two_added_values : Tests {
my %module_values = (rfc => 1);
$global_metrics->add_module_values(\%module_values);
my %other_values = (rfc => 3);
$global_metrics->add_module_values(\%other_values);
my $report = $global_metrics->report;
is($report->{'rfc_sum'}, 4);
}
sub should_have_other_descriptive_statistics : Tests {
my %module_values = (rfc => 1);
$global_metrics->add_module_values(\%module_values);
my $report = $global_metrics->report;
isnt($report->{'rfc_mean'}, undef);
isnt($report->{'rfc_quantile_max'}, undef);
isnt($report->{'rfc_standard_deviation'}, undef);
isnt($report->{'rfc_sum'}, undef);
isnt($report->{'rfc_variance'}, undef);
}
sub should_have_distributions_statistics : Tests {
my %module_values = (rfc => 4);
$global_metrics->add_module_values(\%module_values);
$global_metrics->add_module_values(\%module_values);
$global_metrics->add_module_values(\%module_values);
$global_metrics->add_module_values(\%module_values);
my $report = $global_metrics->report;
isnt($report->{'rfc_kurtosis'}, undef);
isnt($report->{'rfc_skewness'}, undef);
}
sub should_add_total_coupling_factor : Tests {
my $report = $global_metrics->report;
is($report->{'total_cof'}, 1);
my %module_values = (acc => 1);
$global_metrics->add_module_values(\%module_values);
$global_metrics->add_module_values(\%module_values);
$global_metrics->add_module_values(\%module_values);
$report = $global_metrics->report;
is($report->{'total_cof'}, 0.5);
}
sub should_ignore_module_name : Tests {
my %module_values = ('_module' => 'mod1');
$global_metrics->add_module_values(\%module_values);
my $report = $global_metrics->report;
is($report->{'_module'}, undef);
}
sub list_of_metrics : Tests {
my %metrics = $global_metrics->list();
cmp_ok(scalar(keys(%metrics)), '>', 0, 'must list metrics');
}
sub should_ignore_filename : Tests {
my %values = (_filename => 'main.c');
$global_metrics->add_module_values(\%values);
my $report = $global_metrics->report;
ok(! grep(/^_filename/, keys %$report), "Should ignore _filename metrics");
}
__PACKAGE__->runtests;
t/Analizo/Metrics.t view on Meta::CPAN
my $output = $metrics->report;
$output =~ m/total_modules: ([0-9]+)/;
my $modules = $1;
is($modules, 2, 'reporting number of classes in YAML stream');
ok($output =~ /_module: mod1/, 'reporting module 1');
ok($output =~ /_module: mod2/, 'reporting module 2');
}
sub report_global_only : Tests {
sample_modules_for_report();
my $output = $metrics->report_global_metrics_only;
ok($output =~ /total_modules: 2/, 'reporting number of classes (it is global)');
ok($output !~ /_module: mod1/, 'not reporting module 1 details');
ok($output !~ /_module: mod2/, 'not reporting module 2 details');
}
sub report_without_modules_at_all : Tests {
# if this call does not crash we are fine
$metrics->report;
}
sub list_of_metrics : Tests {
t/author-pod-spell.t view on Meta::CPAN
da
DIT
doxyparse
Doxyparse
dsm
DSN
ecfb
efd
egypt
fbad
globalonly
GPL
Graphviz
Gratio
Guerreiro
Gustafsson
Hedley
Hennell
hh
hpp
Hyatt
t/features/metrics/global_only.feature view on Meta::CPAN
Feature: output only global metrics
As a researcher
I want to ouput only the global metrics
So that I can evaluate several projects at once
Background:
Given I am in t/samples/sample_basic/c/
Scenario: simple case
When I run "analizo metrics --global-only ."
Then the output must match "cbo_mean:"
And the output must not match "_module:"
Scenario: short version
When I run "analizo metrics -g ."
Then the output must match "cbo_mean:"
And the output must not match "_module:"
t/samples/kdelibs/backportglobal.h view on Meta::CPAN
- https://github.com/analizo/analizo/issues/173
GitHub kdelibs repository:
- https://github.com/KDE/kdelibs.git
Original file was copied from the commit 0f4cf41b22 from kdelibs git repository
and it is located inside kdelibs repository on the path below.
- experimental/libkdeclarative/bindings/backportglobal.h
Link to the original file on GitHub:
- https://github.com/KDE/kdelibs/blob/9941ebff54bd9d4349c0384dfa0cca2ace9549c4/experimental/libkdeclarative/bindings/backportglobal.h
*/
/****************************************************************************
**
** This file is part of the Qt Script Generator.
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation info@qt.nokia.com
t/samples/kdelibs/daterange.cpp view on Meta::CPAN
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "daterange.h"
#include "kglobal.h"
#include "klocale.h"
#include "kcalendarsystem.h"
#include <QtCore/QSharedData>
#include <QtCore/QDebug>
class DateRange::Private : public QSharedData
{
public: