NAME
Perl::Metrics::Halstead - Compute Halstead complexity metrics
VERSION
version 0.0617
SYNOPSIS
use Perl::Metrics::Halstead;
my $halstead = Perl::Metrics::Halstead->new(file => '/some/perl/code.pl');
my $metrics = $halstead->dump;
$halstead->report; # Print to STDOUT
DESCRIPTION
Perl::Metrics::Halstead
computes software Halstead complexity metrics.
Please see the explanatory links in the "SEE ALSO" section for descriptions of what these attributes mean and how they are computed.
My write-up about this technique is at https://ology.github.io/2019/03/19/halstead-software-complexity-of-perl-code/
The installed program for computing this is called halstead.
ATTRIBUTES
All attributes are calculated except for file, which is required to be given in the constructor.
file
$file = $halstead->file;
The file to analyze.
n_operators
$n = $halstead->n_operators;
The total number of operators.
n_operands
$n = $halstead->n_operands;
The total number of operands.
n_distinct_operators
$n = $halstead->n_distinct_operators;
The number of distinct operators.
n_distinct_operands
$n = $halstead->n_distinct_operands;
The number of distinct operands.
prog_vocab
$x = $halstead->prog_vocab;
The program vocabulary.
prog_length
$x = $halstead->prog_length;
The program length.
est_prog_length
$x = $halstead->est_prog_length;
The estimated program length.
volume
$x = $halstead->volume;
The program volume.
difficulty
$x = $halstead->difficulty;
The program difficulty.
level
$x = $halstead->level;
The program level.
lang_level
$x = $halstead->lang_level;
The programming language level.
intel_content
$x = $halstead->intel_content;
Measure of the information content of a program.
effort
$x = $halstead->effort;
The program effort.
time_to_program
$x = $halstead->time_to_program;
The time to program (in seconds).
delivered_bugs
$x = $halstead->delivered_bugs;
Delivered bugs.
METHODS
new
$halstead = Perl::Metrics::Halstead->new(file => $file);
Create a new Perl::Metrics::Halstead
object given the file argument.
report
$halstead->report;
$halstead->report($precision);
Print the computed metrics to STDOUT
. Optionally provide a number for the decimal precision. Default: 2 digits
dump
$metrics = $halstead->dump;
Return a hashref of the metrics and their computed values.
SEE ALSO
The bin/halstead, eg/git-halstead and t/01-methods.t files in this distribution.
https://en.wikipedia.org/wiki/Halstead_complexity_measures
https://ology.github.io/2019/03/19/halstead-software-complexity-of-perl-code/
https://www.verifysoft.com/en_halstead_metrics.html
https://www.geeksforgeeks.org/software-engineering-halsteads-software-metrics/
https://www.compuware.com/hard-can-find-halstead-maintenance-effort-metric/
AUTHOR
Gene Boggs <gene@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2022 by Gene Boggs.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.