Analizo/Command/metrics_batch.pm

filter: Statementstmt 58.1% 25 / 43 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 76.9% 10 / 13 Podpod 80.0% 4 / 5 totaltotal 54.1% 39 / 72 CC 5 SCAR 16.0
CC
5
Cov
48%
validate
12.0
execute
12.0
__ANON__
2.0
CRAP 4.9
« Analizo/Batch/Git.pm ↑ Summary Analizo/Batch/Job.pm »
1 package Analizo::Command::metrics_batch;
2 9 ▶use Analizo -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use parent qw(Analizo::Command);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use Analizo::Batch::Directories;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use Analizo::Batch::Output::CSV;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # ABSTRACT: processes several source code directories in batch
11  
12 =head1 NAME
13  
14 analizo-metrics-batch - processes several source code directories in batch
15  
16 =head1 USAGE
17  
18 analizo metrics-batch [OPTIONS] [<input> [<input> ...]]
19  
20 =cut
21  
22 2 ▶sub usage_desc { "%c metrics-batch %o [<input> [<input> ...]]" }
Subroutine usage_desc: called CC=1 SCAR=0.0
Pod documented
23  
24 26 ▶sub command_names { qw/metrics-batch/ }
Subroutine command_names: called CC=1 SCAR=0.0
Pod documented
25  
26 2 ▶sub opt_spec {
Subroutine opt_spec: called CC=1 SCAR=0.0
Pod documented
27 return (
28 2 [ 'output|o=s', 'output file name', { default => 'metrics.csv' } ],
29 [ 'quiet|q', 'supresses messages to standard output' ],
30 [ 'parallel|p=i', 'activates support for parallel processing' ],
31 );
32 }
33  
34 0 ▶sub validate {
Subroutine validate: not called CC=3 SCAR=24.8
Pod undocumented
35 0 my ($self, $opt, $args) = @_;
36 0 ▶ if ($opt->output && ! -w dirname($opt->output)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->output and not -w dirname($opt->output)) 0 0 0
Condition0%0/3
$opt->output and not -w dirname($opt->output)
!ll&&!rl&&r
000
MC/DC0%0/2
$opt->output and not -w dirname($opt->output)
$opt->output not -w dirname($opt->output)
Truth table0%0/3
A and not(B)
A= $opt->outputB= not -w dirname($opt->output)
ABresult
0X0
100
111
37 0 $self->usage_error("Output is not writable!");
38 }
39 }
40  
41 0 ▶sub execute {
Subroutine execute: not called CC=3 SCAR=24.8
Pod documented
42 0 my ($self, $opt, $args) = @_;
43 0 my $runner = undef;
44 0 ▶ if ($opt->parallel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->parallel) { } 0 0 0
45 0 require Analizo::Batch::Runner::Parallel;
46 0 $runner = Analizo::Batch::Runner::Parallel->new($opt->parallel);
47 } else {
48 0 require Analizo::Batch::Runner::Sequential;
49 0 $runner = Analizo::Batch::Runner::Sequential->new;
50 }
51 0 ▶ unless ($opt->quiet) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt->quiet) 0 0 0
52 $runner->progress(
53 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 my ($job, $done, $total) = @_;
55 0 printf("I: Processed %s.\n", $job->id);
56 }
57 0 );
58 }
59 0 my $batch = Analizo::Batch::Directories->new(@$args);
60 0 my $output = Analizo::Batch::Output::CSV->new;
61 0 $output->file($opt->output);
62 0 $runner->run($batch, $output);
63 }
64  
65 =head1 DESCRIPTION
66  
67 Processes several source code directories in batch running B<analizo metrics>
68 for each and optionally consolidating the results in a single data file.
69  
70 B<analizo metrics-batch> is useful when you want to analyze several projects at
71 once, or several different versions of the same project. You pass a list of
72 directories in the command line and each one will be analyzed as a separate
73 project. If no directories are passed in the command line, all of the
74 subdirectories of the current directory will be analized.
75  
76 For example, suppose you want to process 5 consecutive releases of
77 I<myproject>, from version 0.1.0 to 0.5.0.
78  
79 =over
80  
81 =item
82  
83 First you unpack the release tarballs for those versions in a directory, say
84 /tmp/analysis:
85  
86 $ ls -1 /tmp/analysis
87 myproject-0.1.0
88 myproject-0.2.0
89 myproject-0.3.0
90 myproject-0.4.0
91 myproject-0.5.0
92  
93 =item
94  
95 Then you change to that directory, and then run B<analizo metrics-batch>:
96  
97 $ cd /tmp/analysis
98 $ analizo metrics-batch
99  
100 =item
101  
102 B<analizo metrics-batch> will collect the metrics
103 data in a single .csv file, that you can import in spreadsheet software or
104 statistical packages.
105  
106 =back
107  
108 analizo metrics-batch is part of the analizo suite.
109  
110 =head1 OPTIONS
111  
112 =over
113  
114 =item --parallel N, -p N
115  
116 Activates support for parallel processing, using I<N> concurrent worker
117 processes. Usually you will want N to be less than or equal to the number of
118 CPUs in your machine.
119  
120 Note that analizo metrics extraction is a CPU-intensive process, so setting N
121 as the exactly number of CPUs you have may bring your machine to an unusable
122 state.
123  
124 =item --output <file>, -o <file>
125  
126 Write output to <file>. Default is to write to I<metrics.csv>. That file can
127 then be opened in data analysis programs.
128  
129 =item --quiet, -q
130  
131 Suppresses messages to standard output.
132  
133 =back
134  
135 =head1 COPYRIGHT AND AUTHORS
136  
137 See B<analizo(1)>.
138  
139 =cut
140  
141 9 1;
« Analizo/Batch/Git.pm ↑ Summary Analizo/Batch/Job.pm »