line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Exception::AggregateConfiguration; |
2
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
20976
|
use 5.010001; |
|
40
|
|
|
|
|
159
|
|
4
|
40
|
|
|
40
|
|
281
|
use strict; |
|
40
|
|
|
|
|
90
|
|
|
40
|
|
|
|
|
883
|
|
5
|
40
|
|
|
40
|
|
223
|
use warnings; |
|
40
|
|
|
|
|
94
|
|
|
40
|
|
|
|
|
1229
|
|
6
|
|
|
|
|
|
|
|
7
|
40
|
|
|
40
|
|
243
|
use Carp qw{ confess }; |
|
40
|
|
|
|
|
111
|
|
|
40
|
|
|
|
|
2134
|
|
8
|
40
|
|
|
40
|
|
772
|
use English qw(-no_match_vars); |
|
40
|
|
|
|
|
3709
|
|
|
40
|
|
|
|
|
266
|
|
9
|
40
|
|
|
40
|
|
15410
|
use Readonly; |
|
40
|
|
|
|
|
8480
|
|
|
40
|
|
|
|
|
1982
|
|
10
|
|
|
|
|
|
|
|
11
|
40
|
|
|
40
|
|
13868
|
use Perl::Critic::Utils qw{ :characters }; |
|
40
|
|
|
|
|
153
|
|
|
40
|
|
|
|
|
1467
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '1.146'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Exception::Class ( |
18
|
40
|
|
|
|
|
422
|
'Perl::Critic::Exception::AggregateConfiguration' => { |
19
|
|
|
|
|
|
|
isa => 'Perl::Critic::Exception', |
20
|
|
|
|
|
|
|
description => 'A collected set of configuration exceptions.', |
21
|
|
|
|
|
|
|
fields => [ qw{ exceptions } ], |
22
|
|
|
|
|
|
|
alias => 'throw_aggregate', |
23
|
|
|
|
|
|
|
}, |
24
|
40
|
|
|
40
|
|
24460
|
); |
|
40
|
|
|
|
|
152
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw< throw_aggregate >; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
49959
|
|
|
49959
|
1
|
118470
|
my ($class, %options) = @_; |
34
|
|
|
|
|
|
|
|
35
|
49959
|
|
|
|
|
101008
|
my $exceptions = $options{exceptions}; |
36
|
49959
|
50
|
|
|
|
128117
|
if (not $exceptions) { |
37
|
49959
|
|
|
|
|
111010
|
$options{exceptions} = []; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
49959
|
|
|
|
|
197526
|
return $class->SUPER::new(%options); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub add_exception { |
46
|
166
|
|
|
166
|
1
|
154900
|
my ( $self, $exception ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
166
|
|
|
|
|
355
|
push @{ $self->exceptions() }, $exception; |
|
166
|
|
|
|
|
3196
|
|
49
|
|
|
|
|
|
|
|
50
|
166
|
|
|
|
|
1346
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub add_exceptions_from { |
56
|
1
|
|
|
1
|
1
|
5
|
my ( $self, $aggregate ) = @_; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
4
|
push @{ $self->exceptions() }, @{ $aggregate->exceptions() }; |
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
24
|
|
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
7
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub add_exception_or_rethrow { |
66
|
40790
|
|
|
40790
|
1
|
81821
|
my ( $self, $eval_error ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
40790
|
100
|
|
|
|
108139
|
return if not $eval_error; |
69
|
4
|
50
|
|
|
|
45
|
confess $eval_error if not ref $eval_error; |
70
|
|
|
|
|
|
|
|
71
|
4
|
100
|
|
|
|
37
|
if ( $eval_error->isa('Perl::Critic::Exception::Configuration') ) { |
|
|
50
|
|
|
|
|
|
72
|
3
|
|
|
|
|
17
|
$self->add_exception($eval_error); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
elsif ( |
75
|
|
|
|
|
|
|
$eval_error->isa('Perl::Critic::Exception::AggregateConfiguration') |
76
|
|
|
|
|
|
|
) { |
77
|
1
|
|
|
|
|
5
|
$self->add_exceptions_from($eval_error); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { |
80
|
0
|
|
|
|
|
0
|
die $eval_error; ## no critic (RequireCarping) |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
4
|
|
|
|
|
13
|
return; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub has_exceptions { |
89
|
59365
|
|
|
59365
|
1
|
117884
|
my ( $self ) = @_; |
90
|
|
|
|
|
|
|
|
91
|
59365
|
100
|
|
|
|
92058
|
return @{ $self->exceptions() } ? 1 : 0; |
|
59365
|
|
|
|
|
1193681
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Readonly::Scalar my $MESSAGE_PREFIX => $EMPTY; |
97
|
|
|
|
|
|
|
Readonly::Scalar my $MESSAGE_SUFFIX => "\n"; |
98
|
|
|
|
|
|
|
Readonly::Scalar my $MESSAGE_SEPARATOR => $MESSAGE_SUFFIX . $MESSAGE_PREFIX; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub full_message { |
101
|
152
|
|
|
152
|
1
|
54735
|
my ( $self ) = @_; |
102
|
|
|
|
|
|
|
|
103
|
152
|
|
|
|
|
343
|
my $message = $MESSAGE_PREFIX; |
104
|
152
|
|
|
|
|
314
|
$message .= join $MESSAGE_SEPARATOR, @{ $self->exceptions() }; |
|
152
|
|
|
|
|
3908
|
|
105
|
152
|
|
|
|
|
175519
|
$message .= $MESSAGE_SUFFIX; |
106
|
|
|
|
|
|
|
|
107
|
152
|
|
|
|
|
417
|
return $message; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=pod |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=for stopwords |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 NAME |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Perl::Critic::Exception::AggregateConfiguration - A collection of a set of problems found in the configuration and/or command-line options. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 DESCRIPTION |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
A set of configuration settings can have multiple problems. This is |
127
|
|
|
|
|
|
|
an object for collecting all the problems found so that the user can |
128
|
|
|
|
|
|
|
see them in one run. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 INTERFACE SUPPORT |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This is considered to be a public class. Any changes to its interface |
134
|
|
|
|
|
|
|
will go through a deprecation cycle. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 METHODS |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item C<add_exception( $exception )> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Accumulate the parameter with rest of the exceptions. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item C<add_exceptions_from( $aggregate )> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Accumulate the exceptions from another instance of this class. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item C<exceptions()> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Returns a reference to an array of the collected exceptions. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item C<add_exception_or_rethrow( $eval_error )> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
If the parameter is an instance of |
159
|
|
|
|
|
|
|
L<Perl::Critic::Exception::Configuration|Perl::Critic::Exception::Configuration> |
160
|
|
|
|
|
|
|
or |
161
|
|
|
|
|
|
|
L<Perl::Critic::Exception::AggregateConfiguration|Perl::Critic::Exception::AggregateConfiguration>, |
162
|
|
|
|
|
|
|
add it. Otherwise, C<die> with the parameter, if it is a reference, |
163
|
|
|
|
|
|
|
or C<confess> with it. If the parameter is false, simply returns. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item C<has_exceptions()> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Answer whether any configuration problems have been found. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item C<full_message()> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Concatenate the exception messages. See |
174
|
|
|
|
|
|
|
L<Exception::Class/"full_message">. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=back |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 AUTHOR |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Elliot Shank <perl@galumph.com> |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 COPYRIGHT |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Copyright (c) 2007-2011 Elliot Shank. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
189
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
190
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
############################################################################## |
195
|
|
|
|
|
|
|
# Local Variables: |
196
|
|
|
|
|
|
|
# mode: cperl |
197
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
198
|
|
|
|
|
|
|
# fill-column: 78 |
199
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
200
|
|
|
|
|
|
|
# c-indentation-style: bsd |
201
|
|
|
|
|
|
|
# End: |
202
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |