Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Utils.pm |
Statements | Executed 216279 statements in 535ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
14319 | 4 | 4 | 307ms | 1.47s | is_hash_key | Perl::Critic::Utils::
14319 | 1 | 1 | 154ms | 657ms | _is_followed_by_parens | Perl::Critic::Utils::
1573 | 2 | 1 | 9.21ms | 11.3ms | CORE:regcomp (opcode) | Perl::Critic::Utils::
1291 | 6 | 3 | 6.60ms | 18.1ms | policy_short_name | Perl::Critic::Utils::
77 | 1 | 1 | 5.44ms | 8.42ms | is_class_name | Perl::Critic::Utils::
222 | 67 | 35 | 4.41ms | 4.74ms | hashify | Perl::Critic::Utils::
144 | 1 | 1 | 3.85ms | 3.99ms | _is_backup | Perl::Critic::Utils::
1 | 1 | 1 | 2.79ms | 10.9ms | all_perl_files | Perl::Critic::Utils::
79 | 6 | 4 | 2.32ms | 48.3ms | is_function_call | Perl::Critic::Utils::
144 | 1 | 1 | 1.85ms | 4.02ms | shebang_line | Perl::Critic::Utils::
1300 | 2 | 1 | 1.68ms | 1.68ms | CORE:subst (opcode) | Perl::Critic::Utils::
18 | 4 | 4 | 1.45ms | 8.72ms | parse_arg_list | Perl::Critic::Utils::
282 | 2 | 2 | 1.36ms | 3.17ms | policy_long_name | Perl::Critic::Utils::
154 | 2 | 1 | 1.23ms | 1.77ms | _name_for_sub_or_stringified_element | Perl::Critic::Utils::
77 | 1 | 1 | 1.17ms | 5.20ms | is_label_pointer | Perl::Critic::Utils::
77 | 1 | 1 | 1.07ms | 4.84ms | is_subroutine_name | Perl::Critic::Utils::
154 | 2 | 1 | 908µs | 1.72ms | _is_dereference_operator | Perl::Critic::Utils::
77 | 1 | 1 | 905µs | 2.18ms | is_perl_bareword | Perl::Critic::Utils::
1 | 1 | 1 | 842µs | 1.14ms | BEGIN@22 | Perl::Critic::Utils::
77 | 1 | 1 | 832µs | 5.13ms | is_included_module_name | Perl::Critic::Utils::
1 | 1 | 1 | 807µs | 1.01ms | BEGIN@26 | Perl::Critic::Utils::
77 | 1 | 1 | 778µs | 2.34ms | is_package_declaration | Perl::Critic::Utils::
77 | 1 | 1 | 760µs | 1.65ms | is_perl_filehandle | Perl::Critic::Utils::
18 | 1 | 1 | 692µs | 1.80ms | split_nodes_on_comma | Perl::Critic::Utils::
77 | 1 | 1 | 679µs | 6.15ms | is_method_call | Perl::Critic::Utils::
1161 | 9 | 1 | 635µs | 652µs | CORE:match (opcode) | Perl::Critic::Utils::
66 | 3 | 2 | 613µs | 2.86ms | first_arg | Perl::Critic::Utils::
144 | 1 | 1 | 549µs | 709µs | _is_perl | Perl::Critic::Utils::
162 | 1 | 1 | 529µs | 529µs | CORE:ftdir (opcode) | Perl::Critic::Utils::
55 | 6 | 4 | 482µs | 669µs | precedence_of | Perl::Critic::Utils::
1 | 1 | 1 | 346µs | 48.0ms | BEGIN@23 | Perl::Critic::Utils::
162 | 1 | 1 | 338µs | 338µs | CORE:ftfile (opcode) | Perl::Critic::Utils::
1 | 1 | 1 | 334µs | 6.76ms | BEGIN@25 | Perl::Critic::Utils::
1 | 1 | 1 | 326µs | 411µs | BEGIN@21 | Perl::Critic::Utils::
18 | 1 | 1 | 311µs | 311µs | CORE:readdir (opcode) | Perl::Critic::Utils::
18 | 1 | 1 | 160µs | 160µs | CORE:open_dir (opcode) | Perl::Critic::Utils::
1 | 1 | 1 | 102µs | 106µs | _build_globals_without_sigils | Perl::Critic::Utils::
40 | 6 | 4 | 90µs | 90µs | words_from_string | Perl::Critic::Utils::
19 | 2 | 1 | 78µs | 96µs | CORE:sort (opcode) | Perl::Critic::Utils::
18 | 1 | 1 | 56µs | 56µs | CORE:closedir (opcode) | Perl::Critic::Utils::
1 | 1 | 1 | 14µs | 14µs | BEGIN@13 | Perl::Critic::Utils::
3 | 3 | 1 | 13µs | 18µs | is_integer | Perl::Critic::Utils::
1 | 1 | 1 | 10µs | 15µs | BEGIN@15 | Perl::Critic::Utils::
1 | 1 | 1 | 8µs | 11µs | is_valid_numeric_verbosity | Perl::Critic::Utils::
1 | 1 | 1 | 7µs | 12µs | BEGIN@28 | Perl::Critic::Utils::
1 | 1 | 1 | 7µs | 25µs | BEGIN@16 | Perl::Critic::Utils::
1 | 1 | 1 | 6µs | 24µs | BEGIN@18 | Perl::Critic::Utils::
1 | 1 | 1 | 6µs | 356µs | BEGIN@19 | Perl::Critic::Utils::
1 | 1 | 1 | 6µs | 17µs | BEGIN@14 | Perl::Critic::Utils::
1 | 1 | 1 | 3µs | 3µs | BEGIN@20 | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | __ANON__[:1201] | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | _is_PL_file | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | _is_covered_by_autodie | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | _is_fatal | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | _normalize_severity | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | find_keywords | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | interpolate | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_in_void_context | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_perl_builtin | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_perl_builtin_with_list_context | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_perl_builtin_with_multiple_arguments | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_perl_builtin_with_no_arguments | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_perl_builtin_with_one_argument | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_perl_builtin_with_optional_argument | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_perl_builtin_with_zero_and_or_one_arguments | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_perl_global | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_qualified_name | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_script | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | is_unchecked_call | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | severity_to_number | Perl::Critic::Utils::
0 | 0 | 0 | 0s | 0s | verbosity_to_format | Perl::Critic::Utils::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ############################################################################## | ||||
2 | # $URL$ | ||||
3 | # $Date$ | ||||
4 | # $Author$ | ||||
5 | # $Revision$ | ||||
6 | ############################################################################## | ||||
7 | |||||
8 | # NOTE: This module is way too large. Please think about adding new | ||||
9 | # functionality into a P::C::Utils::* module instead. | ||||
10 | |||||
11 | package Perl::Critic::Utils; | ||||
12 | |||||
13 | 2 | 36µs | 1 | 14µs | # spent 14µs within Perl::Critic::Utils::BEGIN@13 which was called:
# once (14µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 13 # spent 14µs making 1 call to Perl::Critic::Utils::BEGIN@13 |
14 | 2 | 35µs | 2 | 28µs | # spent 17µs (6+11) within Perl::Critic::Utils::BEGIN@14 which was called:
# once (6µs+11µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 14 # spent 17µs making 1 call to Perl::Critic::Utils::BEGIN@14
# spent 11µs making 1 call to strict::import |
15 | 2 | 18µs | 2 | 20µs | # spent 15µs (10+5) within Perl::Critic::Utils::BEGIN@15 which was called:
# once (10µs+5µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 15 # spent 15µs making 1 call to Perl::Critic::Utils::BEGIN@15
# spent 5µs making 1 call to warnings::import |
16 | 2 | 20µs | 2 | 44µs | # spent 25µs (7+19) within Perl::Critic::Utils::BEGIN@16 which was called:
# once (7µs+19µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 16 # spent 25µs making 1 call to Perl::Critic::Utils::BEGIN@16
# spent 19µs making 1 call to Exporter::import |
17 | |||||
18 | 2 | 19µs | 2 | 43µs | # spent 24µs (6+18) within Perl::Critic::Utils::BEGIN@18 which was called:
# once (6µs+18µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 18 # spent 24µs making 1 call to Perl::Critic::Utils::BEGIN@18
# spent 18µs making 1 call to Exporter::import |
19 | 2 | 21µs | 2 | 705µs | # spent 356µs (6+350) within Perl::Critic::Utils::BEGIN@19 which was called:
# once (6µs+350µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 19 # spent 356µs making 1 call to Perl::Critic::Utils::BEGIN@19
# spent 350µs making 1 call to English::import |
20 | 2 | 17µs | 1 | 3µs | # spent 3µs within Perl::Critic::Utils::BEGIN@20 which was called:
# once (3µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 20 # spent 3µs making 1 call to Perl::Critic::Utils::BEGIN@20 |
21 | 2 | 85µs | 2 | 462µs | # spent 411µs (326+85) within Perl::Critic::Utils::BEGIN@21 which was called:
# once (326µs+85µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 21 # spent 411µs making 1 call to Perl::Critic::Utils::BEGIN@21
# spent 50µs making 1 call to Exporter::import |
22 | 2 | 85µs | 1 | 1.14ms | # spent 1.14ms (842µs+297µs) within Perl::Critic::Utils::BEGIN@22 which was called:
# once (842µs+297µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 22 # spent 1.14ms making 1 call to Perl::Critic::Utils::BEGIN@22 |
23 | 2 | 108µs | 1 | 48.0ms | # spent 48.0ms (346µs+47.6) within Perl::Critic::Utils::BEGIN@23 which was called:
# once (346µs+47.6ms) by Perl::Critic::Exception::Parse::BEGIN@18 at line 23 # spent 48.0ms making 1 call to Perl::Critic::Utils::BEGIN@23 |
24 | |||||
25 | 2 | 183µs | 2 | 6.81ms | # spent 6.76ms (334µs+6.43) within Perl::Critic::Utils::BEGIN@25 which was called:
# once (334µs+6.43ms) by Perl::Critic::Exception::Parse::BEGIN@18 at line 25 # spent 6.76ms making 1 call to Perl::Critic::Utils::BEGIN@25
# spent 49µs making 1 call to Exporter::import |
26 | 2 | 83µs | 2 | 1.06ms | # spent 1.01ms (807µs+206µs) within Perl::Critic::Utils::BEGIN@26 which was called:
# once (807µs+206µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 26 # spent 1.01ms making 1 call to Perl::Critic::Utils::BEGIN@26
# spent 42µs making 1 call to Exporter::import |
27 | |||||
28 | 2 | 3.72ms | 2 | 17µs | # spent 12µs (7+5) within Perl::Critic::Utils::BEGIN@28 which was called:
# once (7µs+5µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 28 # spent 12µs making 1 call to Perl::Critic::Utils::BEGIN@28
# spent 5µs making 1 call to Exporter::import |
29 | |||||
30 | 1 | 700ns | our $VERSION = '1.121'; | ||
31 | |||||
32 | #----------------------------------------------------------------------------- | ||||
33 | # Exportable symbols here. | ||||
34 | |||||
35 | 1 | 4µs | 1 | 75µs | Readonly::Array our @EXPORT_OK => qw( # spent 75µs making 1 call to Readonly::Array |
36 | $TRUE | ||||
37 | $FALSE | ||||
38 | |||||
39 | $POLICY_NAMESPACE | ||||
40 | |||||
41 | $SEVERITY_HIGHEST | ||||
42 | $SEVERITY_HIGH | ||||
43 | $SEVERITY_MEDIUM | ||||
44 | $SEVERITY_LOW | ||||
45 | $SEVERITY_LOWEST | ||||
46 | @SEVERITY_NAMES | ||||
47 | |||||
48 | $DEFAULT_VERBOSITY | ||||
49 | $DEFAULT_VERBOSITY_WITH_FILE_NAME | ||||
50 | |||||
51 | $COLON | ||||
52 | $COMMA | ||||
53 | $DQUOTE | ||||
54 | $EMPTY | ||||
55 | $EQUAL | ||||
56 | $FATCOMMA | ||||
57 | $PERIOD | ||||
58 | $PIPE | ||||
59 | $QUOTE | ||||
60 | $BACKTICK | ||||
61 | $SCOLON | ||||
62 | $SPACE | ||||
63 | $SLASH | ||||
64 | $BSLASH | ||||
65 | $LEFT_PAREN | ||||
66 | $RIGHT_PAREN | ||||
67 | |||||
68 | all_perl_files | ||||
69 | find_keywords | ||||
70 | first_arg | ||||
71 | hashify | ||||
72 | interpolate | ||||
73 | is_class_name | ||||
74 | is_function_call | ||||
75 | is_hash_key | ||||
76 | is_in_void_context | ||||
77 | is_included_module_name | ||||
78 | is_integer | ||||
79 | is_label_pointer | ||||
80 | is_method_call | ||||
81 | is_package_declaration | ||||
82 | is_perl_bareword | ||||
83 | is_perl_builtin | ||||
84 | is_perl_builtin_with_list_context | ||||
85 | is_perl_builtin_with_multiple_arguments | ||||
86 | is_perl_builtin_with_no_arguments | ||||
87 | is_perl_builtin_with_one_argument | ||||
88 | is_perl_builtin_with_optional_argument | ||||
89 | is_perl_builtin_with_zero_and_or_one_arguments | ||||
90 | is_perl_filehandle | ||||
91 | is_perl_global | ||||
92 | is_qualified_name | ||||
93 | is_script | ||||
94 | is_subroutine_name | ||||
95 | is_unchecked_call | ||||
96 | is_valid_numeric_verbosity | ||||
97 | parse_arg_list | ||||
98 | policy_long_name | ||||
99 | policy_short_name | ||||
100 | precedence_of | ||||
101 | severity_to_number | ||||
102 | shebang_line | ||||
103 | split_nodes_on_comma | ||||
104 | verbosity_to_format | ||||
105 | words_from_string | ||||
106 | ); | ||||
107 | |||||
108 | |||||
109 | # Note: this is deprecated. This should also violate ProhibitAutomaticExportation, | ||||
110 | # but at the moment, we aren't smart enough to deal with Readonly variables. | ||||
111 | 1 | 118µs | 67 | 157µs | Readonly::Array our @EXPORT => @EXPORT_OK; # spent 88µs making 65 calls to Readonly::Array::FETCH, avg 1µs/call
# spent 67µs making 1 call to Readonly::Array
# spent 2µs making 1 call to Readonly::Array::FETCHSIZE |
112 | |||||
113 | |||||
114 | 1 | 144µs | 67 | 392µs | Readonly::Hash our %EXPORT_TAGS => ( # spent 307µs making 1 call to Readonly::Hash
# spent 83µs making 65 calls to Readonly::Array::FETCH, avg 1µs/call
# spent 1µs making 1 call to Readonly::Array::FETCHSIZE |
115 | all => [ @EXPORT_OK ], | ||||
116 | booleans => [ qw{ $TRUE $FALSE } ], | ||||
117 | severities => [ | ||||
118 | qw{ | ||||
119 | $SEVERITY_HIGHEST | ||||
120 | $SEVERITY_HIGH | ||||
121 | $SEVERITY_MEDIUM | ||||
122 | $SEVERITY_LOW | ||||
123 | $SEVERITY_LOWEST | ||||
124 | @SEVERITY_NAMES | ||||
125 | } | ||||
126 | ], | ||||
127 | characters => [ | ||||
128 | qw{ | ||||
129 | $COLON | ||||
130 | $COMMA | ||||
131 | $DQUOTE | ||||
132 | $EMPTY | ||||
133 | $EQUAL | ||||
134 | $FATCOMMA | ||||
135 | $PERIOD | ||||
136 | $PIPE | ||||
137 | $QUOTE | ||||
138 | $BACKTICK | ||||
139 | $SCOLON | ||||
140 | $SPACE | ||||
141 | $SLASH | ||||
142 | $BSLASH | ||||
143 | $LEFT_PAREN | ||||
144 | $RIGHT_PAREN | ||||
145 | } | ||||
146 | ], | ||||
147 | classification => [ | ||||
148 | qw{ | ||||
149 | is_class_name | ||||
150 | is_function_call | ||||
151 | is_hash_key | ||||
152 | is_included_module_name | ||||
153 | is_integer | ||||
154 | is_label_pointer | ||||
155 | is_method_call | ||||
156 | is_package_declaration | ||||
157 | is_perl_bareword | ||||
158 | is_perl_builtin | ||||
159 | is_perl_filehandle | ||||
160 | is_perl_global | ||||
161 | is_perl_builtin_with_list_context | ||||
162 | is_perl_builtin_with_multiple_arguments | ||||
163 | is_perl_builtin_with_no_arguments | ||||
164 | is_perl_builtin_with_one_argument | ||||
165 | is_perl_builtin_with_optional_argument | ||||
166 | is_perl_builtin_with_zero_and_or_one_arguments | ||||
167 | is_qualified_name | ||||
168 | is_script | ||||
169 | is_subroutine_name | ||||
170 | is_unchecked_call | ||||
171 | is_valid_numeric_verbosity | ||||
172 | } | ||||
173 | ], | ||||
174 | data_conversion => [ qw{ hashify words_from_string interpolate } ], | ||||
175 | ppi => [ qw{ first_arg parse_arg_list } ], | ||||
176 | internal_lookup => [ qw{ severity_to_number verbosity_to_format } ], | ||||
177 | language => [ qw{ precedence_of } ], | ||||
178 | deprecated => [ qw{ find_keywords } ], | ||||
179 | ); | ||||
180 | |||||
181 | #----------------------------------------------------------------------------- | ||||
182 | |||||
183 | 1 | 11µs | 1 | 59µs | Readonly::Scalar our $POLICY_NAMESPACE => 'Perl::Critic::Policy'; # spent 59µs making 1 call to Readonly::Scalar |
184 | |||||
185 | #----------------------------------------------------------------------------- | ||||
186 | |||||
187 | 1 | 1µs | 1 | 21µs | Readonly::Scalar our $SEVERITY_HIGHEST => 5; # spent 21µs making 1 call to Readonly::Scalar |
188 | 1 | 1µs | 1 | 19µs | Readonly::Scalar our $SEVERITY_HIGH => 4; # spent 19µs making 1 call to Readonly::Scalar |
189 | 1 | 900ns | 1 | 19µs | Readonly::Scalar our $SEVERITY_MEDIUM => 3; # spent 19µs making 1 call to Readonly::Scalar |
190 | 1 | 800ns | 1 | 19µs | Readonly::Scalar our $SEVERITY_LOW => 2; # spent 19µs making 1 call to Readonly::Scalar |
191 | 1 | 800ns | 1 | 19µs | Readonly::Scalar our $SEVERITY_LOWEST => 1; # spent 19µs making 1 call to Readonly::Scalar |
192 | |||||
193 | #----------------------------------------------------------------------------- | ||||
194 | |||||
195 | 1 | 800ns | 1 | 19µs | Readonly::Scalar our $COMMA => q{,}; # spent 19µs making 1 call to Readonly::Scalar |
196 | 1 | 800ns | 1 | 19µs | Readonly::Scalar our $EQUAL => q{=}; # spent 19µs making 1 call to Readonly::Scalar |
197 | 1 | 900ns | 1 | 28µs | Readonly::Scalar our $FATCOMMA => q{=>}; # spent 28µs making 1 call to Readonly::Scalar |
198 | 1 | 1µs | 1 | 20µs | Readonly::Scalar our $COLON => q{:}; # spent 20µs making 1 call to Readonly::Scalar |
199 | 1 | 800ns | 1 | 20µs | Readonly::Scalar our $SCOLON => q{;}; # spent 20µs making 1 call to Readonly::Scalar |
200 | 1 | 900ns | 1 | 20µs | Readonly::Scalar our $QUOTE => q{'}; # spent 20µs making 1 call to Readonly::Scalar |
201 | 1 | 1µs | 1 | 21µs | Readonly::Scalar our $DQUOTE => q{"}; # spent 21µs making 1 call to Readonly::Scalar |
202 | 1 | 900ns | 1 | 30µs | Readonly::Scalar our $BACKTICK => q{`}; # spent 30µs making 1 call to Readonly::Scalar |
203 | 1 | 900ns | 1 | 20µs | Readonly::Scalar our $PERIOD => q{.}; # spent 20µs making 1 call to Readonly::Scalar |
204 | 1 | 900ns | 1 | 20µs | Readonly::Scalar our $PIPE => q{|}; # spent 20µs making 1 call to Readonly::Scalar |
205 | 1 | 900ns | 1 | 22µs | Readonly::Scalar our $SPACE => q{ }; # spent 22µs making 1 call to Readonly::Scalar |
206 | 1 | 900ns | 1 | 20µs | Readonly::Scalar our $SLASH => q{/}; # spent 20µs making 1 call to Readonly::Scalar |
207 | 1 | 800ns | 1 | 29µs | Readonly::Scalar our $BSLASH => q{\\}; # spent 29µs making 1 call to Readonly::Scalar |
208 | 1 | 800ns | 1 | 19µs | Readonly::Scalar our $LEFT_PAREN => q{(}; # spent 19µs making 1 call to Readonly::Scalar |
209 | 1 | 800ns | 1 | 19µs | Readonly::Scalar our $RIGHT_PAREN => q{)}; # spent 19µs making 1 call to Readonly::Scalar |
210 | 1 | 900ns | 1 | 19µs | Readonly::Scalar our $EMPTY => q{}; # spent 19µs making 1 call to Readonly::Scalar |
211 | 1 | 1µs | 1 | 19µs | Readonly::Scalar our $TRUE => 1; # spent 19µs making 1 call to Readonly::Scalar |
212 | 1 | 900ns | 1 | 19µs | Readonly::Scalar our $FALSE => 0; # spent 19µs making 1 call to Readonly::Scalar |
213 | |||||
214 | #----------------------------------------------------------------------------- | ||||
215 | |||||
216 | #TODO: Should this include punctuations vars? | ||||
217 | |||||
- - | |||||
220 | #----------------------------------------------------------------------------- | ||||
221 | ## no critic (ProhibitNoisyQuotes); | ||||
222 | |||||
223 | 1 | 3µs | 1 | 124µs | Readonly::Hash my %PRECEDENCE_OF => ( # spent 124µs making 1 call to Readonly::Hash |
224 | '->' => 1, | ||||
225 | '++' => 2, | ||||
226 | '--' => 2, | ||||
227 | '**' => 3, | ||||
228 | '!' => 4, | ||||
229 | '~' => 4, | ||||
230 | '\\' => 4, | ||||
231 | '=~' => 5, | ||||
232 | '!~' => 5, | ||||
233 | '*' => 6, | ||||
234 | '/' => 6, | ||||
235 | '%' => 6, | ||||
236 | 'x' => 6, | ||||
237 | '+' => 7, | ||||
238 | '-' => 7, | ||||
239 | '.' => 7, | ||||
240 | '<<' => 8, | ||||
241 | '>>' => 8, | ||||
242 | '-R' => 9, | ||||
243 | '-W' => 9, | ||||
244 | '-X' => 9, | ||||
245 | '-r' => 9, | ||||
246 | '-w' => 9, | ||||
247 | '-x' => 9, | ||||
248 | '-e' => 9, | ||||
249 | '-O' => 9, | ||||
250 | '-o' => 9, | ||||
251 | '-z' => 9, | ||||
252 | '-s' => 9, | ||||
253 | '-M' => 9, | ||||
254 | '-A' => 9, | ||||
255 | '-C' => 9, | ||||
256 | '-S' => 9, | ||||
257 | '-c' => 9, | ||||
258 | '-b' => 9, | ||||
259 | '-f' => 9, | ||||
260 | '-d' => 9, | ||||
261 | '-p' => 9, | ||||
262 | '-l' => 9, | ||||
263 | '-u' => 9, | ||||
264 | '-g' => 9, | ||||
265 | '-k' => 9, | ||||
266 | '-t' => 9, | ||||
267 | '-T' => 9, | ||||
268 | '-B' => 9, | ||||
269 | '<' => 10, | ||||
270 | '>' => 10, | ||||
271 | '<=' => 10, | ||||
272 | '>=' => 10, | ||||
273 | 'lt' => 10, | ||||
274 | 'gt' => 10, | ||||
275 | 'le' => 10, | ||||
276 | 'ge' => 10, | ||||
277 | '==' => 11, | ||||
278 | '!=' => 11, | ||||
279 | '<=>' => 11, | ||||
280 | 'eq' => 11, | ||||
281 | 'ne' => 11, | ||||
282 | 'cmp' => 11, | ||||
283 | '~~' => 11, | ||||
284 | '&' => 12, | ||||
285 | '|' => 13, | ||||
286 | '^' => 13, | ||||
287 | '&&' => 14, | ||||
288 | '//' => 15, | ||||
289 | '||' => 15, | ||||
290 | '..' => 16, | ||||
291 | '...' => 17, | ||||
292 | '?' => 18, | ||||
293 | ':' => 18, | ||||
294 | '=' => 19, | ||||
295 | '+=' => 19, | ||||
296 | '-=' => 19, | ||||
297 | '*=' => 19, | ||||
298 | '/=' => 19, | ||||
299 | '%=' => 19, | ||||
300 | '||=' => 19, | ||||
301 | '&&=' => 19, | ||||
302 | '|=' => 19, | ||||
303 | '&=' => 19, | ||||
304 | '**=' => 19, | ||||
305 | 'x=' => 19, | ||||
306 | '.=' => 19, | ||||
307 | '^=' => 19, | ||||
308 | '<<=' => 19, | ||||
309 | '>>=' => 19, | ||||
310 | '//=' => 19, | ||||
311 | ',' => 20, | ||||
312 | '=>' => 20, | ||||
313 | 'not' => 22, | ||||
314 | 'and' => 23, | ||||
315 | 'or' => 24, | ||||
316 | 'xor' => 24, | ||||
317 | ); | ||||
318 | |||||
319 | ## use critic | ||||
320 | |||||
321 | 1 | 3µs | 2 | 34µs | Readonly::Scalar my $MIN_PRECEDENCE_TO_TERMINATE_PARENLESS_ARG_LIST => # spent 21µs making 1 call to Readonly::Scalar
# spent 13µs making 1 call to Perl::Critic::Utils::precedence_of |
322 | precedence_of( 'not' ); | ||||
323 | |||||
324 | #----------------------------------------------------------------------------- | ||||
325 | |||||
326 | # spent 4.74ms (4.41+328µs) within Perl::Critic::Utils::hashify which was called 222 times, avg 21µs/call:
# 52 times (59µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 1230, avg 1µs/call
# 51 times (190µs+0s) by Perl::Critic::Annotation::_parse_annotation at line 270 of Perl/Critic/Annotation.pm, avg 4µs/call
# 32 times (87µs+0s) by Perl::Critic::PolicyParameter::Behavior::StringList::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyParameter/Behavior/StringList.pm:60] at line 55 of Perl/Critic/PolicyParameter/Behavior/StringList.pm, avg 3µs/call
# 13 times (62µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 1233, avg 5µs/call
# 8 times (26µs+0s) by Perl::Critic::PolicyParameter::Behavior::Enumeration::initialize_parameter at line 48 of Perl/Critic/PolicyParameter/Behavior/Enumeration.pm, avg 3µs/call
# 5 times (7µs+0s) by Perl::Critic::PolicyParameter::Behavior::Enumeration::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyParameter/Behavior/Enumeration.pm:93] at line 88 of Perl/Critic/PolicyParameter/Behavior/Enumeration.pm, avg 1µs/call
# once (3.10ms+61µs) by Module::Pluggable::Object::_require at line 58 of Perl/Critic/Policy/CodeLayout/ProhibitParensWithBuiltins.pm
# once (413µs+196µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 404
# once (57µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 362
# once (35µs+16µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 1085
# once (20µs+9µs) by Module::Pluggable::Object::_require at line 27 of Perl/Critic/Policy/ControlStructures/ProhibitUnreachableCode.pm
# once (19µs+9µs) by Module::Pluggable::Object::_require at line 26 of Perl/Critic/Policy/Variables/ProhibitMatchVars.pm
# once (18µs+8µs) by Module::Pluggable::Object::_require at line 24 of Perl/Critic/Policy/ControlStructures/ProhibitUnreachableCode.pm
# once (16µs+7µs) by Module::Pluggable::Object::_require at line 27 of Perl/Critic/Policy/CodeLayout/ProhibitParensWithBuiltins.pm
# once (22µs+0s) by Perl::Critic::PolicyFactory::_validate_policies_in_profile at line 305 of Perl/Critic/PolicyFactory.pm
# once (21µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 655
# once (20µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 477
# once (14µs+5µs) by Module::Pluggable::Object::_require at line 21 of Perl/Critic/Policy/ControlStructures/ProhibitUnreachableCode.pm
# once (12µs+4µs) by Module::Pluggable::Object::_require at line 23 of Perl/Critic/Policy/InputOutput/RequireBracedFileHandleWithPrint.pm
# once (12µs+4µs) by Perl::Critic::Command::BEGIN@26 at line 66 of Perl/Critic/Utils/Constants.pm
# once (11µs+4µs) by Module::Pluggable::Object::_require at line 25 of Perl/Critic/Policy/Subroutines/ProhibitBuiltinHomonyms.pm
# once (11µs+2µs) by Module::Pluggable::Object::_require at line 88 of Perl/Critic/Policy/NamingConventions/Capitalization.pm
# once (10µs+3µs) by Module::Pluggable::Object::_require at line 32 of Perl/Critic/Policy/Subroutines/ProhibitUnusedPrivateSubroutines.pm
# once (12µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 373
# once (8µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 598
# once (7µs+0s) by Module::Pluggable::Object::_require at line 44 of Perl/Critic/Policy/ValuesAndExpressions/RequireConstantVersion.pm
# once (7µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 429
# once (7µs+0s) by Module::Pluggable::Object::_require at line 242 of Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm
# once (6µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 557
# once (6µs+0s) by Module::Pluggable::Object::_require at line 35 of Perl/Critic/Policy/Variables/ProhibitAugmentedAssignmentInDeclaration.pm
# once (6µs+0s) by Module::Pluggable::Object::_require at line 21 of Perl/Critic/Policy/ControlStructures/ProhibitLabelsWithSpecialBlockNames.pm
# once (6µs+0s) by Module::Pluggable::Object::_require at line 28 of Perl/Critic/Policy/RegularExpressions/ProhibitEscapedMetacharacters.pm
# once (5µs+0s) by Module::Pluggable::Object::_require at line 105 of Perl/Critic/Policy/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.pm
# once (4µs+0s) by Module::Pluggable::Object::_require at line 298 of Perl/Critic/Policy/ErrorHandling/RequireCarping.pm
# once (4µs+0s) by Module::Pluggable::Object::_require at line 22 of Perl/Critic/Policy/RegularExpressions/ProhibitCaptureWithoutTest.pm
# once (4µs+0s) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::initialize_if_enabled at line 88 of Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm
# once (4µs+0s) by Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@16 at line 31 of Perl/Critic/Utils/McCabe.pm
# once (4µs+0s) by Module::Pluggable::Object::_require at line 198 of Perl/Critic/Policy/Subroutines/RequireArgUnpacking.pm
# once (4µs+0s) by Module::Pluggable::Object::_require at line 221 of Perl/Critic/Policy/Subroutines/RequireArgUnpacking.pm
# once (4µs+0s) by Perl::Critic::Exception::Parse::BEGIN@18 at line 416
# once (4µs+0s) by Module::Pluggable::Object::_require at line 24 of Perl/Critic/Policy/ValuesAndExpressions/ProhibitMixedBooleanOperators.pm
# once (4µs+0s) by Module::Pluggable::Object::_require at line 25 of Perl/Critic/Policy/BuiltinFunctions/ProhibitBooleanGrep.pm
# once (4µs+0s) by Module::Pluggable::Object::_require at line 45 of Perl/Critic/Policy/Variables/ProhibitConditionalDeclarations.pm
# once (4µs+0s) by Module::Pluggable::Object::_require at line 26 of Perl/Critic/Policy/Subroutines/ProhibitAmpersandSigils.pm
# once (3µs+0s) by Module::Pluggable::Object::_require at line 27 of Perl/Critic/Policy/ValuesAndExpressions/ProhibitMixedBooleanOperators.pm
# once (3µs+0s) by Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@16 at line 34 of Perl/Critic/Utils/McCabe.pm
# once (3µs+0s) by Module::Pluggable::Object::_require at line 32 of Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm
# once (3µs+0s) by Module::Pluggable::Object::_require at line 33 of Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm
# once (3µs+0s) by Module::Pluggable::Object::_require at line 23 of Perl/Critic/Policy/Variables/RequireLocalizedPunctuationVars.pm
# once (3µs+0s) by Module::Pluggable::Object::_require at line 25 of Perl/Critic/Policy/Subroutines/RequireFinalReturn.pm
# once (3µs+0s) by Module::Pluggable::Object::_require at line 26 of Perl/Critic/Policy/BuiltinFunctions/ProhibitBooleanGrep.pm
# once (3µs+0s) by Module::Pluggable::Object::_require at line 35 of Perl/Critic/Policy/InputOutput/RequireBriefOpen.pm
# once (3µs+0s) by Module::Pluggable::Object::_require at line 33 of Perl/Critic/Policy/RegularExpressions/ProhibitUnusedCapture.pm
# once (3µs+0s) by Module::Pluggable::Object::_require at line 31 of Perl/Critic/Policy/Variables/ProhibitEvilVariables.pm
# once (3µs+0s) by Module::Pluggable::Object::_require at line 23 of Perl/Critic/Policy/RegularExpressions/ProhibitCaptureWithoutTest.pm
# once (2µs+0s) by Module::Pluggable::Object::_require at line 34 of Perl/Critic/Policy/RegularExpressions/ProhibitUnusedCapture.pm
# once (2µs+0s) by Module::Pluggable::Object::_require at line 25 of Perl/Critic/Policy/ValuesAndExpressions/ProhibitMixedBooleanOperators.pm
# once (2µs+0s) by Module::Pluggable::Object::_require at line 499 of Perl/Critic/Policy/RegularExpressions/ProhibitUnusedCapture.pm
# once (2µs+0s) by Perl::Critic::Config::_validate_and_save_program_extensions at line 768 of Perl/Critic/Config.pm
# once (2µs+0s) by Module::Pluggable::Object::_require at line 41 of Perl/Critic/Policy/InputOutput/RequireBriefOpen.pm
# once (2µs+0s) by Module::Pluggable::Object::_require at line 29 of Perl/Critic/Policy/Subroutines/ProhibitAmpersandSigils.pm
# once (2µs+0s) by Perl::Critic::Config::program_extensions_as_regexes at line 952 of Perl/Critic/Config.pm
# once (2µs+0s) by Module::Pluggable::Object::_require at line 247 of Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm
# once (2µs+0s) by Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_determine_allowed_values at line 184 of Perl/Critic/Policy/ValuesAndExpressions/ProhibitMagicNumbers.pm
# once (2µs+0s) by Module::Pluggable::Object::_require at line 224 of Perl/Critic/Policy/Subroutines/RequireArgUnpacking.pm
# once (2µs+0s) by Module::Pluggable::Object::_require at line 201 of Perl/Critic/Policy/Subroutines/RequireArgUnpacking.pm
# once (2µs+0s) by Module::Pluggable::Object::_require at line 250 of Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm | ||||
327 | 222 | 1.47ms | 256 | 328µs | return map { $_ => 1 } @_; # spent 319µs making 249 calls to Readonly::Array::FETCH, avg 1µs/call
# spent 9µs making 7 calls to Readonly::Scalar::FETCH, avg 1µs/call |
328 | } | ||||
329 | |||||
330 | #----------------------------------------------------------------------------- | ||||
331 | |||||
332 | sub interpolate { | ||||
333 | my ( $literal ) = @_; | ||||
334 | return eval "\"$literal\"" || confess $EVAL_ERROR; ## no critic (StringyEval); | ||||
335 | } | ||||
336 | |||||
337 | #----------------------------------------------------------------------------- | ||||
338 | |||||
339 | sub find_keywords { | ||||
340 | my ( $doc, $keyword ) = @_; | ||||
341 | my $nodes_ref = $doc->find('PPI::Token::Word'); | ||||
342 | return if !$nodes_ref; | ||||
343 | my @matches = grep { $_ eq $keyword } @{$nodes_ref}; | ||||
344 | return @matches ? \@matches : undef; | ||||
345 | } | ||||
346 | |||||
347 | #----------------------------------------------------------------------------- | ||||
348 | |||||
349 | # spent 1.77ms (1.23+541µs) within Perl::Critic::Utils::_name_for_sub_or_stringified_element which was called 154 times, avg 12µs/call:
# 77 times (724µs+313µs) by Perl::Critic::Utils::is_perl_bareword at line 379, avg 13µs/call
# 77 times (508µs+228µs) by Perl::Critic::Utils::is_perl_filehandle at line 422, avg 10µs/call | ||||
350 | 154 | 31µs | my $elem = shift; | ||
351 | |||||
352 | 154 | 946µs | 308 | 329µs | if ( blessed $elem and $elem->isa('PPI::Statement::Sub') ) { # spent 167µs making 154 calls to UNIVERSAL::isa, avg 1µs/call
# spent 162µs making 154 calls to Scalar::Util::blessed, avg 1µs/call |
353 | return $elem->name(); | ||||
354 | } | ||||
355 | |||||
356 | 154 | 486µs | 154 | 212µs | return "$elem"; # spent 212µs making 154 calls to PPI::Token::content, avg 1µs/call |
357 | } | ||||
358 | |||||
359 | #----------------------------------------------------------------------------- | ||||
360 | ## no critic (ProhibitPackageVars) | ||||
361 | |||||
362 | 1 | 30µs | 2 | 336µs | Readonly::Hash my %BUILTINS => hashify( @B::Keywords::Functions ); # spent 279µs making 1 call to Readonly::Hash
# spent 57µs making 1 call to Perl::Critic::Utils::hashify |
363 | |||||
364 | sub is_perl_builtin { | ||||
365 | my $elem = shift; | ||||
366 | return if !$elem; | ||||
367 | |||||
368 | return exists $BUILTINS{ _name_for_sub_or_stringified_element($elem) }; | ||||
369 | } | ||||
370 | |||||
371 | #----------------------------------------------------------------------------- | ||||
372 | |||||
373 | 1 | 7µs | 2 | 87µs | Readonly::Hash my %BAREWORDS => hashify( @B::Keywords::Barewords ); # spent 74µs making 1 call to Readonly::Hash
# spent 12µs making 1 call to Perl::Critic::Utils::hashify |
374 | |||||
375 | # spent 2.18ms (905µs+1.27) within Perl::Critic::Utils::is_perl_bareword which was called 77 times, avg 28µs/call:
# 77 times (905µs+1.27ms) by Perl::Critic::Utils::is_function_call at line 838, avg 28µs/call | ||||
376 | 77 | 25µs | my $elem = shift; | ||
377 | 77 | 197µs | 77 | 36µs | return if !$elem; # spent 36µs making 77 calls to PPI::Util::TRUE, avg 468ns/call |
378 | |||||
379 | 77 | 604µs | 154 | 1.24ms | return exists $BAREWORDS{ _name_for_sub_or_stringified_element($elem) }; # spent 1.04ms making 77 calls to Perl::Critic::Utils::_name_for_sub_or_stringified_element, avg 13µs/call
# spent 200µs making 77 calls to Readonly::Hash::EXISTS, avg 3µs/call |
380 | } | ||||
381 | |||||
382 | #----------------------------------------------------------------------------- | ||||
383 | |||||
384 | # spent 106µs (102+4) within Perl::Critic::Utils::_build_globals_without_sigils which was called:
# once (102µs+4µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 402 | ||||
385 | # B::Keywords as of 1.08 forgot $\ | ||||
386 | my @globals = | ||||
387 | 1 | 47µs | map { substr $_, 1 } | ||
388 | @B::Keywords::Arrays, | ||||
389 | @B::Keywords::Hashes, | ||||
390 | @B::Keywords::Scalars, | ||||
391 | '$\\'; ## no critic (RequireInterpolationOfMetachars) | ||||
392 | |||||
393 | # Not all of these have sigils | ||||
394 | 1 | 700ns | foreach my $filehandle (@B::Keywords::Filehandles) { | ||
395 | 9 | 20µs | 9 | 4µs | (my $stripped = $filehandle) =~ s< \A [*] ><>xms; # spent 4µs making 9 calls to Perl::Critic::Utils::CORE:subst, avg 444ns/call |
396 | 9 | 5µs | push @globals, $stripped; | ||
397 | } | ||||
398 | |||||
399 | 1 | 34µs | return @globals; | ||
400 | } | ||||
401 | |||||
402 | 1 | 15µs | 2 | 222µs | Readonly::Array my @GLOBALS_WITHOUT_SIGILS => _build_globals_without_sigils(); # spent 115µs making 1 call to Readonly::Array
# spent 106µs making 1 call to Perl::Critic::Utils::_build_globals_without_sigils |
403 | |||||
404 | 1 | 68µs | 3 | 799µs | Readonly::Hash my %GLOBALS => hashify( @GLOBALS_WITHOUT_SIGILS ); # spent 609µs making 1 call to Perl::Critic::Utils::hashify
# spent 188µs making 1 call to Readonly::Hash
# spent 1µs making 1 call to Readonly::Array::FETCHSIZE |
405 | |||||
406 | sub is_perl_global { | ||||
407 | my $elem = shift; | ||||
408 | return if !$elem; | ||||
409 | my $var_name = "$elem"; #Convert Token::Symbol to string | ||||
410 | $var_name =~ s{\A [\$@%*] }{}xms; #Chop off the sigil | ||||
411 | return exists $GLOBALS{ $var_name }; | ||||
412 | } | ||||
413 | |||||
414 | #----------------------------------------------------------------------------- | ||||
415 | |||||
416 | 1 | 3µs | 2 | 36µs | Readonly::Hash my %FILEHANDLES => hashify( @B::Keywords::Filehandles ); # spent 32µs making 1 call to Readonly::Hash
# spent 4µs making 1 call to Perl::Critic::Utils::hashify |
417 | |||||
418 | # spent 1.65ms (760µs+890µs) within Perl::Critic::Utils::is_perl_filehandle which was called 77 times, avg 21µs/call:
# 77 times (760µs+890µs) by Perl::Critic::Utils::is_function_call at line 839, avg 21µs/call | ||||
419 | 77 | 26µs | my $elem = shift; | ||
420 | 77 | 211µs | 77 | 35µs | return if !$elem; # spent 35µs making 77 calls to PPI::Util::TRUE, avg 460ns/call |
421 | |||||
422 | 77 | 413µs | 154 | 855µs | return exists $FILEHANDLES{ _name_for_sub_or_stringified_element($elem) }; # spent 736µs making 77 calls to Perl::Critic::Utils::_name_for_sub_or_stringified_element, avg 10µs/call
# spent 119µs making 77 calls to Readonly::Hash::EXISTS, avg 2µs/call |
423 | } | ||||
424 | |||||
425 | ## use critic | ||||
426 | #----------------------------------------------------------------------------- | ||||
427 | |||||
428 | # egrep '=item.*LIST' perlfunc.pod | ||||
429 | 1 | 5µs | 2 | 52µs | Readonly::Hash my %BUILTINS_WHICH_PROVIDE_LIST_CONTEXT => # spent 45µs making 1 call to Readonly::Hash
# spent 7µs making 1 call to Perl::Critic::Utils::hashify |
430 | hashify( | ||||
431 | qw{ | ||||
432 | chmod | ||||
433 | chown | ||||
434 | die | ||||
435 | exec | ||||
436 | formline | ||||
437 | grep | ||||
438 | import | ||||
439 | join | ||||
440 | kill | ||||
441 | map | ||||
442 | no | ||||
443 | open | ||||
444 | pack | ||||
445 | |||||
446 | printf | ||||
447 | push | ||||
448 | reverse | ||||
449 | say | ||||
450 | sort | ||||
451 | splice | ||||
452 | sprintf | ||||
453 | syscall | ||||
454 | system | ||||
455 | tie | ||||
456 | unlink | ||||
457 | unshift | ||||
458 | use | ||||
459 | utime | ||||
460 | warn | ||||
461 | }, | ||||
462 | ); | ||||
463 | |||||
464 | sub is_perl_builtin_with_list_context { | ||||
465 | my $elem = shift; | ||||
466 | |||||
467 | return | ||||
468 | exists | ||||
469 | $BUILTINS_WHICH_PROVIDE_LIST_CONTEXT{ | ||||
470 | _name_for_sub_or_stringified_element($elem) | ||||
471 | }; | ||||
472 | } | ||||
473 | |||||
474 | #----------------------------------------------------------------------------- | ||||
475 | |||||
476 | # egrep '=item.*[A-Z],' perlfunc.pod | ||||
477 | 1 | 62µs | 32 | 154µs | Readonly::Hash my %BUILTINS_WHICH_TAKE_MULTIPLE_ARGUMENTS => # spent 101µs making 1 call to Readonly::Hash
# spent 30µs making 29 calls to Readonly::Hash::NEXTKEY, avg 1µs/call
# spent 20µs making 1 call to Perl::Critic::Utils::hashify
# spent 4µs making 1 call to Readonly::Hash::FIRSTKEY |
478 | hashify( | ||||
479 | qw{ | ||||
480 | accept | ||||
481 | atan2 | ||||
482 | bind | ||||
483 | binmode | ||||
484 | bless | ||||
485 | connect | ||||
486 | crypt | ||||
487 | dbmopen | ||||
488 | fcntl | ||||
489 | flock | ||||
490 | gethostbyaddr | ||||
491 | getnetbyaddr | ||||
492 | getpriority | ||||
493 | getservbyname | ||||
494 | getservbyport | ||||
495 | getsockopt | ||||
496 | index | ||||
497 | ioctl | ||||
498 | link | ||||
499 | listen | ||||
500 | mkdir | ||||
501 | msgctl | ||||
502 | msgget | ||||
503 | msgrcv | ||||
504 | msgsnd | ||||
505 | open | ||||
506 | opendir | ||||
507 | pipe | ||||
508 | read | ||||
509 | recv | ||||
510 | rename | ||||
511 | rindex | ||||
512 | seek | ||||
513 | seekdir | ||||
514 | select | ||||
515 | semctl | ||||
516 | semget | ||||
517 | semop | ||||
518 | send | ||||
519 | setpgrp | ||||
520 | setpriority | ||||
521 | setsockopt | ||||
522 | shmctl | ||||
523 | shmget | ||||
524 | shmread | ||||
525 | shmwrite | ||||
526 | shutdown | ||||
527 | socket | ||||
528 | socketpair | ||||
529 | splice | ||||
530 | split | ||||
531 | substr | ||||
532 | symlink | ||||
533 | sysopen | ||||
534 | sysread | ||||
535 | sysseek | ||||
536 | syswrite | ||||
537 | truncate | ||||
538 | unpack | ||||
539 | vec | ||||
540 | waitpid | ||||
541 | }, | ||||
542 | keys %BUILTINS_WHICH_PROVIDE_LIST_CONTEXT | ||||
543 | ); | ||||
544 | |||||
545 | sub is_perl_builtin_with_multiple_arguments { | ||||
546 | my $elem = shift; | ||||
547 | |||||
548 | return | ||||
549 | exists | ||||
550 | $BUILTINS_WHICH_TAKE_MULTIPLE_ARGUMENTS{ | ||||
551 | _name_for_sub_or_stringified_element($elem) | ||||
552 | }; | ||||
553 | } | ||||
554 | |||||
555 | #----------------------------------------------------------------------------- | ||||
556 | |||||
557 | 1 | 4µs | 2 | 46µs | Readonly::Hash my %BUILTINS_WHICH_TAKE_NO_ARGUMENTS => # spent 40µs making 1 call to Readonly::Hash
# spent 6µs making 1 call to Perl::Critic::Utils::hashify |
558 | hashify( | ||||
559 | qw{ | ||||
560 | endgrent | ||||
561 | endhostent | ||||
562 | endnetent | ||||
563 | endprotoent | ||||
564 | endpwent | ||||
565 | endservent | ||||
566 | fork | ||||
567 | format | ||||
568 | getgrent | ||||
569 | gethostent | ||||
570 | getlogin | ||||
571 | getnetent | ||||
572 | getppid | ||||
573 | getprotoent | ||||
574 | getpwent | ||||
575 | getservent | ||||
576 | setgrent | ||||
577 | setpwent | ||||
578 | split | ||||
579 | time | ||||
580 | times | ||||
581 | wait | ||||
582 | wantarray | ||||
583 | } | ||||
584 | ); | ||||
585 | |||||
586 | sub is_perl_builtin_with_no_arguments { | ||||
587 | my $elem = shift; | ||||
588 | |||||
589 | return | ||||
590 | exists | ||||
591 | $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{ | ||||
592 | _name_for_sub_or_stringified_element($elem) | ||||
593 | }; | ||||
594 | } | ||||
595 | |||||
596 | #----------------------------------------------------------------------------- | ||||
597 | |||||
598 | 1 | 5µs | 2 | 61µs | Readonly::Hash my %BUILTINS_WHICH_TAKE_ONE_ARGUMENT => # spent 53µs making 1 call to Readonly::Hash
# spent 8µs making 1 call to Perl::Critic::Utils::hashify |
599 | hashify( | ||||
600 | qw{ | ||||
601 | closedir | ||||
602 | dbmclose | ||||
603 | delete | ||||
604 | each | ||||
605 | exists | ||||
606 | fileno | ||||
607 | getgrgid | ||||
608 | getgrnam | ||||
609 | gethostbyname | ||||
610 | getnetbyname | ||||
611 | getpeername | ||||
612 | getpgrp | ||||
613 | getprotobyname | ||||
614 | getprotobynumber | ||||
615 | getpwnam | ||||
616 | getpwuid | ||||
617 | getsockname | ||||
618 | goto | ||||
619 | keys | ||||
620 | local | ||||
621 | prototype | ||||
622 | readdir | ||||
623 | readline | ||||
624 | readpipe | ||||
625 | rewinddir | ||||
626 | scalar | ||||
627 | sethostent | ||||
628 | setnetent | ||||
629 | setprotoent | ||||
630 | setservent | ||||
631 | telldir | ||||
632 | tied | ||||
633 | untie | ||||
634 | values | ||||
635 | } | ||||
636 | ); | ||||
637 | |||||
638 | sub is_perl_builtin_with_one_argument { | ||||
639 | my $elem = shift; | ||||
640 | |||||
641 | return | ||||
642 | exists | ||||
643 | $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{ | ||||
644 | _name_for_sub_or_stringified_element($elem) | ||||
645 | }; | ||||
646 | } | ||||
647 | |||||
648 | #----------------------------------------------------------------------------- | ||||
649 | |||||
650 | ## no critic (ProhibitPackageVars) | ||||
651 | Readonly::Hash my %BUILTINS_WHICH_TAKE_OPTIONAL_ARGUMENT => | ||||
652 | hashify( | ||||
653 | grep { not exists $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{ $_ } } | ||||
654 | grep { not exists $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{ $_ } } | ||||
655 | 1 | 1.18ms | 529 | 918µs | grep { not exists $BUILTINS_WHICH_TAKE_MULTIPLE_ARGUMENTS{ $_ } } # spent 773µs making 527 calls to Readonly::Hash::EXISTS, avg 1µs/call
# spent 124µs making 1 call to Readonly::Hash
# spent 21µs making 1 call to Perl::Critic::Utils::hashify |
656 | @B::Keywords::Functions | ||||
657 | ); | ||||
658 | ## use critic | ||||
659 | |||||
660 | sub is_perl_builtin_with_optional_argument { | ||||
661 | my $elem = shift; | ||||
662 | |||||
663 | return | ||||
664 | exists | ||||
665 | $BUILTINS_WHICH_TAKE_OPTIONAL_ARGUMENT{ | ||||
666 | _name_for_sub_or_stringified_element($elem) | ||||
667 | }; | ||||
668 | } | ||||
669 | |||||
670 | #----------------------------------------------------------------------------- | ||||
671 | |||||
672 | sub is_perl_builtin_with_zero_and_or_one_arguments { | ||||
673 | my $elem = shift; | ||||
674 | |||||
675 | return if not $elem; | ||||
676 | |||||
677 | my $name = _name_for_sub_or_stringified_element($elem); | ||||
678 | |||||
679 | return ( | ||||
680 | exists $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{ $name } | ||||
681 | or exists $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{ $name } | ||||
682 | or exists $BUILTINS_WHICH_TAKE_OPTIONAL_ARGUMENT{ $name } | ||||
683 | ); | ||||
684 | } | ||||
685 | |||||
686 | #----------------------------------------------------------------------------- | ||||
687 | |||||
688 | sub is_qualified_name { | ||||
689 | my $name = shift; | ||||
690 | |||||
691 | return if not $name; | ||||
692 | |||||
693 | return index ( $name, q{::} ) >= 0; | ||||
694 | } | ||||
695 | |||||
696 | #----------------------------------------------------------------------------- | ||||
697 | |||||
698 | # spent 669µs (482+187) within Perl::Critic::Utils::precedence_of which was called 55 times, avg 12µs/call:
# 50 times (448µs+175µs) by Perl::Critic::Utils::parse_arg_list at line 972, avg 12µs/call
# once (8µs+6µs) by Perl::Critic::Exception::Parse::BEGIN@18 at line 321
# once (7µs+2µs) by Module::Pluggable::Object::_require at line 36 of Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm
# once (7µs+2µs) by Module::Pluggable::Object::_require at line 32 of Perl/Critic/Policy/CodeLayout/ProhibitParensWithBuiltins.pm
# once (7µs+2µs) by Module::Pluggable::Object::_require at line 26 of Perl/Critic/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm
# once (5µs+2µs) by Module::Pluggable::Object::_require at line 33 of Perl/Critic/Policy/CodeLayout/ProhibitParensWithBuiltins.pm | ||||
699 | 55 | 15µs | my $elem = shift; | ||
700 | 55 | 113µs | 50 | 23µs | return if !$elem; # spent 23µs making 50 calls to PPI::Util::TRUE, avg 464ns/call |
701 | 55 | 300µs | 105 | 164µs | return $PRECEDENCE_OF{ ref $elem ? "$elem" : $elem }; # spent 94µs making 55 calls to Readonly::Hash::FETCH, avg 2µs/call
# spent 70µs making 50 calls to PPI::Token::content, avg 1µs/call |
702 | } | ||||
703 | |||||
704 | #----------------------------------------------------------------------------- | ||||
705 | |||||
706 | # spent 1.47s (307ms+1.16) within Perl::Critic::Utils::is_hash_key which was called 14319 times, avg 103µs/call:
# 10038 times (201ms+818ms) by Perl::Critic::Utils::McCabe::_count_logic_keywords at line 112 of Perl/Critic/Utils/McCabe.pm, avg 102µs/call
# 2101 times (50.9ms+173ms) by Perl::Critic::Policy::Subroutines::ProhibitReturnSort::violates at line 37 of Perl/Critic/Policy/Subroutines/ProhibitReturnSort.pm, avg 106µs/call
# 2101 times (53.2ms+164ms) by Perl::Critic::Policy::Subroutines::ProhibitExplicitReturnUndef::violates at line 37 of Perl/Critic/Policy/Subroutines/ProhibitExplicitReturnUndef.pm, avg 104µs/call
# 79 times (1.94ms+8.07ms) by Perl::Critic::Utils::is_function_call at line 832, avg 127µs/call | ||||
707 | 14319 | 3.01ms | my $elem = shift; | ||
708 | 14319 | 41.1ms | 14319 | 7.56ms | return if !$elem; # spent 7.56ms making 14319 calls to PPI::Util::TRUE, avg 528ns/call |
709 | |||||
710 | #If followed by an argument list, then its a function call, not a literal | ||||
711 | 14319 | 21.9ms | 14319 | 657ms | return if _is_followed_by_parens($elem); # spent 657ms making 14319 calls to Perl::Critic::Utils::_is_followed_by_parens, avg 46µs/call |
712 | |||||
713 | #Check curly-brace style: $hash{foo} = bar; | ||||
714 | 11584 | 12.7ms | 11584 | 47.4ms | my $parent = $elem->parent(); # spent 47.4ms making 11584 calls to PPI::Element::parent, avg 4µs/call |
715 | 11584 | 40.4ms | 11584 | 6.81ms | return if !$parent; # spent 6.81ms making 11584 calls to PPI::Util::TRUE, avg 588ns/call |
716 | 11584 | 11.7ms | 11584 | 48.9ms | my $grandparent = $parent->parent(); # spent 48.9ms making 11584 calls to PPI::Element::parent, avg 4µs/call |
717 | 11584 | 27.1ms | 11584 | 6.48ms | return if !$grandparent; # spent 6.48ms making 11584 calls to PPI::Util::TRUE, avg 559ns/call |
718 | 11584 | 44.0ms | 11584 | 13.5ms | return 1 if $grandparent->isa('PPI::Structure::Subscript'); # spent 12.3ms making 11331 calls to UNIVERSAL::isa, avg 1µs/call
# spent 1.15ms making 249 calls to PPI::Structure::List::isa, avg 5µs/call
# spent 16µs making 4 calls to PPI::Structure::For::isa, avg 4µs/call |
719 | |||||
720 | |||||
721 | #Check declarative style: %hash = (foo => bar); | ||||
722 | 11399 | 11.3ms | 11399 | 338ms | my $sib = $elem->snext_sibling(); # spent 338ms making 11399 calls to PPI::Element::snext_sibling, avg 30µs/call |
723 | 11399 | 33.2ms | 11260 | 6.65ms | return if !$sib; # spent 6.65ms making 11260 calls to PPI::Util::TRUE, avg 591ns/call |
724 | 11260 | 36.6ms | 12164 | 31.1ms | return 1 if $sib->isa('PPI::Token::Operator') && $sib eq '=>'; # spent 18.8ms making 904 calls to PPI::Element::__eq, avg 21µs/call
# spent 12.3ms making 11257 calls to UNIVERSAL::isa, avg 1µs/call
# spent 12µs making 3 calls to PPI::Structure::For::isa, avg 4µs/call |
725 | |||||
726 | 10758 | 29.3ms | return; | ||
727 | } | ||||
728 | |||||
729 | #----------------------------------------------------------------------------- | ||||
730 | |||||
731 | # spent 657ms (154+503) within Perl::Critic::Utils::_is_followed_by_parens which was called 14319 times, avg 46µs/call:
# 14319 times (154ms+503ms) by Perl::Critic::Utils::is_hash_key at line 711, avg 46µs/call | ||||
732 | 14319 | 1.87ms | my $elem = shift; | ||
733 | 14319 | 42.3ms | 14319 | 5.71ms | return if !$elem; # spent 5.71ms making 14319 calls to PPI::Util::TRUE, avg 399ns/call |
734 | |||||
735 | 14319 | 58.0ms | 28319 | 469ms | my $sibling = $elem->snext_sibling() || return; # spent 461ms making 14319 calls to PPI::Element::snext_sibling, avg 32µs/call
# spent 8.12ms making 14000 calls to PPI::Util::TRUE, avg 580ns/call |
736 | 14000 | 70.8ms | 14000 | 29.0ms | return $sibling->isa('PPI::Structure::List'); # spent 14.8ms making 11262 calls to UNIVERSAL::isa, avg 1µs/call
# spent 14.2ms making 2735 calls to PPI::Structure::List::isa, avg 5µs/call
# spent 14µs making 3 calls to PPI::Structure::For::isa, avg 5µs/call |
737 | } | ||||
738 | |||||
739 | #----------------------------------------------------------------------------- | ||||
740 | |||||
741 | # spent 5.13ms (832µs+4.30) within Perl::Critic::Utils::is_included_module_name which was called 77 times, avg 67µs/call:
# 77 times (832µs+4.30ms) by Perl::Critic::Utils::is_function_call at line 836, avg 67µs/call | ||||
742 | 77 | 23µs | my $elem = shift; | ||
743 | 77 | 201µs | 77 | 34µs | return if !$elem; # spent 34µs making 77 calls to PPI::Util::TRUE, avg 442ns/call |
744 | 77 | 108µs | 77 | 4.12ms | my $stmnt = $elem->statement(); # spent 4.12ms making 77 calls to PPI::Element::statement, avg 54µs/call |
745 | 77 | 196µs | 77 | 39µs | return if !$stmnt; # spent 39µs making 77 calls to PPI::Util::TRUE, avg 509ns/call |
746 | 77 | 425µs | 77 | 106µs | return if !$stmnt->isa('PPI::Statement::Include'); # spent 106µs making 77 calls to UNIVERSAL::isa, avg 1µs/call |
747 | return $stmnt->schild(1) == $elem; | ||||
748 | } | ||||
749 | |||||
750 | #----------------------------------------------------------------------------- | ||||
751 | |||||
752 | # spent 18µs (13+5) within Perl::Critic::Utils::is_integer which was called 3 times, avg 6µs/call:
# once (7µs+3µs) by Perl::Critic::Config::_validate_and_save_verbosity at line 487 of Perl/Critic/Config.pm
# once (3µs+1µs) by Perl::Critic::Config::_validate_and_save_severity at line 529 of Perl/Critic/Config.pm
# once (3µs+1µs) by Perl::Critic::Config::_validate_and_save_top at line 588 of Perl/Critic/Config.pm | ||||
753 | 3 | 500ns | my ($value) = @_; | ||
754 | 3 | 600ns | return 0 if not defined $value; | ||
755 | |||||
756 | 3 | 20µs | 3 | 5µs | return $value =~ m{ \A [+-]? \d+ \z }xms; # spent 5µs making 3 calls to Perl::Critic::Utils::CORE:match, avg 2µs/call |
757 | } | ||||
758 | |||||
759 | #----------------------------------------------------------------------------- | ||||
760 | |||||
761 | # spent 5.20ms (1.17+4.03) within Perl::Critic::Utils::is_label_pointer which was called 77 times, avg 67µs/call:
# 77 times (1.17ms+4.03ms) by Perl::Critic::Utils::is_function_call at line 840, avg 67µs/call | ||||
762 | 77 | 26µs | my $elem = shift; | ||
763 | 77 | 196µs | 77 | 34µs | return if !$elem; # spent 34µs making 77 calls to PPI::Util::TRUE, avg 445ns/call |
764 | |||||
765 | 77 | 106µs | 77 | 1.43ms | my $statement = $elem->statement(); # spent 1.43ms making 77 calls to PPI::Element::statement, avg 19µs/call |
766 | 77 | 200µs | 77 | 40µs | return if !$statement; # spent 40µs making 77 calls to PPI::Util::TRUE, avg 514ns/call |
767 | |||||
768 | 77 | 116µs | 77 | 2.35ms | my $psib = $elem->sprevious_sibling(); # spent 2.35ms making 77 calls to PPI::Element::sprevious_sibling, avg 31µs/call |
769 | 77 | 202µs | 52 | 32µs | return if !$psib; # spent 32µs making 52 calls to PPI::Util::TRUE, avg 625ns/call |
770 | |||||
771 | 52 | 377µs | 76 | 158µs | return $statement->isa('PPI::Statement::Break') # spent 78µs making 52 calls to UNIVERSAL::isa, avg 1µs/call
# spent 62µs making 12 calls to Perl::Critic::Utils::CORE:match, avg 5µs/call
# spent 17µs making 12 calls to PPI::Token::content, avg 1µs/call |
772 | && $psib =~ m/(?:redo|goto|next|last)/xmso; | ||||
773 | } | ||||
774 | |||||
775 | #----------------------------------------------------------------------------- | ||||
776 | |||||
777 | # spent 6.15ms (679µs+5.47) within Perl::Critic::Utils::is_method_call which was called 77 times, avg 80µs/call:
# 77 times (679µs+5.47ms) by Perl::Critic::Utils::is_function_call at line 833, avg 80µs/call | ||||
778 | 77 | 25µs | my $elem = shift; | ||
779 | 77 | 207µs | 77 | 38µs | return if !$elem; # spent 38µs making 77 calls to PPI::Util::TRUE, avg 491ns/call |
780 | |||||
781 | 77 | 377µs | 154 | 5.43ms | return _is_dereference_operator( $elem->sprevious_sibling() ); # spent 4.27ms making 77 calls to PPI::Element::sprevious_sibling, avg 56µs/call
# spent 1.16ms making 77 calls to Perl::Critic::Utils::_is_dereference_operator, avg 15µs/call |
782 | } | ||||
783 | |||||
784 | #----------------------------------------------------------------------------- | ||||
785 | |||||
786 | # spent 8.42ms (5.44+2.98) within Perl::Critic::Utils::is_class_name which was called 77 times, avg 109µs/call:
# 77 times (5.44ms+2.98ms) by Perl::Critic::Utils::is_function_call at line 834, avg 109µs/call | ||||
787 | 77 | 25µs | my $elem = shift; | ||
788 | 77 | 200µs | 77 | 40µs | return if !$elem; # spent 40µs making 77 calls to PPI::Util::TRUE, avg 517ns/call |
789 | |||||
790 | 77 | 337µs | 154 | 2.94ms | return _is_dereference_operator( $elem->snext_sibling() ) # spent 2.38ms making 77 calls to PPI::Element::snext_sibling, avg 31µs/call
# spent 560µs making 77 calls to Perl::Critic::Utils::_is_dereference_operator, avg 7µs/call |
791 | && !_is_dereference_operator( $elem->sprevious_sibling() ); | ||||
792 | } | ||||
793 | |||||
794 | #----------------------------------------------------------------------------- | ||||
795 | |||||
796 | # spent 1.72ms (908µs+812µs) within Perl::Critic::Utils::_is_dereference_operator which was called 154 times, avg 11µs/call:
# 77 times (468µs+692µs) by Perl::Critic::Utils::is_method_call at line 781, avg 15µs/call
# 77 times (439µs+120µs) by Perl::Critic::Utils::is_class_name at line 790, avg 7µs/call | ||||
797 | 154 | 47µs | my $elem = shift; | ||
798 | 154 | 382µs | 128 | 60µs | return if !$elem; # spent 60µs making 128 calls to PPI::Util::TRUE, avg 471ns/call |
799 | |||||
800 | 128 | 719µs | 168 | 752µs | return $elem->isa('PPI::Token::Operator') && $elem eq q{->}; # spent 617µs making 40 calls to PPI::Element::__eq, avg 15µs/call
# spent 135µs making 128 calls to UNIVERSAL::isa, avg 1µs/call |
801 | } | ||||
802 | |||||
803 | #----------------------------------------------------------------------------- | ||||
804 | |||||
805 | # spent 2.34ms (778µs+1.56) within Perl::Critic::Utils::is_package_declaration which was called 77 times, avg 30µs/call:
# 77 times (778µs+1.56ms) by Perl::Critic::Utils::is_function_call at line 837, avg 30µs/call | ||||
806 | 77 | 25µs | my $elem = shift; | ||
807 | 77 | 184µs | 77 | 35µs | return if !$elem; # spent 35µs making 77 calls to PPI::Util::TRUE, avg 458ns/call |
808 | 77 | 97µs | 77 | 1.39ms | my $stmnt = $elem->statement(); # spent 1.39ms making 77 calls to PPI::Element::statement, avg 18µs/call |
809 | 77 | 192µs | 77 | 39µs | return if !$stmnt; # spent 39µs making 77 calls to PPI::Util::TRUE, avg 509ns/call |
810 | 77 | 416µs | 77 | 97µs | return if !$stmnt->isa('PPI::Statement::Package'); # spent 97µs making 77 calls to UNIVERSAL::isa, avg 1µs/call |
811 | return $stmnt->schild(1) == $elem; | ||||
812 | } | ||||
813 | |||||
814 | #----------------------------------------------------------------------------- | ||||
815 | |||||
816 | # spent 4.84ms (1.07+3.77) within Perl::Critic::Utils::is_subroutine_name which was called 77 times, avg 63µs/call:
# 77 times (1.07ms+3.77ms) by Perl::Critic::Utils::is_function_call at line 835, avg 63µs/call | ||||
817 | 77 | 25µs | my $elem = shift; | ||
818 | 77 | 216µs | 77 | 35µs | return if !$elem; # spent 35µs making 77 calls to PPI::Util::TRUE, avg 455ns/call |
819 | 77 | 113µs | 77 | 2.41ms | my $sib = $elem->sprevious_sibling(); # spent 2.41ms making 77 calls to PPI::Element::sprevious_sibling, avg 31µs/call |
820 | 77 | 209µs | 52 | 34µs | return if !$sib; # spent 34µs making 52 calls to PPI::Util::TRUE, avg 646ns/call |
821 | 52 | 94µs | 52 | 1.19ms | my $stmnt = $elem->statement(); # spent 1.19ms making 52 calls to PPI::Element::statement, avg 23µs/call |
822 | 52 | 134µs | 52 | 27µs | return if !$stmnt; # spent 27µs making 52 calls to PPI::Util::TRUE, avg 515ns/call |
823 | 52 | 313µs | 52 | 76µs | return $stmnt->isa('PPI::Statement::Sub') && $sib eq 'sub'; # spent 76µs making 52 calls to UNIVERSAL::isa, avg 1µs/call |
824 | } | ||||
825 | |||||
826 | #----------------------------------------------------------------------------- | ||||
827 | |||||
828 | # spent 48.3ms (2.32+46.0) within Perl::Critic::Utils::is_function_call which was called 79 times, avg 611µs/call:
# 55 times (1.71ms+37.5ms) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::violates at line 101 of Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm, avg 714µs/call
# 10 times (308µs+3.84ms) by Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::violates at line 50 of Perl/Critic/Policy/BuiltinFunctions/ProhibitStringyEval.pm, avg 415µs/call
# 6 times (130µs+1.91ms) by Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles::violates at line 38 of Perl/Critic/Policy/InputOutput/ProhibitBarewordFileHandles.pm, avg 340µs/call
# 6 times (127µs+1.85ms) by Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen::violates at line 45 of Perl/Critic/Policy/InputOutput/ProhibitTwoArgOpen.pm, avg 330µs/call
# once (22µs+410µs) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic_mutating_substr at line 230 of Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm
# once (22µs+409µs) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic_mutating_func at line 210 of Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm | ||||
829 | 79 | 28µs | my $elem = shift; | ||
830 | 79 | 257µs | 79 | 42µs | return if !$elem; # spent 42µs making 79 calls to PPI::Util::TRUE, avg 537ns/call |
831 | |||||
832 | 79 | 125µs | 79 | 10.0ms | return if is_hash_key($elem); # spent 10.0ms making 79 calls to Perl::Critic::Utils::is_hash_key, avg 127µs/call |
833 | 77 | 129µs | 77 | 6.15ms | return if is_method_call($elem); # spent 6.15ms making 77 calls to Perl::Critic::Utils::is_method_call, avg 80µs/call |
834 | 77 | 132µs | 77 | 8.42ms | return if is_class_name($elem); # spent 8.42ms making 77 calls to Perl::Critic::Utils::is_class_name, avg 109µs/call |
835 | 77 | 128µs | 77 | 4.84ms | return if is_subroutine_name($elem); # spent 4.84ms making 77 calls to Perl::Critic::Utils::is_subroutine_name, avg 63µs/call |
836 | 77 | 112µs | 77 | 5.13ms | return if is_included_module_name($elem); # spent 5.13ms making 77 calls to Perl::Critic::Utils::is_included_module_name, avg 67µs/call |
837 | 77 | 99µs | 77 | 2.34ms | return if is_package_declaration($elem); # spent 2.34ms making 77 calls to Perl::Critic::Utils::is_package_declaration, avg 30µs/call |
838 | 77 | 206µs | 77 | 2.18ms | return if is_perl_bareword($elem); # spent 2.18ms making 77 calls to Perl::Critic::Utils::is_perl_bareword, avg 28µs/call |
839 | 77 | 186µs | 77 | 1.65ms | return if is_perl_filehandle($elem); # spent 1.65ms making 77 calls to Perl::Critic::Utils::is_perl_filehandle, avg 21µs/call |
840 | 77 | 143µs | 77 | 5.20ms | return if is_label_pointer($elem); # spent 5.20ms making 77 calls to Perl::Critic::Utils::is_label_pointer, avg 67µs/call |
841 | |||||
842 | 77 | 194µs | return 1; | ||
843 | } | ||||
844 | |||||
845 | #----------------------------------------------------------------------------- | ||||
846 | |||||
847 | sub is_script { | ||||
848 | my $doc = shift; | ||||
849 | |||||
850 | warnings::warnif( | ||||
851 | 'deprecated', | ||||
852 | 'Perl::Critic::Utils::is_script($doc) deprecated, use $doc->is_program() instead.', ## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars) | ||||
853 | ); | ||||
854 | |||||
855 | return $doc->is_program() | ||||
856 | if blessed($doc) && $doc->isa('Perl::Critic::Document'); | ||||
857 | |||||
858 | return 1 if shebang_line($doc); | ||||
859 | return 1 if _is_PL_file($doc); | ||||
860 | return 0; | ||||
861 | } | ||||
862 | |||||
863 | #----------------------------------------------------------------------------- | ||||
864 | |||||
865 | sub _is_PL_file { ## no critic (NamingConventions::Capitalization) | ||||
866 | my ($doc) = @_; | ||||
867 | return if not $doc->can('filename'); | ||||
868 | my $filename = $doc->filename() || return; | ||||
869 | return 1 if $filename =~ m/[.] PL \z/xms; | ||||
870 | return 0; | ||||
871 | } | ||||
872 | |||||
873 | #----------------------------------------------------------------------------- | ||||
874 | |||||
875 | sub is_in_void_context { | ||||
876 | my ($token) = @_; | ||||
877 | |||||
878 | # If part of a collective, can't be void. | ||||
879 | return if $token->sprevious_sibling(); | ||||
880 | |||||
881 | my $parent = $token->statement()->parent(); | ||||
882 | if ($parent) { | ||||
883 | return if $parent->isa('PPI::Structure::List'); | ||||
884 | return if $parent->isa('PPI::Structure::For'); | ||||
885 | return if $parent->isa('PPI::Structure::Condition'); | ||||
886 | return if $parent->isa('PPI::Structure::Constructor'); | ||||
887 | return if $parent->isa('PPI::Structure::Subscript'); | ||||
888 | |||||
889 | my $grand_parent = $parent->parent(); | ||||
890 | if ($grand_parent) { | ||||
891 | return if | ||||
892 | $parent->isa('PPI::Structure::Block') | ||||
893 | and not $grand_parent->isa('PPI::Statement::Compound'); | ||||
894 | } | ||||
895 | } | ||||
896 | |||||
897 | return $TRUE; | ||||
898 | } | ||||
899 | |||||
900 | #----------------------------------------------------------------------------- | ||||
901 | |||||
902 | # spent 3.17ms (1.36+1.81) within Perl::Critic::Utils::policy_long_name which was called 282 times, avg 11µs/call:
# 141 times (731µs+1.00ms) by Perl::Critic::PolicyFactory::create_policy at line 183 of Perl/Critic/PolicyFactory.pm, avg 12µs/call
# 141 times (630µs+805µs) by Perl::Critic::UserProfile::raw_policy_params at line 78 of Perl/Critic/UserProfile.pm, avg 10µs/call | ||||
903 | 282 | 36µs | my ( $policy_name ) = @_; | ||
904 | 282 | 1.94ms | 846 | 2.16ms | if ( $policy_name !~ m{ \A $POLICY_NAMESPACE }xms ) { # spent 1.52ms making 282 calls to Perl::Critic::Utils::CORE:regcomp, avg 5µs/call
# spent 352µs making 282 calls to Readonly::Scalar::FETCH, avg 1µs/call
# spent 284µs making 282 calls to Perl::Critic::Utils::CORE:match, avg 1µs/call |
905 | $policy_name = $POLICY_NAMESPACE . q{::} . $policy_name; | ||||
906 | } | ||||
907 | 282 | 579µs | return $policy_name; | ||
908 | } | ||||
909 | |||||
910 | #----------------------------------------------------------------------------- | ||||
911 | |||||
912 | # spent 18.1ms (6.60+11.5) within Perl::Critic::Utils::policy_short_name which was called 1291 times, avg 14µs/call:
# 586 times (3.17ms+6.90ms) by Perl::Critic::Policy::get_short_name at line 264 of Perl/Critic/Policy.pm, avg 17µs/call
# 141 times (749µs+1.07ms) by Perl::Critic::UserProfile::policy_is_disabled at line 96 of Perl/Critic/UserProfile.pm, avg 13µs/call
# 141 times (687µs+960µs) by Perl::Critic::UserProfile::policy_is_enabled at line 109 of Perl/Critic/UserProfile.pm, avg 12µs/call
# 141 times (690µs+873µs) by Perl::Critic::PolicyFactory::create_policy at line 184 of Perl/Critic/PolicyFactory.pm, avg 11µs/call
# 141 times (683µs+831µs) by Perl::Critic::UserProfile::raw_policy_params at line 79 of Perl/Critic/UserProfile.pm, avg 11µs/call
# 141 times (628µs+847µs) by Perl::Critic::UserProfile::policy_params at line 64 of Perl/Critic/UserProfile.pm, avg 10µs/call | ||||
913 | 1291 | 348µs | my ( $policy_name ) = @_; | ||
914 | 1291 | 9.60ms | 3873 | 13.2ms | $policy_name =~ s{\A $POLICY_NAMESPACE ::}{}xms; # spent 9.80ms making 1291 calls to Perl::Critic::Utils::CORE:regcomp, avg 8µs/call
# spent 1.77ms making 1291 calls to Readonly::Scalar::FETCH, avg 1µs/call
# spent 1.68ms making 1291 calls to Perl::Critic::Utils::CORE:subst, avg 1µs/call |
915 | 1291 | 2.73ms | return $policy_name; | ||
916 | } | ||||
917 | |||||
918 | #----------------------------------------------------------------------------- | ||||
919 | |||||
920 | # spent 2.86ms (613µs+2.25) within Perl::Critic::Utils::first_arg which was called 66 times, avg 43µs/call:
# 55 times (514µs+1.98ms) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::violates at line 104 of Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm, avg 45µs/call
# 10 times (96µs+242µs) by Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::violates at line 52 of Perl/Critic/Policy/BuiltinFunctions/ProhibitStringyEval.pm, avg 34µs/call
# once (3µs+22µs) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic_mutating_func at line 214 of Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm | ||||
921 | 66 | 21µs | my $elem = shift; | ||
922 | 66 | 90µs | 66 | 2.12ms | my $sib = $elem->snext_sibling(); # spent 2.12ms making 66 calls to PPI::Element::snext_sibling, avg 32µs/call |
923 | 66 | 172µs | 65 | 37µs | return if !$sib; # spent 37µs making 65 calls to PPI::Util::TRUE, avg 565ns/call |
924 | |||||
925 | 65 | 248µs | 65 | 89µs | if ( $sib->isa('PPI::Structure::List') ) { # spent 89µs making 65 calls to UNIVERSAL::isa, avg 1µs/call |
926 | |||||
927 | my $expr = $sib->schild(0); | ||||
928 | return if !$expr; | ||||
929 | return $expr->isa('PPI::Statement') ? $expr->schild(0) : $expr; | ||||
930 | } | ||||
931 | |||||
932 | 65 | 139µs | return $sib; | ||
933 | } | ||||
934 | |||||
935 | #----------------------------------------------------------------------------- | ||||
936 | |||||
937 | # spent 8.72ms (1.45+7.27) within Perl::Critic::Utils::parse_arg_list which was called 18 times, avg 484µs/call:
# 7 times (537µs+2.98ms) by Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::violates at line 48 of Perl/Critic/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm, avg 503µs/call
# 5 times (458µs+2.00ms) by Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles::violates at line 40 of Perl/Critic/Policy/InputOutput/ProhibitBarewordFileHandles.pm, avg 492µs/call
# 5 times (383µs+1.92ms) by Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen::violates at line 50 of Perl/Critic/Policy/InputOutput/ProhibitTwoArgOpen.pm, avg 461µs/call
# once (72µs+361µs) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic_mutating_substr at line 233 of Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm | ||||
938 | 18 | 4µs | my $elem = shift; | ||
939 | 18 | 23µs | 18 | 464µs | my $sib = $elem->snext_sibling(); # spent 464µs making 18 calls to PPI::Element::snext_sibling, avg 26µs/call |
940 | 18 | 50µs | 18 | 10µs | return if !$sib; # spent 10µs making 18 calls to PPI::Util::TRUE, avg 561ns/call |
941 | |||||
942 | 18 | 70µs | 18 | 27µs | if ( $sib->isa('PPI::Structure::List') ) { # spent 27µs making 18 calls to UNIVERSAL::isa, avg 1µs/call |
943 | |||||
944 | #Pull siblings from list | ||||
945 | my @list_contents = $sib->schildren(); | ||||
946 | return if not @list_contents; | ||||
947 | |||||
948 | my @list_expressions; | ||||
949 | foreach my $item (@list_contents) { | ||||
950 | if ( | ||||
951 | is_ppi_expression_or_generic_statement($item) | ||||
952 | ) { | ||||
953 | push | ||||
954 | @list_expressions, | ||||
955 | split_nodes_on_comma( $item->schildren() ); | ||||
956 | } | ||||
957 | else { | ||||
958 | push @list_expressions, $item; | ||||
959 | } | ||||
960 | } | ||||
961 | |||||
962 | return @list_expressions; | ||||
963 | } | ||||
964 | else { | ||||
965 | |||||
966 | #Gather up remaining nodes in the statement | ||||
967 | 18 | 6µs | my $iter = $elem; | ||
968 | 18 | 8µs | my @arg_list = (); | ||
969 | |||||
970 | 18 | 68µs | 36 | 430µs | while ($iter = $iter->snext_sibling() ) { # spent 420µs making 18 calls to PPI::Element::snext_sibling, avg 23µs/call
# spent 10µs making 18 calls to PPI::Util::TRUE, avg 528ns/call |
971 | 120 | 339µs | 126 | 206µs | last if $iter->isa('PPI::Token::Structure') and $iter eq $SCOLON; # spent 128µs making 120 calls to UNIVERSAL::isa, avg 1µs/call
# spent 74µs making 3 calls to PPI::Element::__eq, avg 24µs/call
# spent 4µs making 3 calls to Readonly::Scalar::FETCH, avg 1µs/call |
972 | 117 | 422µs | 217 | 766µs | last if $iter->isa('PPI::Token::Operator') # spent 623µs making 50 calls to Perl::Critic::Utils::precedence_of, avg 12µs/call
# spent 88µs making 117 calls to UNIVERSAL::isa, avg 753ns/call
# spent 55µs making 50 calls to Readonly::Scalar::FETCH, avg 1µs/call |
973 | and $MIN_PRECEDENCE_TO_TERMINATE_PARENLESS_ARG_LIST <= | ||||
974 | precedence_of( $iter ); | ||||
975 | 105 | 415µs | 207 | 3.57ms | push @arg_list, $iter; # spent 3.52ms making 105 calls to PPI::Element::snext_sibling, avg 34µs/call
# spent 52µs making 102 calls to PPI::Util::TRUE, avg 510ns/call |
976 | } | ||||
977 | 18 | 90µs | 18 | 1.80ms | return split_nodes_on_comma( @arg_list ); # spent 1.80ms making 18 calls to Perl::Critic::Utils::split_nodes_on_comma, avg 100µs/call |
978 | } | ||||
979 | } | ||||
980 | |||||
981 | #--------------------------------- | ||||
982 | |||||
983 | # spent 1.80ms (692µs+1.10) within Perl::Critic::Utils::split_nodes_on_comma which was called 18 times, avg 100µs/call:
# 18 times (692µs+1.10ms) by Perl::Critic::Utils::parse_arg_list at line 977, avg 100µs/call | ||||
984 | 18 | 15µs | my @nodes = @_; | ||
985 | |||||
986 | 18 | 4µs | my $i = 0; | ||
987 | 18 | 2µs | my @node_stacks; | ||
988 | 18 | 16µs | for my $node (@nodes) { | ||
989 | 105 | 569µs | 254 | 1.10ms | if ( # spent 886µs making 41 calls to PPI::Element::__eq, avg 22µs/call
# spent 168µs making 172 calls to UNIVERSAL::isa, avg 977ns/call
# spent 50µs making 41 calls to Readonly::Scalar::FETCH, avg 1µs/call |
990 | $node->isa('PPI::Token::Operator') | ||||
991 | and ($node eq $COMMA or $node eq $FATCOMMA) | ||||
992 | ) { | ||||
993 | 38 | 11µs | if (@node_stacks) { | ||
994 | $i++; #Move forward to next 'node stack' | ||||
995 | } | ||||
996 | 38 | 19µs | next; | ||
997 | } elsif ( $node->isa('PPI::Token::QuoteLike::Words' )) { | ||||
998 | my $section = $node->{sections}->[0]; | ||||
999 | my @words = words_from_string(substr $node->content, $section->{position}, $section->{size}); | ||||
1000 | my $loc = $node->location; | ||||
1001 | for my $word (@words) { | ||||
1002 | my $token = PPI::Token::Quote::Single->new(q{'} . $word . q{'}); | ||||
1003 | $token->{_location} = $loc; | ||||
1004 | push @{ $node_stacks[$i++] }, $token; | ||||
1005 | } | ||||
1006 | next; | ||||
1007 | } | ||||
1008 | 67 | 57µs | push @{ $node_stacks[$i] }, $node; | ||
1009 | } | ||||
1010 | 18 | 48µs | return @node_stacks; | ||
1011 | } | ||||
1012 | |||||
1013 | #----------------------------------------------------------------------------- | ||||
1014 | |||||
1015 | # XXX: You must keep the regular expressions in extras/perlcritic.el in sync | ||||
1016 | # if you change these. | ||||
1017 | 1 | 2µs | 1 | 36µs | Readonly::Hash my %FORMAT_OF => ( # spent 36µs making 1 call to Readonly::Hash |
1018 | 1 => "%f:%l:%c:%m\n", | ||||
1019 | 2 => "%f: (%l:%c) %m\n", | ||||
1020 | 3 => "%m at %f line %l\n", | ||||
1021 | 4 => "%m at line %l, column %c. %e. (Severity: %s)\n", | ||||
1022 | 5 => "%f: %m at line %l, column %c. %e. (Severity: %s)\n", | ||||
1023 | 6 => "%m at line %l, near '%r'. (Severity: %s)\n", | ||||
1024 | 7 => "%f: %m at line %l near '%r'. (Severity: %s)\n", | ||||
1025 | 8 => "[%p] %m at line %l, column %c. (Severity: %s)\n", | ||||
1026 | 9 => "[%p] %m at line %l, near '%r'. (Severity: %s)\n", | ||||
1027 | 10 => "%m at line %l, column %c.\n %p (Severity: %s)\n%d\n", | ||||
1028 | 11 => "%m at line %l, near '%r'.\n %p (Severity: %s)\n%d\n", | ||||
1029 | ); | ||||
1030 | |||||
1031 | 1 | 1µs | 1 | 23µs | Readonly::Scalar our $DEFAULT_VERBOSITY => 4; # spent 23µs making 1 call to Readonly::Scalar |
1032 | 1 | 800ns | 1 | 21µs | Readonly::Scalar our $DEFAULT_VERBOSITY_WITH_FILE_NAME => 5; # spent 21µs making 1 call to Readonly::Scalar |
1033 | 1 | 6µs | 3 | 33µs | Readonly::Scalar my $DEFAULT_FORMAT => $FORMAT_OF{$DEFAULT_VERBOSITY}; # spent 27µs making 1 call to Readonly::Scalar
# spent 6µs making 2 calls to Readonly::Scalar::FETCH, avg 3µs/call |
1034 | |||||
1035 | # spent 11µs (8+3) within Perl::Critic::Utils::is_valid_numeric_verbosity which was called:
# once (8µs+3µs) by Perl::Critic::Config::_validate_and_save_verbosity at line 487 of Perl/Critic/Config.pm | ||||
1036 | 1 | 400ns | my ($verbosity) = @_; | ||
1037 | |||||
1038 | 1 | 7µs | 1 | 3µs | return exists $FORMAT_OF{$verbosity}; # spent 3µs making 1 call to Readonly::Hash::EXISTS |
1039 | } | ||||
1040 | |||||
1041 | sub verbosity_to_format { | ||||
1042 | my ($verbosity) = @_; | ||||
1043 | return $DEFAULT_FORMAT if not defined $verbosity; | ||||
1044 | return $FORMAT_OF{abs int $verbosity} || $DEFAULT_FORMAT if is_integer($verbosity); | ||||
1045 | return interpolate( $verbosity ); #Otherwise, treat as a format spec | ||||
1046 | } | ||||
1047 | |||||
1048 | #----------------------------------------------------------------------------- | ||||
1049 | |||||
1050 | 1 | 1µs | 1 | 24µs | Readonly::Hash my %SEVERITY_NUMBER_OF => ( # spent 24µs making 1 call to Readonly::Hash |
1051 | gentle => 5, | ||||
1052 | stern => 4, | ||||
1053 | harsh => 3, | ||||
1054 | cruel => 2, | ||||
1055 | brutal => 1, | ||||
1056 | ); | ||||
1057 | |||||
1058 | Readonly::Array our @SEVERITY_NAMES => #This is exported! | ||||
1059 | sort | ||||
1060 | 1 | 56µs | 22 | 118µs | { $SEVERITY_NUMBER_OF{$a} <=> $SEVERITY_NUMBER_OF{$b} } # spent 69µs making 1 call to Perl::Critic::Utils::CORE:sort
# spent 22µs making 1 call to Readonly::Array
# spent 19µs making 14 calls to Readonly::Hash::FETCH, avg 1µs/call
# spent 6µs making 5 calls to Readonly::Hash::NEXTKEY, avg 1µs/call
# spent 2µs making 1 call to Readonly::Hash::FIRSTKEY |
1061 | keys %SEVERITY_NUMBER_OF; | ||||
1062 | |||||
1063 | sub severity_to_number { | ||||
1064 | my ($severity) = @_; | ||||
1065 | return _normalize_severity( $severity ) if is_integer( $severity ); | ||||
1066 | my $severity_number = $SEVERITY_NUMBER_OF{lc $severity}; | ||||
1067 | |||||
1068 | if ( not defined $severity_number ) { | ||||
1069 | throw_generic qq{Invalid severity: "$severity"}; | ||||
1070 | } | ||||
1071 | |||||
1072 | return $severity_number; | ||||
1073 | } | ||||
1074 | |||||
1075 | sub _normalize_severity { | ||||
1076 | my $s = shift || return $SEVERITY_HIGHEST; | ||||
1077 | $s = $s > $SEVERITY_HIGHEST ? $SEVERITY_HIGHEST : $s; | ||||
1078 | $s = $s < $SEVERITY_LOWEST ? $SEVERITY_LOWEST : $s; | ||||
1079 | return $s; | ||||
1080 | } | ||||
1081 | |||||
1082 | #----------------------------------------------------------------------------- | ||||
1083 | |||||
1084 | 1 | 1µs | 1 | 25µs | Readonly::Array my @SKIP_DIR => qw( CVS RCS .svn _darcs {arch} .bzr .cdv .git .hg .pc _build blib ); # spent 25µs making 1 call to Readonly::Array |
1085 | 1 | 9µs | 3 | 90µs | Readonly::Hash my %SKIP_DIR => hashify( @SKIP_DIR ); # spent 51µs making 1 call to Perl::Critic::Utils::hashify
# spent 38µs making 1 call to Readonly::Hash
# spent 1µs making 1 call to Readonly::Array::FETCHSIZE |
1086 | |||||
1087 | # spent 10.9ms (2.79+8.12) within Perl::Critic::Utils::all_perl_files which was called:
# once (2.79ms+8.12ms) by Perl::Critic::Command::_get_input at line 220 of Perl/Critic/Command.pm | ||||
1088 | |||||
1089 | # Recursively searches a list of directories and returns the paths | ||||
1090 | # to files that seem to be Perl source code. This subroutine was | ||||
1091 | # poached from Test::Perl::Critic. | ||||
1092 | |||||
1093 | 1 | 1µs | my @queue = @_; | ||
1094 | 1 | 400ns | my @code_files = (); | ||
1095 | |||||
1096 | 1 | 700ns | while (@queue) { | ||
1097 | 162 | 57µs | my $file = shift @queue; | ||
1098 | 162 | 803µs | 162 | 529µs | if ( -d $file ) { # spent 529µs making 162 calls to Perl::Critic::Utils::CORE:ftdir, avg 3µs/call |
1099 | 18 | 220µs | 18 | 160µs | opendir my ($dh), $file or next; # spent 160µs making 18 calls to Perl::Critic::Utils::CORE:open_dir, avg 9µs/call |
1100 | 18 | 472µs | 36 | 338µs | my @newfiles = sort readdir $dh; # spent 311µs making 18 calls to Perl::Critic::Utils::CORE:readdir, avg 17µs/call
# spent 28µs making 18 calls to Perl::Critic::Utils::CORE:sort, avg 2µs/call |
1101 | 18 | 92µs | 18 | 56µs | closedir $dh; # spent 56µs making 18 calls to Perl::Critic::Utils::CORE:closedir, avg 3µs/call |
1102 | |||||
1103 | 18 | 125µs | 18 | 349µs | @newfiles = File::Spec->no_upwards(@newfiles); # spent 349µs making 18 calls to File::Spec::Unix::no_upwards, avg 19µs/call |
1104 | 18 | 463µs | 161 | 232µs | @newfiles = grep { not $SKIP_DIR{$_} } @newfiles; # spent 232µs making 161 calls to Readonly::Hash::FETCH, avg 1µs/call |
1105 | 179 | 1.89ms | 644 | 2.13ms | push @queue, map { File::Spec->catfile($file, $_) } @newfiles; # spent 1.41ms making 161 calls to File::Spec::Unix::catfile, avg 9µs/call
# spent 512µs making 161 calls to File::Spec::Unix::catdir, avg 3µs/call
# spent 208µs making 322 calls to File::Spec::Unix::canonpath, avg 645ns/call |
1106 | } | ||||
1107 | |||||
1108 | 162 | 996µs | 450 | 5.04ms | if ( (-f $file) && ! _is_backup($file) && _is_perl($file) ) { # spent 3.99ms making 144 calls to Perl::Critic::Utils::_is_backup, avg 28µs/call
# spent 709µs making 144 calls to Perl::Critic::Utils::_is_perl, avg 5µs/call
# spent 338µs making 162 calls to Perl::Critic::Utils::CORE:ftfile, avg 2µs/call |
1109 | push @code_files, $file; | ||||
1110 | } | ||||
1111 | } | ||||
1112 | 1 | 43µs | return @code_files; | ||
1113 | } | ||||
1114 | |||||
1115 | |||||
1116 | #----------------------------------------------------------------------------- | ||||
1117 | # Decide if it's some sort of backup file | ||||
1118 | |||||
1119 | # spent 3.99ms (3.85+140µs) within Perl::Critic::Utils::_is_backup which was called 144 times, avg 28µs/call:
# 144 times (3.85ms+140µs) by Perl::Critic::Utils::all_perl_files at line 1108, avg 28µs/call | ||||
1120 | 144 | 30µs | my ($file) = @_; | ||
1121 | 144 | 243µs | 144 | 50µs | return 1 if $file =~ m{ [.] swp \z}xms; # spent 50µs making 144 calls to Perl::Critic::Utils::CORE:match, avg 345ns/call |
1122 | 144 | 193µs | 144 | 32µs | return 1 if $file =~ m{ [.] bak \z}xms; # spent 32µs making 144 calls to Perl::Critic::Utils::CORE:match, avg 221ns/call |
1123 | 144 | 3.14ms | 144 | 29µs | return 1 if $file =~ m{ ~ \z}xms; # spent 29µs making 144 calls to Perl::Critic::Utils::CORE:match, avg 204ns/call |
1124 | 144 | 172µs | 144 | 30µs | return 1 if $file =~ m{ \A [#] .+ [#] \z}xms; # spent 30µs making 144 calls to Perl::Critic::Utils::CORE:match, avg 206ns/call |
1125 | 144 | 217µs | return; | ||
1126 | } | ||||
1127 | |||||
1128 | #----------------------------------------------------------------------------- | ||||
1129 | # Returns true if the argument ends with a perl-ish file | ||||
1130 | # extension, or if it has a shebang-line containing 'perl' This | ||||
1131 | # subroutine was also poached from Test::Perl::Critic | ||||
1132 | |||||
1133 | # spent 709µs (549+160) within Perl::Critic::Utils::_is_perl which was called 144 times, avg 5µs/call:
# 144 times (549µs+160µs) by Perl::Critic::Utils::all_perl_files at line 1108, avg 5µs/call | ||||
1134 | 144 | 30µs | my ($file) = @_; | ||
1135 | |||||
1136 | #Check filename extensions | ||||
1137 | 144 | 231µs | 144 | 44µs | return 1 if $file =~ m{ [.] PL \z}xms; # spent 44µs making 144 calls to Perl::Critic::Utils::CORE:match, avg 306ns/call |
1138 | 144 | 485µs | 144 | 116µs | return 1 if $file =~ m{ [.] p[lm] \z}xms; # spent 116µs making 144 calls to Perl::Critic::Utils::CORE:match, avg 804ns/call |
1139 | return 1 if $file =~ m{ [.] t \z}xms; | ||||
1140 | |||||
1141 | #Check for shebang | ||||
1142 | open my $fh, '<', $file or return; | ||||
1143 | my $first = <$fh>; | ||||
1144 | close $fh or throw_generic "unable to close $file: $OS_ERROR"; | ||||
1145 | |||||
1146 | return 1 if defined $first && ( $first =~ m{ \A [#]!.*perl }xms ); | ||||
1147 | return; | ||||
1148 | } | ||||
1149 | |||||
1150 | #----------------------------------------------------------------------------- | ||||
1151 | |||||
1152 | # spent 4.02ms (1.85+2.17) within Perl::Critic::Utils::shebang_line which was called 144 times, avg 28µs/call:
# 144 times (1.85ms+2.17ms) by Perl::Critic::Document::_determine_is_module at line 581 of Perl/Critic/Document.pm, avg 28µs/call | ||||
1153 | 144 | 61µs | my $doc = shift; | ||
1154 | 144 | 461µs | 144 | 1.82ms | my $first_element = $doc->first_element(); # spent 1.82ms making 144 calls to Perl::Critic::Document::AUTOLOAD, avg 13µs/call |
1155 | 144 | 490µs | 144 | 118µs | return if not $first_element; # spent 118µs making 144 calls to PPI::Util::TRUE, avg 816ns/call |
1156 | 144 | 907µs | 144 | 242µs | return if not $first_element->isa('PPI::Token::Comment'); # spent 242µs making 144 calls to UNIVERSAL::isa, avg 2µs/call |
1157 | my $location = $first_element->location(); | ||||
1158 | return if !$location; | ||||
1159 | # The shebang must be the first two characters in the file, according to | ||||
1160 | # http://en.wikipedia.org/wiki/Shebang_(Unix) | ||||
1161 | return if $location->[0] != 1; # line number | ||||
1162 | return if $location->[1] != 1; # column number | ||||
1163 | my $shebang = $first_element->content; | ||||
1164 | return if $shebang !~ m{ \A [#]! }xms; | ||||
1165 | return $shebang; | ||||
1166 | } | ||||
1167 | |||||
1168 | #----------------------------------------------------------------------------- | ||||
1169 | |||||
1170 | # spent 90µs within Perl::Critic::Utils::words_from_string which was called 40 times, avg 2µs/call:
# 27 times (62µs+0s) by Perl::Critic::PolicyParameter::Behavior::StringList::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyParameter/Behavior/StringList.pm:60] at line 51 of Perl/Critic/PolicyParameter/Behavior/StringList.pm, avg 2µs/call
# 5 times (12µs+0s) by Perl::Critic::Config::_validate_and_save_color_severity at line 723 of Perl/Critic/Config.pm, avg 2µs/call
# 5 times (10µs+0s) by Perl::Critic::PolicyParameter::Behavior::Enumeration::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyParameter/Behavior/Enumeration.pm:93] at line 70 of Perl/Critic/PolicyParameter/Behavior/Enumeration.pm, avg 2µs/call
# once (4µs+0s) by Perl::Critic::OptionsProcessor::_init at line 45 of Perl/Critic/OptionsProcessor.pm
# once (1µs+0s) by Perl::Critic::OptionsProcessor::_init at line 51 of Perl/Critic/OptionsProcessor.pm
# once (1µs+0s) by Perl::Critic::OptionsProcessor::_init at line 48 of Perl/Critic/OptionsProcessor.pm | ||||
1171 | 40 | 9µs | my $str = shift; | ||
1172 | |||||
1173 | 40 | 125µs | return split q{ }, $str; # This must be a literal space, not $SPACE | ||
1174 | } | ||||
1175 | |||||
1176 | #----------------------------------------------------------------------------- | ||||
1177 | |||||
1178 | sub is_unchecked_call { | ||||
1179 | my $elem = shift; | ||||
1180 | |||||
1181 | return if not is_function_call( $elem ); | ||||
1182 | |||||
1183 | # check to see if there's an '=' or 'unless' or something before this. | ||||
1184 | if( my $sib = $elem->sprevious_sibling() ){ | ||||
1185 | return if $sib; | ||||
1186 | } | ||||
1187 | |||||
1188 | |||||
1189 | if( my $statement = $elem->statement() ){ | ||||
1190 | |||||
1191 | # "open or die" is OK. | ||||
1192 | # We can't check snext_sibling for 'or' since the next siblings are an | ||||
1193 | # unknown number of arguments to the system call. Instead, check all of | ||||
1194 | # the elements to this statement to see if we find 'or' or '||'. | ||||
1195 | |||||
1196 | my $or_operators = sub { | ||||
1197 | my (undef, $elem) = @_; ## no critic(Variables::ProhibitReusedNames) | ||||
1198 | return if not $elem->isa('PPI::Token::Operator'); | ||||
1199 | return if $elem ne q{or} && $elem ne q{||}; | ||||
1200 | return 1; | ||||
1201 | }; | ||||
1202 | |||||
1203 | return if $statement->find( $or_operators ); | ||||
1204 | |||||
1205 | |||||
1206 | if( my $parent = $elem->statement()->parent() ){ | ||||
1207 | |||||
1208 | # Check if we're in an if( open ) {good} else {bad} condition | ||||
1209 | return if $parent->isa('PPI::Structure::Condition'); | ||||
1210 | |||||
1211 | # Return val could be captured in data structure and checked later | ||||
1212 | return if $parent->isa('PPI::Structure::Constructor'); | ||||
1213 | |||||
1214 | # "die if not ( open() )" - It's in list context. | ||||
1215 | if ( $parent->isa('PPI::Structure::List') ) { | ||||
1216 | if( my $uncle = $parent->sprevious_sibling() ){ | ||||
1217 | return if $uncle; | ||||
1218 | } | ||||
1219 | } | ||||
1220 | } | ||||
1221 | } | ||||
1222 | |||||
1223 | return if _is_fatal($elem); | ||||
1224 | |||||
1225 | # Otherwise, return. this system call is unchecked. | ||||
1226 | return 1; | ||||
1227 | } | ||||
1228 | |||||
1229 | # Based upon autodie 2.10. | ||||
1230 | 52 | 76µs | 52 | 59µs | Readonly::Hash my %AUTODIE_PARAMETER_TO_AFFECTED_BUILTINS_MAP => ( # spent 59µs making 52 calls to Perl::Critic::Utils::hashify, avg 1µs/call |
1231 | # Map builtins to themselves. | ||||
1232 | ( | ||||
1233 | 1 | 97µs | 14 | 1.80ms | map { $_ => { hashify( $_ ) } } # spent 1.74ms making 1 call to Readonly::Hash
# spent 62µs making 13 calls to Perl::Critic::Utils::hashify, avg 5µs/call |
1234 | qw< | ||||
1235 | accept bind binmode chdir chmod close closedir connect | ||||
1236 | dbmclose dbmopen exec fcntl fileno flock fork getsockopt ioctl | ||||
1237 | link listen mkdir msgctl msgget msgrcv msgsnd open opendir | ||||
1238 | pipe read readlink recv rename rmdir seek semctl semget semop | ||||
1239 | send setsockopt shmctl shmget shmread shutdown socketpair | ||||
1240 | symlink sysopen sysread sysseek system syswrite truncate umask | ||||
1241 | unlink | ||||
1242 | > | ||||
1243 | ), | ||||
1244 | |||||
1245 | # Generate these using tools/dump-autodie-tag-contents | ||||
1246 | ':threads' => { hashify( qw< fork > ) }, | ||||
1247 | ':system' => { hashify( qw< exec system > ) }, | ||||
1248 | ':dbm' => { hashify( qw< dbmclose dbmopen > ) }, | ||||
1249 | ':semaphore' => { hashify( qw< semctl semget semop > ) }, | ||||
1250 | ':shm' => { hashify( qw< shmctl shmget shmread > ) }, | ||||
1251 | ':msg' => { hashify( qw< msgctl msgget msgrcv msgsnd > ) }, | ||||
1252 | ':file' => { | ||||
1253 | hashify( | ||||
1254 | qw< | ||||
1255 | binmode chmod close fcntl fileno flock ioctl open sysopen | ||||
1256 | truncate | ||||
1257 | > | ||||
1258 | ) | ||||
1259 | }, | ||||
1260 | ':filesys' => { | ||||
1261 | hashify( | ||||
1262 | qw< | ||||
1263 | chdir closedir link mkdir opendir readlink rename rmdir | ||||
1264 | symlink umask unlink | ||||
1265 | > | ||||
1266 | ) | ||||
1267 | }, | ||||
1268 | ':ipc' => { | ||||
1269 | hashify( | ||||
1270 | qw< | ||||
1271 | msgctl msgget msgrcv msgsnd pipe semctl semget semop shmctl | ||||
1272 | shmget shmread | ||||
1273 | > | ||||
1274 | ) | ||||
1275 | }, | ||||
1276 | ':socket' => { | ||||
1277 | hashify( | ||||
1278 | qw< | ||||
1279 | accept bind connect getsockopt listen recv send setsockopt | ||||
1280 | shutdown socketpair | ||||
1281 | > | ||||
1282 | ) | ||||
1283 | }, | ||||
1284 | ':io' => { | ||||
1285 | hashify( | ||||
1286 | qw< | ||||
1287 | accept bind binmode chdir chmod close closedir connect | ||||
1288 | dbmclose dbmopen fcntl fileno flock getsockopt ioctl link | ||||
1289 | listen mkdir msgctl msgget msgrcv msgsnd open opendir pipe | ||||
1290 | read readlink recv rename rmdir seek semctl semget semop send | ||||
1291 | setsockopt shmctl shmget shmread shutdown socketpair symlink | ||||
1292 | sysopen sysread sysseek syswrite truncate umask unlink | ||||
1293 | > | ||||
1294 | ) | ||||
1295 | }, | ||||
1296 | ':default' => { | ||||
1297 | hashify( | ||||
1298 | qw< | ||||
1299 | accept bind binmode chdir chmod close closedir connect | ||||
1300 | dbmclose dbmopen fcntl fileno flock fork getsockopt ioctl link | ||||
1301 | listen mkdir msgctl msgget msgrcv msgsnd open opendir pipe | ||||
1302 | read readlink recv rename rmdir seek semctl semget semop send | ||||
1303 | setsockopt shmctl shmget shmread shutdown socketpair symlink | ||||
1304 | sysopen sysread sysseek syswrite truncate umask unlink | ||||
1305 | > | ||||
1306 | ) | ||||
1307 | }, | ||||
1308 | ':all' => { | ||||
1309 | hashify( | ||||
1310 | qw< | ||||
1311 | accept bind binmode chdir chmod close closedir connect | ||||
1312 | dbmclose dbmopen exec fcntl fileno flock fork getsockopt ioctl | ||||
1313 | link listen mkdir msgctl msgget msgrcv msgsnd open opendir | ||||
1314 | pipe read readlink recv rename rmdir seek semctl semget semop | ||||
1315 | send setsockopt shmctl shmget shmread shutdown socketpair | ||||
1316 | symlink sysopen sysread sysseek system syswrite truncate umask | ||||
1317 | unlink | ||||
1318 | > | ||||
1319 | ) | ||||
1320 | }, | ||||
1321 | ); | ||||
1322 | |||||
1323 | sub _is_fatal { | ||||
1324 | my ($elem) = @_; | ||||
1325 | |||||
1326 | my $top = $elem->top(); | ||||
1327 | return if not $top->isa('PPI::Document'); | ||||
1328 | |||||
1329 | my $includes = $top->find('PPI::Statement::Include'); | ||||
1330 | return if not $includes; | ||||
1331 | |||||
1332 | for my $include (@{$includes}) { | ||||
1333 | next if 'use' ne $include->type(); | ||||
1334 | |||||
1335 | if ('Fatal' eq $include->module()) { | ||||
1336 | my @args = parse_arg_list($include->schild(1)); | ||||
1337 | foreach my $arg (@args) { | ||||
1338 | return $TRUE if $arg->[0]->isa('PPI::Token::Quote') && $elem eq $arg->[0]->string(); | ||||
1339 | } | ||||
1340 | } | ||||
1341 | elsif ('Fatal::Exception' eq $include->module()) { | ||||
1342 | my @args = parse_arg_list($include->schild(1)); | ||||
1343 | shift @args; # skip exception class name | ||||
1344 | foreach my $arg (@args) { | ||||
1345 | return $TRUE if $arg->[0]->isa('PPI::Token::Quote') && $elem eq $arg->[0]->string(); | ||||
1346 | } | ||||
1347 | } | ||||
1348 | elsif ('autodie' eq $include->pragma()) { | ||||
1349 | return _is_covered_by_autodie($elem, $include); | ||||
1350 | } | ||||
1351 | } | ||||
1352 | |||||
1353 | return; | ||||
1354 | } | ||||
1355 | |||||
1356 | sub _is_covered_by_autodie { | ||||
1357 | my ($elem, $include) = @_; | ||||
1358 | |||||
1359 | my @args = parse_arg_list($include->schild(1)); | ||||
1360 | |||||
1361 | if (@args) { | ||||
1362 | foreach my $arg (@args) { | ||||
1363 | my $builtins = | ||||
1364 | $AUTODIE_PARAMETER_TO_AFFECTED_BUILTINS_MAP{ | ||||
1365 | $arg->[0]->string | ||||
1366 | }; | ||||
1367 | |||||
1368 | return $TRUE if $builtins and $builtins->{$elem->content()}; | ||||
1369 | } | ||||
1370 | } | ||||
1371 | else { | ||||
1372 | my $builtins = | ||||
1373 | $AUTODIE_PARAMETER_TO_AFFECTED_BUILTINS_MAP{':default'}; | ||||
1374 | |||||
1375 | return $TRUE if $builtins and $builtins->{$elem->content()}; | ||||
1376 | } | ||||
1377 | |||||
1378 | return; | ||||
1379 | } | ||||
1380 | |||||
1381 | 1 | 106µs | 1; | ||
1382 | |||||
1383 | __END__ | ||||
# spent 56µs within Perl::Critic::Utils::CORE:closedir which was called 18 times, avg 3µs/call:
# 18 times (56µs+0s) by Perl::Critic::Utils::all_perl_files at line 1101, avg 3µs/call | |||||
# spent 529µs within Perl::Critic::Utils::CORE:ftdir which was called 162 times, avg 3µs/call:
# 162 times (529µs+0s) by Perl::Critic::Utils::all_perl_files at line 1098, avg 3µs/call | |||||
# spent 338µs within Perl::Critic::Utils::CORE:ftfile which was called 162 times, avg 2µs/call:
# 162 times (338µs+0s) by Perl::Critic::Utils::all_perl_files at line 1108, avg 2µs/call | |||||
# spent 652µs (635+17) within Perl::Critic::Utils::CORE:match which was called 1161 times, avg 562ns/call:
# 282 times (284µs+0s) by Perl::Critic::Utils::policy_long_name at line 904, avg 1µs/call
# 144 times (116µs+0s) by Perl::Critic::Utils::_is_perl at line 1138, avg 804ns/call
# 144 times (50µs+0s) by Perl::Critic::Utils::_is_backup at line 1121, avg 345ns/call
# 144 times (44µs+0s) by Perl::Critic::Utils::_is_perl at line 1137, avg 306ns/call
# 144 times (32µs+0s) by Perl::Critic::Utils::_is_backup at line 1122, avg 221ns/call
# 144 times (30µs+0s) by Perl::Critic::Utils::_is_backup at line 1124, avg 206ns/call
# 144 times (29µs+0s) by Perl::Critic::Utils::_is_backup at line 1123, avg 204ns/call
# 12 times (45µs+17µs) by Perl::Critic::Utils::is_label_pointer at line 771, avg 5µs/call
# 3 times (5µs+0s) by Perl::Critic::Utils::is_integer at line 756, avg 2µs/call | |||||
# spent 160µs within Perl::Critic::Utils::CORE:open_dir which was called 18 times, avg 9µs/call:
# 18 times (160µs+0s) by Perl::Critic::Utils::all_perl_files at line 1099, avg 9µs/call | |||||
# spent 311µs within Perl::Critic::Utils::CORE:readdir which was called 18 times, avg 17µs/call:
# 18 times (311µs+0s) by Perl::Critic::Utils::all_perl_files at line 1100, avg 17µs/call | |||||
# spent 11.3ms (9.21+2.12) within Perl::Critic::Utils::CORE:regcomp which was called 1573 times, avg 7µs/call:
# 1291 times (8.04ms+1.77ms) by Perl::Critic::Utils::policy_short_name at line 914, avg 8µs/call
# 282 times (1.17ms+352µs) by Perl::Critic::Utils::policy_long_name at line 904, avg 5µs/call | |||||
sub Perl::Critic::Utils::CORE:sort; # opcode | |||||
sub Perl::Critic::Utils::CORE:subst; # opcode |