Perl::Metrics::Halstead - Compute Halstead complexity metrics
version 0.0602
use Perl::Metrics::Halstead; my $halstead = Perl::Metrics::Halstead->new(file => '/some/perl/code.pl'); my $metrics = $halstead->dump; $halstead->report;
Perl::Metrics::Halstead computes software Halstead complexity metrics.
Perl::Metrics::Halstead
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 http://techn.ology.net/halstead-software-complexity-of-perl-code/
All attributes are calculated except for file, which is required to be given in the constructor.
$file = $halstead->file;
The file to analyze.
$n = $halstead->n_operators;
The total number of operators.
$n = $halstead->n_operands;
The total number of operands.
$n = $halstead->n_distinct_operators;
The number of distinct operators.
$n = $halstead->n_distinct_operands;
The number of distinct operands.
$x = $halstead->prog_vocab;
The program vocabulary.
$x = $halstead->prog_length;
The program length.
$x = $halstead->est_prog_length;
The estimated program length.
$x = $halstead->volume;
The program volume.
$x = $halstead->difficulty;
The program difficulty.
$x = $halstead->level;
The program level.
$x = $halstead->lang_level;
The programming language level.
$x = $halstead->intel_content;
Measure of the information content of a program.
$x = $halstead->effort;
The program effort.
$x = $halstead->time_to_program;
The time to program (in seconds).
$x = $halstead->delivered_bugs;
Delivered bugs.
$halstead = Perl::Metrics::Halstead->new(file => $file);
Create a new Perl::Metrics::Halstead object given the file argument.
Process the given file into the computed metrics.
$halstead->report;
Print the computed metrics to STDOUT.
STDOUT
$metrics = $halstead->dump;
Return a hashref of the metrics and their computed values.
The eg/analyze and t/01-methods.t file in this distribution.
Moo
PPI::Document
PPI::Dumper
https://en.wikipedia.org/wiki/Halstead_complexity_measures
http://techn.ology.net/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/
Gene Boggs <gene@cpan.org>
This software is copyright (c) 2019 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.
To install Perl::Metrics::Halstead, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::Metrics::Halstead
CPAN shell
perl -MCPAN -e shell install Perl::Metrics::Halstead
For more information on module installation, please visit the detailed CPAN module installation guide.