Perl::Metric::Basic

Perl::Metric::Basic is a Perl module that can provide basic software metrics.
Download

Perl::Metric::Basic Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Leon Brocard
  • Publisher web site:
  • http://search.cpan.org/~lbrocard/

Perl::Metric::Basic Tags


Perl::Metric::Basic Description

Perl::Metric::Basic is a Perl module that can provide basic software metrics. Perl::Metric::Basic is a Perl module that can provide basic software metrics.SYNOPSIS # first construct a PPI::Document object to pass in my $document = PPI::Document->load("t/lib/Acme.pm"); # then retrieve metrics on the document my $m = Perl::Metric::Basic->new; my $metric = $m->measure($document); # $metric will consist of something like: # 'Acme' => { # 'new' => { # 'blank_lines' => 1, # 'comments' => 1, # 'lines' => 7, # 'lines_of_code' => 6, # 'numbers' => 0, # 'numbers_unique' => 0, # 'operators' => 3, # 'operators_unique' => 2, # 'symbols' => 5, # 'symbols_unique' => 2, # 'words' => 7, # 'words_unique' => 6 # }, # ...When constructing software one often produces code of vastly differing quality. The Perl::Metric::Basic module leverages the PPI module to provide some interesting software metrics for Perl code, mostly measuring size and maintainability.A metric is some sort of measurement which is intended to help you make a decision about a piece of code. There aren't any hard rules about metrics, but the ones provided should allow you to make decisions about modules or subroutines which are outliers. Abnormal measurements in a subroutine are a warning sign that you should reexamine that routine, checking for unusually low quality.This module uses the PPI module, and thus can parse Perl code without evaluating it.If you're interested in software metrics, I highly recommend "Code Complete" (Second Edition) by Steve McConnel (Microsoft Press).METHODSnew()The new() method is the constructor: my $m = Perl::Metric::Basic->new;measure()The measure() method measures some metrics and returns a hash reference. Files in Perl can contain more than one package, and it is interesting to seperate metrics by package. The key for the hash reference is the name of the package, and the value is another hash reference.Perl packages are seperated into subroutines, and it is interesting to seperate metrics by subroutine. The key for the second hash reference is the name of the subroutine, and the value is another hash reference containing metrics.There are various metrics applied to the subroutine. The key for the third hash reference is the name of the metric, and the value is the value of the metric. The metrics are:blank_linesThe number of blank code lines.commentsThe number of lines containing comments.linesThe total number of lines.lines_of_codeThe number of lines of code.numbersThe total number of numbers used (eg "$z = 42 * 3" would have 2 numbers).numbers_uniqueThe number of unique numbers used (eg "$z = 2*$x + 2*$y" would have 1 unique number).operatorsThe total number of operators used.operators_uniqueThe number of unique operators used.symbolsThe total number of symbols used (eg "$z = $x*$x + $y*$y" would have 5 symbols).symbols_uniqueThe number of unique symbols used (eg "$z = $x*$x + $y*$y" would have 3 unique symbols).wordsThe total number of words (operators) used.words_uniqueThe number of unique words used.Requirements:· Perl Requirements: · Perl


Perl::Metric::Basic Related Software