File Coverage

lib/Code/Statistics.pm
Criterion Covered Total %
statement 32 32 100.0
branch n/a
condition n/a
subroutine 11 11 100.0
pod 2 2 100.0
total 45 45 100.0


line stmt bran cond sub pod time code
1 1     1   5 use strict;
  1         1  
  1         34  
2 1     1   5 use warnings;
  1         1  
  1         47  
3              
4             package Code::Statistics;
5             $Code::Statistics::VERSION = '1.190680';
6             # ABSTRACT: collects and reports statistics on perl code
7              
8              
9              
10 1     1   279 use Code::Statistics::Config;
  1         3  
  1         49  
11 1     1   403 use Code::Statistics::Collector;
  1         2  
  1         42  
12 1     1   376 use Code::Statistics::Reporter;
  1         3  
  1         41  
13              
14 1     1   9 use Moose;
  1         1  
  1         7  
15 1     1   5707 use MooseX::HasDefaults::RO;
  1         2  
  1         7  
16 1     1   4610 use MooseX::SlurpyConstructor 1.1;
  1         23  
  1         6  
17              
18             has config_args => (
19             is => 'ro',
20             slurpy => 1,
21             default => sub { {} },
22             );
23              
24             sub _command_config {
25 3     3   8 my ( $self ) = @_;
26 3         6 my $config = Code::Statistics::Config->new( %{ $self->config_args } )->assemble;
  3         56  
27 3         15 return $config;
28             }
29              
30              
31              
32             sub collect {
33 2     2 1 1448 my ( $self ) = @_;
34 2         8 return Code::Statistics::Collector->new( $self->_command_config )->collect;
35             }
36              
37              
38             sub report {
39 1     1 1 639 my ( $self ) = @_;
40 1         4 return Code::Statistics::Reporter->new( $self->_command_config )->report;
41             }
42              
43              
44             1;
45              
46             __END__
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             Code::Statistics - collects and reports statistics on perl code
55              
56             =head1 VERSION
57              
58             version 1.190680
59              
60             =head1 SYNOPSIS
61              
62             On a terminal:
63              
64             # collect statistics on the current directory and sub-directories,
65             # then store results in codestat.out as json
66             codestat collect
67              
68             # compile a report from codestat.out and print to the terminal
69             codestat report
70              
71             =head1 DESCRIPTION
72              
73             This is a framework to collect various metrics on a codebase and report them
74             in a summarized manner. It is meant to be as extensible as possible.
75              
76             The current collection workflows are as follow:
77              
78             =head2 Collection
79              
80             All files in the search path are collected.
81              
82             Target constructs as defined by modules living under Code::Statistics::Target:: are collected for all files.
83              
84             Metrics as defined by modules living under Code::Statistics::Metric:: are collected for all targets.
85              
86             All data is dumped as json to C<codestat.out>.
87              
88             =head2 Reporting
89              
90             Data from the local C<codestat.out> is read.
91              
92             Data is grouped by target and for each target type the following is printed:
93              
94             Averages of all non-location metrics.
95              
96             Tables with the top ten and bottom ten for each significant metric.
97              
98             =head1 SUBROUTINES/METHODS
99              
100             This module acts mostly as a dispatcher and collects configuration data,
101             then forwards it to actual action modules. These are the methods it
102             currently provides.
103              
104             =head2 collect
105              
106             Dispatches configuration to the statistics collector module.
107              
108             =head2 report
109              
110             Dispatches configuration to the statistics reporter module.
111              
112             =head1 TODO
113              
114             Possibly elevate metrics to objects to allow parametrized metrics during
115             collection. Not sure if i want this or whether making more generic metrics is a
116             better idea. http://gist.github.com/549132
117              
118             =head1 SEE ALSO
119              
120             PPI::Tester
121              
122             =head1 AUTHOR
123              
124             Christian Walde <mithaldu@yahoo.de>
125              
126             =head1 COPYRIGHT AND LICENSE
127              
128              
129             Christian Walde has dedicated the work to the Commons by waiving all of his
130             or her rights to the work worldwide under copyright law and all related or
131             neighboring legal rights he or she had in the work, to the extent allowable by
132             law.
133              
134             Works under CC0 do not require attribution. When citing the work, you should
135             not imply endorsement by the author.
136              
137             =cut