1Perl::Metrics::Simple(3U)ser Contributed Perl DocumentatiPoenrl::Metrics::Simple(3)
2
3
4
6 Perl::Metrics::Simple - Count packages, subs, lines, etc. of many
7 files.
8
10 use Perl::Metrics::Simple;
11 my $analyzer = Perl::Metrics::Simple->new;
12 my $analysis = $analyzer->analyze_files(@paths, @refs_to_file_contents);
13 $file_count = $analysis->file_count;
14 $package_count = $analysis->package_count;
15 $sub_count = $analysis->sub_count;
16 $lines = $analysis->lines;
17 $main_stats = $analysis->main_stats;
18 $file_stats = $analysis->file_stats;
19
21 This is VERSION 0.12
22
24 Perl::Metrics::Simple provides just enough methods to run static
25 analysis of one or many Perl files and obtain a few metrics: packages,
26 subroutines, lines of code, and an approximation of cyclomatic (mccabe)
27 complexity for the subroutines and the "main" portion of the code.
28
29 Perl::Metrics::Simple is far simpler than Perl::Metrics.
30
31 Installs a script called countperl.
32
34 See the countperl script (included with this distribution) for a simple
35 example of usage.
36
38 new
39 Takes no arguments and returns a new Perl::Metrics::Simple object.
40
41 is_perl_file
42 Takes a path and returns true if the target is a Perl file.
43
45 analyze_files( @paths, @refs_to_file_contents )
46 Takes an array of files and or directory paths, and/or SCALAR refs to
47 file contents and returns an Perl::Metrics::Simple::Analysis object.
48
49 find_files( @directories_and_files )
50 Uses list_perl_files to find all the readable Perl files and returns a
51 reference to a (possibly empty) list of paths.
52
53 list_perl_files
54 Takes a list of one or more paths and returns an alphabetically sorted
55 list of only the perl files. Uses is_perl_file so may throw an
56 exception if a file is unreadable.
57
58 is_perl_file($path)
59 Takes a path to a file and returns true if the file appears to be a
60 Perl file, otherwise returns false.
61
62 If the file name does not match any of
63 @Perl::Metrics::Simple::PERL_FILE_SUFFIXES then the file is opened for
64 reading and the first line examined for a a Perl 'shebang' line. An
65 exception is thrown if the file cannot be opened in this case.
66
67 should_be_skipped($path)
68 Returns true if the path should be skipped when looking for Perl files.
69 Currently skips .svn, CVS, and _darcs directories.
70
72 See: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Perl-Metrics-Simple
73
75 Via CPAN:
76
77 Disussion Forum
78 http://www.cpanforum.com/dist/Perl-Metrics-Simple
79
80 Bug Reports
81 http://rt.cpan.org/NoAuth/Bugs.html?Dist=Perl-Metrics-Simple
82
84 Matisse Enzer
85 CPAN ID: MATISSE
86 Eigenstate Consulting, LLC
87 matisse@eigenstate.net
88 http://www.eigenstate.net/
89
91 Copyright (c) 2006-2009 by Eigenstate Consulting, LLC.
92
93 This program is free software; you can redistribute it and/or modify it
94 under the same terms as Perl itself.
95
96 The full text of the license can be found in the LICENSE file included
97 with this module.
98
100 The countperl script included with this distribution.
101 PPI
102 Perl::Critic
103 Perl::Metrics
104 http://en.wikipedia.org/wiki/Cyclomatic_complexity
105
106
107
108perl v5.30.1 2020-01-30 Perl::Metrics::Simple(3)