File Coverage

blib/lib/App/Critique/Command/status.pm
Criterion Covered Total %
statement 15 72 20.8
branch 0 22 0.0
condition 0 20 0.0
subroutine 5 6 83.3
pod 1 1 100.0
total 21 121 17.3


line stmt bran cond sub pod time code
1             package App::Critique::Command::status;
2              
3 1     1   1107 use strict;
  1         3  
  1         25  
4 1     1   23 use warnings;
  1         2  
  1         47  
5              
6             our $VERSION = '0.05';
7             our $AUTHORITY = 'cpan:STEVAN';
8              
9 1     1   5 use Term::ANSIColor ':constants';
  1         2  
  1         228  
10              
11 1     1   7 use App::Critique::Session;
  1         3  
  1         25  
12              
13 1     1   5 use App::Critique -command;
  1         2  
  1         6  
14              
15             sub execute {
16 0     0 1   my ($self, $opt, $args) = @_;
17              
18 0           local $Term::ANSIColor::AUTORESET = 1;
19              
20 0           my $session = $self->cautiously_load_session( $opt, $args );
21              
22 0           info('Session file loaded.');
23              
24 0           my @tracked_files = $session->tracked_files;
25 0           my $num_files = scalar @tracked_files;
26 0           my $curr_file_idx = $session->current_file_idx;
27 0           my $git = $session->git_wrapper;
28              
29 0           my ($violations, $reviewed, $edited, $commited) = (0, 0, 0, 0);
30 0           foreach my $file ( @tracked_files ) {
31 0 0         $violations += $file->recall('violations') if defined $file->recall('violations');
32 0 0         $reviewed += $file->recall('reviewed') if defined $file->recall('reviewed');
33 0 0         $edited += $file->recall('edited') if defined $file->recall('edited');
34 0 0         $commited += $file->recall('commited') if defined $file->recall('commited');
35             }
36              
37 0 0         if ( $opt->verbose ) {
38 0           info(HR_DARK);
39 0           info('CONFIG:');
40 0           info(HR_LIGHT);
41 0   0       info(' perl_critic_profile = %s', $session->perl_critic_profile // '[...]');
42 0   0       info(' perl_critic_theme = %s', $session->perl_critic_theme // '[...]');
43 0   0       info(' perl_critic_policy = %s', $session->perl_critic_policy // '[...]');
44 0           info(HR_LIGHT);
45 0           info(' git_work_tree = %s', $session->git_work_tree );
46 0           info(' git_work_tree_root = %s', $session->git_work_tree_root );
47 0           info(' git_branch = %s', $session->git_branch );
48 0           info(' git_head_sha = %s', $session->git_head_sha );
49            
50 0           info(HR_DARK);
51 0           info('FILE CRITERIA:');
52 0           info(HR_LIGHT);
53 0   0       info(' filter = %s', $session->file_criteria->{'filter'} // '[...]');
54 0   0       info(' match = %s', $session->file_criteria->{'match'} // '[...]');
55 0   0       info(' no-violation = %s', $session->file_criteria->{'no_violation'} // '[...]');
56             }
57              
58 0           info(HR_DARK);
59 0           info('FILES: <legend: [v|r|e|c]:(idx) path>');
60 0 0         if ( $opt->verbose ) {
61 0           info(HR_LIGHT);
62 0           info('CURRENT FILE INDEX: (%d)', $curr_file_idx);
63             }
64 0           info(HR_LIGHT);
65 0 0         if ( $num_files ) {
66 0           foreach my $i ( 0 .. $#tracked_files ) {
67 0           my $file = $tracked_files[$i];
68 0 0 0       info('%s [%s|%s|%s|%s]:(%d) %s',
      0        
      0        
      0        
69             ($i == $curr_file_idx ? '>' : ' '),
70             $file->recall('violations') // '-',
71             $file->recall('reviewed') // '-',
72             $file->recall('edited') // '-',
73             $file->recall('commited') // '-',
74             $i,
75             $file->relative_path( $session->git_work_tree_root ),
76             );
77 0 0         if ( $opt->verbose ) {
78 0 0         foreach my $sha ( @{ $file->recall('shas') || [] } ) {
  0            
79 0           info(' | %s', $git->show($sha, { format => '%h - %s', s => 1 }));
80             }
81             }
82             }
83             }
84             else {
85 0           info(ITALIC('... no files added.'));
86             }
87 0           info(HR_DARK);
88 0           info('TOTAL: %s file(s)', format_number($num_files) );
89 0           info(' (v)iolations = %s', format_number($violations));
90 0           info(' (r)eviwed = %s', format_number($reviewed) );
91 0           info(' (e)dited = %s', format_number($edited) );
92 0           info(' (c)ommited = %s', format_number($commited) );
93              
94 0 0         if ( $opt->verbose ) {
95 0           info(HR_LIGHT);
96 0           info('PATH: (%s)', $session->session_file_path);
97             }
98 0           info(HR_DARK);
99              
100             }
101              
102             1;
103              
104             =pod
105              
106             =head1 NAME
107              
108             App::Critique::Command::status - Display status of the current critique session.
109              
110             =head1 VERSION
111              
112             version 0.05
113              
114             =head1 DESCRIPTION
115              
116             This command will display information about the current critique session.
117             Among other things, this will include information about each of the files,
118             such as how many violations were found, how many of those violations were
119             reviewed, and how many were edited.
120              
121             =head1 AUTHOR
122              
123             Stevan Little <stevan@cpan.org>
124              
125             =head1 COPYRIGHT AND LICENSE
126              
127             This software is copyright (c) 2016 by Stevan Little.
128              
129             This is free software; you can redistribute it and/or modify it under
130             the same terms as the Perl 5 programming language system itself.
131              
132             =cut
133              
134             __END__
135              
136             # ABSTRACT: Display status of the current critique session.
137