Skip to content

Instantly share code, notes, and snippets.

@wchristian
Created August 27, 2010 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wchristian/553572 to your computer and use it in GitHub Desktop.
Save wchristian/553572 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
package Code::Statistics::Metric::ccomp;
# ABSTRACT: measures the cyclomatic complexity of a target
use Moose;
extends 'Code::Statistics::Metric';
use Perl::Metrics::Simple::Analysis::File;
=head2 measure
Returns the cyclomatic complexity of the given target.
=cut
sub measure {
my ( $class, $target ) = @_;
my $s = bless {}, 'Perl::Metrics::Simple::Analysis::File';
# setup default lists for keywords and operators
%Perl::Metrics::Simple::Analysis::File::LOGIC_KEYWORDS =
Perl::Metrics::Simple::Analysis::File::hashify(@Perl::Metrics::Simple::Analysis::File::DEFAULT_LOGIC_KEYWORDS);
%Perl::Metrics::Simple::Analysis::File::LOGIC_OPERATORS =
Perl::Metrics::Simple::Analysis::File::hashify(@Perl::Metrics::Simple::Analysis::File::DEFAULT_LOGIC_OPERATORS);
my $complexity = $s->measure_complexity( $target );
return $complexity;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment