Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Violation.pm |
Statements | Executed 569 statements in 3.62ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.47ms | 2.59ms | BEGIN@19 | Perl::Critic::Violation::
1 | 1 | 1 | 2.41ms | 4.75ms | BEGIN@26 | Perl::Critic::Violation::
1 | 1 | 1 | 1.17ms | 1.34ms | BEGIN@17 | Perl::Critic::Violation::
144 | 1 | 1 | 907µs | 1.07ms | sort_by_location | Perl::Critic::Violation::
1 | 1 | 1 | 436µs | 599µs | BEGIN@21 | Perl::Critic::Violation::
1 | 1 | 1 | 362µs | 871µs | BEGIN@30 | Perl::Critic::Violation::
144 | 1 | 1 | 160µs | 160µs | CORE:sort (opcode) | Perl::Critic::Violation::
3 | 1 | 1 | 155µs | 817µs | new | Perl::Critic::Violation::
3 | 1 | 1 | 77µs | 468µs | _line_containing_violation | Perl::Critic::Violation::
3 | 1 | 1 | 27µs | 29µs | _chomp_periods | Perl::Critic::Violation::
1 | 1 | 1 | 15µs | 15µs | BEGIN@10 | Perl::Critic::Violation::
1 | 1 | 1 | 9µs | 32µs | BEGIN@20 | Perl::Critic::Violation::
1 | 1 | 1 | 8µs | 369µs | BEGIN@14 | Perl::Critic::Violation::
1 | 1 | 1 | 8µs | 34µs | BEGIN@23 | Perl::Critic::Violation::
1 | 1 | 1 | 8µs | 27µs | BEGIN@15 | Perl::Critic::Violation::
1 | 1 | 1 | 7µs | 283µs | BEGIN@25 | Perl::Critic::Violation::
1 | 1 | 1 | 7µs | 19µs | BEGIN@11 | Perl::Critic::Violation::
1 | 1 | 1 | 7µs | 11µs | BEGIN@12 | Perl::Critic::Violation::
3 | 1 | 1 | 6µs | 6µs | location | Perl::Critic::Violation::
3 | 1 | 1 | 5µs | 5µs | CORE:qr (opcode) | Perl::Critic::Violation::
3 | 1 | 1 | 4µs | 4µs | CORE:regcomp (opcode) | Perl::Critic::Violation::
1 | 1 | 1 | 4µs | 4µs | BEGIN@18 | Perl::Critic::Violation::
3 | 1 | 1 | 2µs | 2µs | CORE:subst (opcode) | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | __ANON__[:265] | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | __ANON__[:266] | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | __ANON__[:267] | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | __ANON__[:268] | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | __ANON__[:269] | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | __ANON__[:270] | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | __ANON__[:271] | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | __ANON__[:272] | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | __ANON__[:276] | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | __ANON__[:277] | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | _compare | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | column_number | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | description | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | diagnostics | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | element_class | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | explanation | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | filename | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | get_format | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | line_number | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | logical_filename | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | logical_line_number | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | policy | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | set_format | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | severity | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | sort_by_severity | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | source | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | to_string | Perl::Critic::Violation::
0 | 0 | 0 | 0s | 0s | visual_column_number | Perl::Critic::Violation::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ############################################################################## | ||||
2 | # $URL$ | ||||
3 | # $Date$ | ||||
4 | # $Author$ | ||||
5 | # $Revision$ | ||||
6 | ############################################################################## | ||||
7 | |||||
8 | package Perl::Critic::Violation; | ||||
9 | |||||
10 | 2 | 38µs | 1 | 15µs | # spent 15µs within Perl::Critic::Violation::BEGIN@10 which was called:
# once (15µs+0s) by Perl::Critic::Command::BEGIN@27 at line 10 # spent 15µs making 1 call to Perl::Critic::Violation::BEGIN@10 |
11 | 2 | 19µs | 2 | 31µs | # spent 19µs (7+12) within Perl::Critic::Violation::BEGIN@11 which was called:
# once (7µs+12µs) by Perl::Critic::Command::BEGIN@27 at line 11 # spent 19µs making 1 call to Perl::Critic::Violation::BEGIN@11
# spent 12µs making 1 call to strict::import |
12 | 2 | 25µs | 2 | 15µs | # spent 11µs (7+4) within Perl::Critic::Violation::BEGIN@12 which was called:
# once (7µs+4µs) by Perl::Critic::Command::BEGIN@27 at line 12 # spent 11µs making 1 call to Perl::Critic::Violation::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | |||||
14 | 2 | 24µs | 2 | 729µs | # spent 369µs (8+360) within Perl::Critic::Violation::BEGIN@14 which was called:
# once (8µs+360µs) by Perl::Critic::Command::BEGIN@27 at line 14 # spent 369µs making 1 call to Perl::Critic::Violation::BEGIN@14
# spent 360µs making 1 call to English::import |
15 | 2 | 23µs | 2 | 46µs | # spent 27µs (8+19) within Perl::Critic::Violation::BEGIN@15 which was called:
# once (8µs+19µs) by Perl::Critic::Command::BEGIN@27 at line 15 # spent 27µs making 1 call to Perl::Critic::Violation::BEGIN@15
# spent 19µs making 1 call to Exporter::import |
16 | |||||
17 | 2 | 125µs | 2 | 1.37ms | # spent 1.34ms (1.17+163µs) within Perl::Critic::Violation::BEGIN@17 which was called:
# once (1.17ms+163µs) by Perl::Critic::Command::BEGIN@27 at line 17 # spent 1.34ms making 1 call to Perl::Critic::Violation::BEGIN@17
# spent 31µs making 1 call to Exporter::import |
18 | 2 | 19µs | 1 | 4µs | # spent 4µs within Perl::Critic::Violation::BEGIN@18 which was called:
# once (4µs+0s) by Perl::Critic::Command::BEGIN@27 at line 18 # spent 4µs making 1 call to Perl::Critic::Violation::BEGIN@18 |
19 | 2 | 100µs | 1 | 2.59ms | # spent 2.59ms (2.47+112µs) within Perl::Critic::Violation::BEGIN@19 which was called:
# once (2.47ms+112µs) by Perl::Critic::Command::BEGIN@27 at line 19 # spent 2.59ms making 1 call to Perl::Critic::Violation::BEGIN@19 |
20 | 2 | 24µs | 2 | 56µs | # spent 32µs (9+24) within Perl::Critic::Violation::BEGIN@20 which was called:
# once (9µs+24µs) by Perl::Critic::Command::BEGIN@27 at line 20 # spent 32µs making 1 call to Perl::Critic::Violation::BEGIN@20
# spent 24µs making 1 call to Exporter::import |
21 | 2 | 94µs | 2 | 626µs | # spent 599µs (436+163) within Perl::Critic::Violation::BEGIN@21 which was called:
# once (436µs+163µs) by Perl::Critic::Command::BEGIN@27 at line 21 # spent 599µs making 1 call to Perl::Critic::Violation::BEGIN@21
# spent 26µs making 1 call to Exporter::import |
22 | |||||
23 | 2 | 24µs | 2 | 59µs | # spent 34µs (8+26) within Perl::Critic::Violation::BEGIN@23 which was called:
# once (8µs+26µs) by Perl::Critic::Command::BEGIN@27 at line 23 # spent 34µs making 1 call to Perl::Critic::Violation::BEGIN@23
# spent 26µs making 1 call to overload::import |
24 | |||||
25 | 2 | 25µs | 2 | 559µs | # spent 283µs (7+276) within Perl::Critic::Violation::BEGIN@25 which was called:
# once (7µs+276µs) by Perl::Critic::Command::BEGIN@27 at line 25 # spent 283µs making 1 call to Perl::Critic::Violation::BEGIN@25
# spent 276µs making 1 call to Exporter::import |
26 | 1 | 68µs | # spent 4.75ms (2.41+2.34) within Perl::Critic::Violation::BEGIN@26 which was called:
# once (2.41ms+2.34ms) by Perl::Critic::Command::BEGIN@27 at line 29 | ||
27 | get_pod_section_for_module | ||||
28 | trim_pod_section | ||||
29 | 1 | 47µs | 2 | 4.87ms | >; # spent 4.75ms making 1 call to Perl::Critic::Violation::BEGIN@26
# spent 112µs making 1 call to Exporter::import |
30 | 2 | 1.66ms | 2 | 930µs | # spent 871µs (362+509) within Perl::Critic::Violation::BEGIN@30 which was called:
# once (362µs+509µs) by Perl::Critic::Command::BEGIN@27 at line 30 # spent 871µs making 1 call to Perl::Critic::Violation::BEGIN@30
# spent 59µs making 1 call to Exporter::import |
31 | |||||
32 | 1 | 800ns | our $VERSION = '1.121'; | ||
33 | |||||
34 | |||||
35 | 1 | 3µs | 1 | 45µs | Readonly::Scalar my $LOCATION_LINE_NUMBER => 0; # spent 45µs making 1 call to Readonly::Scalar |
36 | 1 | 1µs | 1 | 30µs | Readonly::Scalar my $LOCATION_COLUMN_NUMBER => 1; # spent 30µs making 1 call to Readonly::Scalar |
37 | 1 | 1µs | 1 | 28µs | Readonly::Scalar my $LOCATION_VISUAL_COLUMN_NUMBER => 2; # spent 28µs making 1 call to Readonly::Scalar |
38 | 1 | 1µs | 1 | 27µs | Readonly::Scalar my $LOCATION_LOGICAL_LINE_NUMBER => 3; # spent 27µs making 1 call to Readonly::Scalar |
39 | 1 | 1µs | 1 | 27µs | Readonly::Scalar my $LOCATION_LOGICAL_FILENAME => 4; # spent 27µs making 1 call to Readonly::Scalar |
40 | |||||
41 | |||||
42 | # Class variables... | ||||
43 | 1 | 500ns | my $format = "%m at line %l, column %c. %e.\n"; # Default stringy format | ||
44 | 1 | 600ns | my %diagnostics = (); # Cache of diagnostic messages | ||
45 | |||||
46 | #----------------------------------------------------------------------------- | ||||
47 | |||||
48 | 1 | 1µs | 1 | 27µs | Readonly::Scalar my $CONSTRUCTOR_ARG_COUNT => 5; # spent 27µs making 1 call to Readonly::Scalar |
49 | |||||
50 | # spent 817µs (155+663) within Perl::Critic::Violation::new which was called 3 times, avg 272µs/call:
# 3 times (155µs+663µs) by Perl::Critic::Policy::Subroutines::ProhibitExplicitReturnUndef::violates at line 421 of Perl/Critic/Policy.pm, avg 272µs/call | ||||
51 | 3 | 2µs | my ( $class, $desc, $expl, $elem, $sev ) = @_; | ||
52 | |||||
53 | # Check arguments to help out developers who might | ||||
54 | # be creating new Perl::Critic::Policy modules. | ||||
55 | |||||
56 | 3 | 7µs | 3 | 3µs | if ( @_ != $CONSTRUCTOR_ARG_COUNT ) { # spent 3µs making 3 calls to Readonly::Scalar::FETCH, avg 1µs/call |
57 | throw_internal 'Wrong number of args to Violation->new()'; | ||||
58 | } | ||||
59 | |||||
60 | 6 | 16µs | 3 | 6µs | if ( eval { $elem->isa( 'Perl::Critic::Document' ) } ) { # spent 6µs making 3 calls to UNIVERSAL::isa, avg 2µs/call |
61 | # break the facade, return the real PPI::Document | ||||
62 | $elem = $elem->ppi_document(); | ||||
63 | } | ||||
64 | |||||
65 | 6 | 11µs | 3 | 2µs | if ( not eval { $elem->isa( 'PPI::Element' ) } ) { # spent 2µs making 3 calls to UNIVERSAL::isa, avg 600ns/call |
66 | throw_internal '3rd arg to Violation->new() must be a PPI::Element'; | ||||
67 | } | ||||
68 | |||||
69 | # Strip punctuation. These are controlled by the user via the | ||||
70 | # formats. He/She can use whatever makes sense to them. | ||||
71 | 3 | 7µs | 3 | 29µs | ($desc, $expl) = _chomp_periods($desc, $expl); # spent 29µs making 3 calls to Perl::Critic::Violation::_chomp_periods, avg 10µs/call |
72 | |||||
73 | # Create object | ||||
74 | 3 | 4µs | my $self = bless {}, $class; | ||
75 | 3 | 28µs | $self->{_description} = $desc; | ||
76 | 3 | 2µs | $self->{_explanation} = $expl; | ||
77 | 3 | 1µs | $self->{_severity} = $sev; | ||
78 | 3 | 3µs | $self->{_policy} = caller; | ||
79 | |||||
80 | # PPI eviscerates the Elements in a Document when the Document gets | ||||
81 | # DESTROY()ed, and thus they aren't useful after it is gone. So we have | ||||
82 | # to preemptively grab everything we could possibly want. | ||||
83 | 3 | 15µs | 3 | 4µs | $self->{_element_class} = blessed $elem; # spent 4µs making 3 calls to Scalar::Util::blessed, avg 2µs/call |
84 | |||||
85 | 3 | 8µs | 3 | 127µs | my $top = $elem->top(); # spent 127µs making 3 calls to PPI::Element::top, avg 42µs/call |
86 | 3 | 19µs | 6 | 9µs | $self->{_filename} = $top->can('filename') ? $top->filename() : undef; # spent 6µs making 3 calls to PPI::Document::File::filename, avg 2µs/call
# spent 3µs making 3 calls to UNIVERSAL::can, avg 933ns/call |
87 | 3 | 6µs | 3 | 468µs | $self->{_source} = _line_containing_violation( $elem ); # spent 468µs making 3 calls to Perl::Critic::Violation::_line_containing_violation, avg 156µs/call |
88 | 3 | 7µs | 3 | 15µs | $self->{_location} = # spent 15µs making 3 calls to PPI::Element::location, avg 5µs/call |
89 | $elem->location() || [ 0, 0, 0, 0, $self->filename() ]; | ||||
90 | |||||
91 | 3 | 12µs | return $self; | ||
92 | } | ||||
93 | |||||
94 | #----------------------------------------------------------------------------- | ||||
95 | |||||
96 | sub set_format { return $format = verbosity_to_format( $_[0] ); } ## no critic(ArgUnpacking) | ||||
97 | sub get_format { return $format; } | ||||
98 | |||||
99 | #----------------------------------------------------------------------------- | ||||
100 | |||||
101 | # spent 1.07ms (907µs+160µs) within Perl::Critic::Violation::sort_by_location which was called 144 times, avg 7µs/call:
# 144 times (907µs+160µs) by Perl::Critic::_gather_violations at line 148 of Perl/Critic.pm, avg 7µs/call | ||||
102 | |||||
103 | 144 | 86µs | ref $_[0] || shift; # Can call as object or class method | ||
104 | 144 | 52µs | return scalar @_ if ! wantarray; # In case we are called in scalar context | ||
105 | |||||
106 | ## TODO: What if $a and $b are not Violation objects? | ||||
107 | return | ||||
108 | map {$_->[0]} | ||||
109 | sort { ($a->[1] <=> $b->[1]) || ($a->[2] <=> $b->[2]) } | ||||
110 | 144 | 887µs | 144 | 160µs | map {[$_, $_->location->[0] || 0, $_->location->[1] || 0]} # spent 160µs making 144 calls to Perl::Critic::Violation::CORE:sort, avg 1µs/call |
111 | @_; | ||||
112 | } | ||||
113 | |||||
114 | #----------------------------------------------------------------------------- | ||||
115 | |||||
116 | sub sort_by_severity { ## no critic(ArgUnpacking) | ||||
117 | |||||
118 | ref $_[0] || shift; # Can call as object or class method | ||||
119 | return scalar @_ if ! wantarray; # In case we are called in scalar context | ||||
120 | |||||
121 | ## TODO: What if $a and $b are not Violation objects? | ||||
122 | return | ||||
123 | map {$_->[0]} | ||||
124 | sort { $a->[1] <=> $b->[1] } | ||||
125 | map {[$_, $_->severity() || 0]} | ||||
126 | @_; | ||||
127 | } | ||||
128 | |||||
129 | #----------------------------------------------------------------------------- | ||||
130 | |||||
131 | # spent 6µs within Perl::Critic::Violation::location which was called 3 times, avg 2µs/call:
# 3 times (6µs+0s) by Perl::Critic::_critique at line 185 of Perl/Critic.pm, avg 2µs/call | ||||
132 | 3 | 1µs | my $self = shift; | ||
133 | |||||
134 | 3 | 8µs | return $self->{_location}; | ||
135 | } | ||||
136 | |||||
137 | #----------------------------------------------------------------------------- | ||||
138 | |||||
139 | sub line_number { | ||||
140 | my ($self) = @_; | ||||
141 | |||||
142 | return $self->location()->[$LOCATION_LINE_NUMBER]; | ||||
143 | } | ||||
144 | |||||
145 | #----------------------------------------------------------------------------- | ||||
146 | |||||
147 | sub logical_line_number { | ||||
148 | my ($self) = @_; | ||||
149 | |||||
150 | return $self->location()->[$LOCATION_LOGICAL_LINE_NUMBER]; | ||||
151 | } | ||||
152 | |||||
153 | #----------------------------------------------------------------------------- | ||||
154 | |||||
155 | sub column_number { | ||||
156 | my ($self) = @_; | ||||
157 | |||||
158 | return $self->location()->[$LOCATION_COLUMN_NUMBER]; | ||||
159 | } | ||||
160 | |||||
161 | #----------------------------------------------------------------------------- | ||||
162 | |||||
163 | sub visual_column_number { | ||||
164 | my ($self) = @_; | ||||
165 | |||||
166 | return $self->location()->[$LOCATION_VISUAL_COLUMN_NUMBER]; | ||||
167 | } | ||||
168 | |||||
169 | #----------------------------------------------------------------------------- | ||||
170 | |||||
171 | sub diagnostics { | ||||
172 | my ($self) = @_; | ||||
173 | my $policy = $self->policy(); | ||||
174 | |||||
175 | if ( not $diagnostics{$policy} ) { | ||||
176 | eval { ## no critic (RequireCheckingReturnValueOfEval) | ||||
177 | my $module_name = ref $policy || $policy; | ||||
178 | $diagnostics{$policy} = | ||||
179 | trim_pod_section( | ||||
180 | get_pod_section_for_module( $module_name, 'DESCRIPTION' ) | ||||
181 | ); | ||||
182 | }; | ||||
183 | $diagnostics{$policy} ||= " No diagnostics available\n"; | ||||
184 | } | ||||
185 | return $diagnostics{$policy}; | ||||
186 | } | ||||
187 | |||||
188 | #----------------------------------------------------------------------------- | ||||
189 | |||||
190 | sub description { | ||||
191 | my $self = shift; | ||||
192 | return $self->{_description}; | ||||
193 | } | ||||
194 | |||||
195 | #----------------------------------------------------------------------------- | ||||
196 | |||||
197 | sub explanation { | ||||
198 | my $self = shift; | ||||
199 | my $expl = $self->{_explanation}; | ||||
200 | if ( !$expl ) { | ||||
201 | $expl = '(no explanation)'; | ||||
202 | } | ||||
203 | if ( ref $expl eq 'ARRAY' ) { | ||||
204 | my $page = @{$expl} > 1 ? 'pages' : 'page'; | ||||
205 | $page .= $SPACE . join $COMMA, @{$expl}; | ||||
206 | $expl = "See $page of PBP"; | ||||
207 | } | ||||
208 | return $expl; | ||||
209 | } | ||||
210 | |||||
211 | #----------------------------------------------------------------------------- | ||||
212 | |||||
213 | sub severity { | ||||
214 | my $self = shift; | ||||
215 | return $self->{_severity}; | ||||
216 | } | ||||
217 | |||||
218 | #----------------------------------------------------------------------------- | ||||
219 | |||||
220 | sub policy { | ||||
221 | my $self = shift; | ||||
222 | return $self->{_policy}; | ||||
223 | } | ||||
224 | |||||
225 | #----------------------------------------------------------------------------- | ||||
226 | |||||
227 | sub filename { | ||||
228 | my $self = shift; | ||||
229 | return $self->{_filename}; | ||||
230 | } | ||||
231 | |||||
232 | #----------------------------------------------------------------------------- | ||||
233 | |||||
234 | sub logical_filename { | ||||
235 | my ($self) = @_; | ||||
236 | |||||
237 | return $self->location()->[$LOCATION_LOGICAL_FILENAME]; | ||||
238 | } | ||||
239 | |||||
240 | #----------------------------------------------------------------------------- | ||||
241 | |||||
242 | sub source { | ||||
243 | my $self = shift; | ||||
244 | return $self->{_source}; | ||||
245 | } | ||||
246 | |||||
247 | #----------------------------------------------------------------------------- | ||||
248 | |||||
249 | sub element_class { | ||||
250 | my ($self) = @_; | ||||
251 | |||||
252 | return $self->{_element_class}; | ||||
253 | } | ||||
254 | |||||
255 | #----------------------------------------------------------------------------- | ||||
256 | |||||
257 | sub to_string { | ||||
258 | my $self = shift; | ||||
259 | |||||
260 | my $long_policy = $self->policy(); | ||||
261 | (my $short_policy = $long_policy) =~ s/ \A Perl::Critic::Policy:: //xms; | ||||
262 | |||||
263 | # Wrap the more expensive ones in sub{} to postpone evaluation | ||||
264 | my %fspec = ( | ||||
265 | 'f' => sub { $self->logical_filename() }, | ||||
266 | 'F' => sub { basename( $self->logical_filename() ) }, | ||||
267 | 'g' => sub { $self->filename() }, | ||||
268 | 'G' => sub { basename( $self->filename() ) }, | ||||
269 | 'l' => sub { $self->logical_line_number() }, | ||||
270 | 'L' => sub { $self->line_number() }, | ||||
271 | 'c' => sub { $self->visual_column_number() }, | ||||
272 | 'C' => sub { $self->element_class() }, | ||||
273 | 'm' => $self->description(), | ||||
274 | 'e' => $self->explanation(), | ||||
275 | 's' => $self->severity(), | ||||
276 | 'd' => sub { $self->diagnostics() }, | ||||
277 | 'r' => sub { $self->source() }, | ||||
278 | 'P' => $long_policy, | ||||
279 | 'p' => $short_policy, | ||||
280 | ); | ||||
281 | return stringf($format, %fspec); | ||||
282 | } | ||||
283 | |||||
284 | #----------------------------------------------------------------------------- | ||||
285 | # Apparently, some perls do not implicitly stringify overloading | ||||
286 | # objects before doing a comparison. This causes a couple of our | ||||
287 | # sorting tests to fail. To work around this, we overload C<cmp> to | ||||
288 | # do it explicitly. | ||||
289 | # | ||||
290 | # 20060503 - More information: This problem has been traced to | ||||
291 | # Test::Simple versions <= 0.60, not perl itself. Upgrading to | ||||
292 | # Test::Simple v0.62 will fix the problem. But rather than forcing | ||||
293 | # everyone to upgrade, I have decided to leave this workaround in | ||||
294 | # place. | ||||
295 | |||||
296 | sub _compare { return "$_[0]" cmp "$_[1]" } | ||||
297 | |||||
298 | #----------------------------------------------------------------------------- | ||||
299 | |||||
300 | # spent 468µs (77+391) within Perl::Critic::Violation::_line_containing_violation which was called 3 times, avg 156µs/call:
# 3 times (77µs+391µs) by Perl::Critic::Violation::new at line 87, avg 156µs/call | ||||
301 | 3 | 800ns | my ( $elem ) = @_; | ||
302 | |||||
303 | 3 | 12µs | 6 | 65µs | my $stmnt = $elem->statement() || $elem; # spent 64µs making 3 calls to PPI::Element::statement, avg 21µs/call
# spent 2µs making 3 calls to PPI::Util::TRUE, avg 500ns/call |
304 | 3 | 9µs | 3 | 234µs | my $code_string = $stmnt->content() || $EMPTY; # spent 234µs making 3 calls to PPI::Node::content, avg 78µs/call |
305 | |||||
306 | # Split into individual lines | ||||
307 | 3 | 32µs | 6 | 10µs | my @lines = split qr{ \n\s* }xms, $code_string; # spent 5µs making 3 calls to Perl::Critic::Violation::CORE:qr, avg 2µs/call
# spent 4µs making 3 calls to Perl::Critic::Violation::CORE:regcomp, avg 1µs/call |
308 | |||||
309 | # Take the line containing the element that is in violation | ||||
310 | 3 | 14µs | 6 | 83µs | my $inx = ( $elem->line_number() || 0 ) - # spent 83µs making 6 calls to PPI::Element::line_number, avg 14µs/call |
311 | ( $stmnt->line_number() || 0 ); | ||||
312 | 3 | 800ns | $inx > @lines and return $EMPTY; | ||
313 | 3 | 9µs | return $lines[$inx]; | ||
314 | } | ||||
315 | |||||
316 | #----------------------------------------------------------------------------- | ||||
317 | |||||
318 | # spent 29µs (27+2) within Perl::Critic::Violation::_chomp_periods which was called 3 times, avg 10µs/call:
# 3 times (27µs+2µs) by Perl::Critic::Violation::new at line 71, avg 10µs/call | ||||
319 | 3 | 2µs | my @args = @_; | ||
320 | |||||
321 | 3 | 4µs | for (@args) { | ||
322 | 6 | 3µs | next if not defined or ref; | ||
323 | 3 | 12µs | 3 | 2µs | s{ [.]+ \z }{}xms # spent 2µs making 3 calls to Perl::Critic::Violation::CORE:subst, avg 800ns/call |
324 | } | ||||
325 | |||||
326 | 3 | 9µs | return @args; | ||
327 | } | ||||
328 | |||||
329 | #----------------------------------------------------------------------------- | ||||
330 | |||||
331 | 1 | 6µs | 1; | ||
332 | |||||
333 | #----------------------------------------------------------------------------- | ||||
334 | |||||
335 | __END__ | ||||
# spent 5µs within Perl::Critic::Violation::CORE:qr which was called 3 times, avg 2µs/call:
# 3 times (5µs+0s) by Perl::Critic::Violation::_line_containing_violation at line 307, avg 2µs/call | |||||
# spent 4µs within Perl::Critic::Violation::CORE:regcomp which was called 3 times, avg 1µs/call:
# 3 times (4µs+0s) by Perl::Critic::Violation::_line_containing_violation at line 307, avg 1µs/call | |||||
# spent 160µs within Perl::Critic::Violation::CORE:sort which was called 144 times, avg 1µs/call:
# 144 times (160µs+0s) by Perl::Critic::Violation::sort_by_location at line 110, avg 1µs/call | |||||
# spent 2µs within Perl::Critic::Violation::CORE:subst which was called 3 times, avg 800ns/call:
# 3 times (2µs+0s) by Perl::Critic::Violation::_chomp_periods at line 323, avg 800ns/call |