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   6 use strict;
  1         2  
  1         33  
2 1     1   5 use warnings;
  1         2  
  1         53  
3              
4             package Code::Statistics;
5             {
6             $Code::Statistics::VERSION = '1.112980';
7             }
8              
9             # ABSTRACT: collects and reports statistics on perl code
10              
11              
12              
13 1     1   343 use Code::Statistics::Config;
  1         3  
  1         53  
14 1     1   466 use Code::Statistics::Collector;
  1         4  
  1         51  
15 1     1   473 use Code::Statistics::Reporter;
  1         4  
  1         61  
16              
17 1     1   12 use Moose;
  1         3  
  1         9  
18 1     1   8206 use MooseX::HasDefaults::RO;
  1         3  
  1         10  
19 1     1   5371 use MooseX::SlurpyConstructor 1.1;
  1         32  
  1         8  
20              
21             has config_args => (
22             is => 'ro',
23             slurpy => 1,
24             default => sub { {} },
25             );
26              
27             sub _command_config {
28 3     3   10 my ( $self ) = @_;
29 3         6 my $config = Code::Statistics::Config->new( %{ $self->config_args } )->assemble;
  3         76  
30 3         34 return $config;
31             }
32              
33              
34              
35             sub collect {
36 2     2 1 1732 my ( $self ) = @_;
37 2         10 return Code::Statistics::Collector->new( $self->_command_config )->collect;
38             }
39              
40              
41             sub report {
42 1     1 1 607 my ( $self ) = @_;
43 1         4 return Code::Statistics::Reporter->new( $self->_command_config )->report;
44             }
45              
46              
47             1;
48              
49             __END__
50             =pod
51              
52             =head1 NAME
53              
54             Code::Statistics - collects and reports statistics on perl code
55              
56             =head1 VERSION
57              
58             version 1.112980
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             This software is Copyright (c) 2010 by Christian Walde.
129              
130             This is free software, licensed under:
131              
132             DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE, Version 2, December 2004
133              
134             =cut
135