← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:10 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Utils.pm
StatementsExecuted 216279 statements in 535ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1431944307ms1.47sPerl::Critic::Utils::::is_hash_keyPerl::Critic::Utils::is_hash_key
1431911154ms657msPerl::Critic::Utils::::_is_followed_by_parensPerl::Critic::Utils::_is_followed_by_parens
1573219.21ms11.3msPerl::Critic::Utils::::CORE:regcompPerl::Critic::Utils::CORE:regcomp (opcode)
1291636.60ms18.1msPerl::Critic::Utils::::policy_short_namePerl::Critic::Utils::policy_short_name
77115.44ms8.42msPerl::Critic::Utils::::is_class_namePerl::Critic::Utils::is_class_name
22267354.41ms4.74msPerl::Critic::Utils::::hashifyPerl::Critic::Utils::hashify
144113.85ms3.99msPerl::Critic::Utils::::_is_backupPerl::Critic::Utils::_is_backup
1112.79ms10.9msPerl::Critic::Utils::::all_perl_filesPerl::Critic::Utils::all_perl_files
79642.32ms48.3msPerl::Critic::Utils::::is_function_callPerl::Critic::Utils::is_function_call
144111.85ms4.02msPerl::Critic::Utils::::shebang_linePerl::Critic::Utils::shebang_line
1300211.68ms1.68msPerl::Critic::Utils::::CORE:substPerl::Critic::Utils::CORE:subst (opcode)
18441.45ms8.72msPerl::Critic::Utils::::parse_arg_listPerl::Critic::Utils::parse_arg_list
282221.36ms3.17msPerl::Critic::Utils::::policy_long_namePerl::Critic::Utils::policy_long_name
154211.23ms1.77msPerl::Critic::Utils::::_name_for_sub_or_stringified_elementPerl::Critic::Utils::_name_for_sub_or_stringified_element
77111.17ms5.20msPerl::Critic::Utils::::is_label_pointerPerl::Critic::Utils::is_label_pointer
77111.07ms4.84msPerl::Critic::Utils::::is_subroutine_namePerl::Critic::Utils::is_subroutine_name
15421908┬Ás1.72msPerl::Critic::Utils::::_is_dereference_operatorPerl::Critic::Utils::_is_dereference_operator
7711905┬Ás2.18msPerl::Critic::Utils::::is_perl_barewordPerl::Critic::Utils::is_perl_bareword
111842┬Ás1.14msPerl::Critic::Utils::::BEGIN@22Perl::Critic::Utils::BEGIN@22
7711832┬Ás5.13msPerl::Critic::Utils::::is_included_module_namePerl::Critic::Utils::is_included_module_name
111807┬Ás1.01msPerl::Critic::Utils::::BEGIN@26Perl::Critic::Utils::BEGIN@26
7711778┬Ás2.34msPerl::Critic::Utils::::is_package_declarationPerl::Critic::Utils::is_package_declaration
7711760┬Ás1.65msPerl::Critic::Utils::::is_perl_filehandlePerl::Critic::Utils::is_perl_filehandle
1811692┬Ás1.80msPerl::Critic::Utils::::split_nodes_on_commaPerl::Critic::Utils::split_nodes_on_comma
7711679┬Ás6.15msPerl::Critic::Utils::::is_method_callPerl::Critic::Utils::is_method_call
116191635┬Ás652┬ÁsPerl::Critic::Utils::::CORE:matchPerl::Critic::Utils::CORE:match (opcode)
6632613┬Ás2.86msPerl::Critic::Utils::::first_argPerl::Critic::Utils::first_arg
14411549┬Ás709┬ÁsPerl::Critic::Utils::::_is_perlPerl::Critic::Utils::_is_perl
16211529┬Ás529┬ÁsPerl::Critic::Utils::::CORE:ftdirPerl::Critic::Utils::CORE:ftdir (opcode)
5564482┬Ás669┬ÁsPerl::Critic::Utils::::precedence_ofPerl::Critic::Utils::precedence_of
111346┬Ás48.0msPerl::Critic::Utils::::BEGIN@23Perl::Critic::Utils::BEGIN@23
16211338┬Ás338┬ÁsPerl::Critic::Utils::::CORE:ftfilePerl::Critic::Utils::CORE:ftfile (opcode)
111334┬Ás6.76msPerl::Critic::Utils::::BEGIN@25Perl::Critic::Utils::BEGIN@25
111326┬Ás411┬ÁsPerl::Critic::Utils::::BEGIN@21Perl::Critic::Utils::BEGIN@21
1811311┬Ás311┬ÁsPerl::Critic::Utils::::CORE:readdirPerl::Critic::Utils::CORE:readdir (opcode)
1811160┬Ás160┬ÁsPerl::Critic::Utils::::CORE:open_dirPerl::Critic::Utils::CORE:open_dir (opcode)
111102┬Ás106┬ÁsPerl::Critic::Utils::::_build_globals_without_sigilsPerl::Critic::Utils::_build_globals_without_sigils
406490┬Ás90┬ÁsPerl::Critic::Utils::::words_from_stringPerl::Critic::Utils::words_from_string
192178┬Ás96┬ÁsPerl::Critic::Utils::::CORE:sortPerl::Critic::Utils::CORE:sort (opcode)
181156┬Ás56┬ÁsPerl::Critic::Utils::::CORE:closedirPerl::Critic::Utils::CORE:closedir (opcode)
11114┬Ás14┬ÁsPerl::Critic::Utils::::BEGIN@13Perl::Critic::Utils::BEGIN@13
33113┬Ás18┬ÁsPerl::Critic::Utils::::is_integerPerl::Critic::Utils::is_integer
11110┬Ás15┬ÁsPerl::Critic::Utils::::BEGIN@15Perl::Critic::Utils::BEGIN@15
1118┬Ás11┬ÁsPerl::Critic::Utils::::is_valid_numeric_verbosityPerl::Critic::Utils::is_valid_numeric_verbosity
1117┬Ás12┬ÁsPerl::Critic::Utils::::BEGIN@28Perl::Critic::Utils::BEGIN@28
1117┬Ás25┬ÁsPerl::Critic::Utils::::BEGIN@16Perl::Critic::Utils::BEGIN@16
1116┬Ás24┬ÁsPerl::Critic::Utils::::BEGIN@18Perl::Critic::Utils::BEGIN@18
1116┬Ás356┬ÁsPerl::Critic::Utils::::BEGIN@19Perl::Critic::Utils::BEGIN@19
1116┬Ás17┬ÁsPerl::Critic::Utils::::BEGIN@14Perl::Critic::Utils::BEGIN@14
1113┬Ás3┬ÁsPerl::Critic::Utils::::BEGIN@20Perl::Critic::Utils::BEGIN@20
0000s0sPerl::Critic::Utils::::__ANON__[:1201]Perl::Critic::Utils::__ANON__[:1201]
0000s0sPerl::Critic::Utils::::_is_PL_filePerl::Critic::Utils::_is_PL_file
0000s0sPerl::Critic::Utils::::_is_covered_by_autodiePerl::Critic::Utils::_is_covered_by_autodie
0000s0sPerl::Critic::Utils::::_is_fatalPerl::Critic::Utils::_is_fatal
0000s0sPerl::Critic::Utils::::_normalize_severityPerl::Critic::Utils::_normalize_severity
0000s0sPerl::Critic::Utils::::find_keywordsPerl::Critic::Utils::find_keywords
0000s0sPerl::Critic::Utils::::interpolatePerl::Critic::Utils::interpolate
0000s0sPerl::Critic::Utils::::is_in_void_contextPerl::Critic::Utils::is_in_void_context
0000s0sPerl::Critic::Utils::::is_perl_builtinPerl::Critic::Utils::is_perl_builtin
0000s0sPerl::Critic::Utils::::is_perl_builtin_with_list_contextPerl::Critic::Utils::is_perl_builtin_with_list_context
0000s0sPerl::Critic::Utils::::is_perl_builtin_with_multiple_argumentsPerl::Critic::Utils::is_perl_builtin_with_multiple_arguments
0000s0sPerl::Critic::Utils::::is_perl_builtin_with_no_argumentsPerl::Critic::Utils::is_perl_builtin_with_no_arguments
0000s0sPerl::Critic::Utils::::is_perl_builtin_with_one_argumentPerl::Critic::Utils::is_perl_builtin_with_one_argument
0000s0sPerl::Critic::Utils::::is_perl_builtin_with_optional_argumentPerl::Critic::Utils::is_perl_builtin_with_optional_argument
0000s0sPerl::Critic::Utils::::is_perl_builtin_with_zero_and_or_one_argumentsPerl::Critic::Utils::is_perl_builtin_with_zero_and_or_one_arguments
0000s0sPerl::Critic::Utils::::is_perl_globalPerl::Critic::Utils::is_perl_global
0000s0sPerl::Critic::Utils::::is_qualified_namePerl::Critic::Utils::is_qualified_name
0000s0sPerl::Critic::Utils::::is_scriptPerl::Critic::Utils::is_script
0000s0sPerl::Critic::Utils::::is_unchecked_callPerl::Critic::Utils::is_unchecked_call
0000s0sPerl::Critic::Utils::::severity_to_numberPerl::Critic::Utils::severity_to_number
0000s0sPerl::Critic::Utils::::verbosity_to_formatPerl::Critic::Utils::verbosity_to_format
Call graph for these subroutines as a Graphviz dot language file.
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
11package Perl::Critic::Utils;
12
13236┬Ás114┬Á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
use 5.006001;
# spent 14┬Ás making 1 call to Perl::Critic::Utils::BEGIN@13
14235┬Ás228┬Á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
use strict;
# spent 17┬Ás making 1 call to Perl::Critic::Utils::BEGIN@14 # spent 11┬Ás making 1 call to strict::import
15218┬Ás220┬Á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
use warnings;
# spent 15┬Ás making 1 call to Perl::Critic::Utils::BEGIN@15 # spent 5┬Ás making 1 call to warnings::import
16220┬Ás244┬Á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
use Readonly;
# spent 25┬Ás making 1 call to Perl::Critic::Utils::BEGIN@16 # spent 19┬Ás making 1 call to Exporter::import
17
18219┬Ás243┬Á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
use Carp qw( confess );
# spent 24┬Ás making 1 call to Perl::Critic::Utils::BEGIN@18 # spent 18┬Ás making 1 call to Exporter::import
19221┬Ás2705┬Á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
use English qw(-no_match_vars);
# spent 356┬Ás making 1 call to Perl::Critic::Utils::BEGIN@19 # spent 350┬Ás making 1 call to English::import
20217┬Ás13┬Á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
use File::Spec qw();
# spent 3┬Ás making 1 call to Perl::Critic::Utils::BEGIN@20
21285┬Ás2462┬Á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
use Scalar::Util qw( blessed );
# spent 411┬Ás making 1 call to Perl::Critic::Utils::BEGIN@21 # spent 50┬Ás making 1 call to Exporter::import
22285┬Ás11.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
use B::Keywords qw();
# spent 1.14ms making 1 call to Perl::Critic::Utils::BEGIN@22
232108┬Ás148.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
use PPI::Token::Quote::Single;
# spent 48.0ms making 1 call to Perl::Critic::Utils::BEGIN@23
24
252183┬Ás26.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
use Perl::Critic::Exception::Fatal::Generic qw{ throw_generic };
# spent 6.76ms making 1 call to Perl::Critic::Utils::BEGIN@25 # spent 49┬Ás making 1 call to Exporter::import
26283┬Ás21.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
use Perl::Critic::Utils::PPI qw< is_ppi_expression_or_generic_statement >;
# spent 1.01ms making 1 call to Perl::Critic::Utils::BEGIN@26 # spent 42┬Ás making 1 call to Exporter::import
27
2823.72ms217┬Á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
use Exporter 'import';
# spent 12┬Ás making 1 call to Perl::Critic::Utils::BEGIN@28 # spent 5┬Ás making 1 call to Exporter::import
29
301700nsour $VERSION = '1.121';
31
32#-----------------------------------------------------------------------------
33# Exportable symbols here.
34
3514┬Ás175┬ÁsReadonly::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.
1111118┬Ás67157┬ÁsReadonly::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
1141144┬Ás67392┬ÁsReadonly::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
183111┬Ás159┬ÁsReadonly::Scalar our $POLICY_NAMESPACE => 'Perl::Critic::Policy';
# spent 59┬Ás making 1 call to Readonly::Scalar
184
185#-----------------------------------------------------------------------------
186
18711┬Ás121┬ÁsReadonly::Scalar our $SEVERITY_HIGHEST => 5;
# spent 21┬Ás making 1 call to Readonly::Scalar
18811┬Ás119┬ÁsReadonly::Scalar our $SEVERITY_HIGH => 4;
# spent 19┬Ás making 1 call to Readonly::Scalar
1891900ns119┬ÁsReadonly::Scalar our $SEVERITY_MEDIUM => 3;
# spent 19┬Ás making 1 call to Readonly::Scalar
1901800ns119┬ÁsReadonly::Scalar our $SEVERITY_LOW => 2;
# spent 19┬Ás making 1 call to Readonly::Scalar
1911800ns119┬ÁsReadonly::Scalar our $SEVERITY_LOWEST => 1;
# spent 19┬Ás making 1 call to Readonly::Scalar
192
193#-----------------------------------------------------------------------------
194
1951800ns119┬ÁsReadonly::Scalar our $COMMA => q{,};
# spent 19┬Ás making 1 call to Readonly::Scalar
1961800ns119┬ÁsReadonly::Scalar our $EQUAL => q{=};
# spent 19┬Ás making 1 call to Readonly::Scalar
1971900ns128┬ÁsReadonly::Scalar our $FATCOMMA => q{=>};
# spent 28┬Ás making 1 call to Readonly::Scalar
19811┬Ás120┬ÁsReadonly::Scalar our $COLON => q{:};
# spent 20┬Ás making 1 call to Readonly::Scalar
1991800ns120┬ÁsReadonly::Scalar our $SCOLON => q{;};
# spent 20┬Ás making 1 call to Readonly::Scalar
2001900ns120┬ÁsReadonly::Scalar our $QUOTE => q{'};
# spent 20┬Ás making 1 call to Readonly::Scalar
20111┬Ás121┬ÁsReadonly::Scalar our $DQUOTE => q{"};
# spent 21┬Ás making 1 call to Readonly::Scalar
2021900ns130┬ÁsReadonly::Scalar our $BACKTICK => q{`};
# spent 30┬Ás making 1 call to Readonly::Scalar
2031900ns120┬ÁsReadonly::Scalar our $PERIOD => q{.};
# spent 20┬Ás making 1 call to Readonly::Scalar
2041900ns120┬ÁsReadonly::Scalar our $PIPE => q{|};
# spent 20┬Ás making 1 call to Readonly::Scalar
2051900ns122┬ÁsReadonly::Scalar our $SPACE => q{ };
# spent 22┬Ás making 1 call to Readonly::Scalar
2061900ns120┬ÁsReadonly::Scalar our $SLASH => q{/};
# spent 20┬Ás making 1 call to Readonly::Scalar
2071800ns129┬ÁsReadonly::Scalar our $BSLASH => q{\\};
# spent 29┬Ás making 1 call to Readonly::Scalar
2081800ns119┬ÁsReadonly::Scalar our $LEFT_PAREN => q{(};
# spent 19┬Ás making 1 call to Readonly::Scalar
2091800ns119┬ÁsReadonly::Scalar our $RIGHT_PAREN => q{)};
# spent 19┬Ás making 1 call to Readonly::Scalar
2101900ns119┬ÁsReadonly::Scalar our $EMPTY => q{};
# spent 19┬Ás making 1 call to Readonly::Scalar
21111┬Ás119┬ÁsReadonly::Scalar our $TRUE => 1;
# spent 19┬Ás making 1 call to Readonly::Scalar
2121900ns119┬ÁsReadonly::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
22313┬Ás1124┬ÁsReadonly::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
32113┬Ás234┬ÁsReadonly::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
sub hashify { ## no critic (ArgUnpacking)
3272221.47ms256328┬Á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
332sub interpolate {
333 my ( $literal ) = @_;
334 return eval "\"$literal\"" || confess $EVAL_ERROR; ## no critic (StringyEval);
335}
336
337#-----------------------------------------------------------------------------
338
339sub 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
sub _name_for_sub_or_stringified_element {
35015431┬Ás my $elem = shift;
351
352154946┬Ás308329┬Á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
356154486┬Ás154212┬Á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
362130┬Ás2336┬ÁsReadonly::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
364sub 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
37317┬Ás287┬ÁsReadonly::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
sub is_perl_bareword {
3767725┬Ás my $elem = shift;
37777197┬Ás7736┬Ás return if !$elem;
# spent 36┬Ás making 77 calls to PPI::Util::TRUE, avg 468ns/call
378
37977604┬Ás1541.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
sub _build_globals_without_sigils {
385 # B::Keywords as of 1.08 forgot $\
386 my @globals =
387147┬Á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
3941700ns foreach my $filehandle (@B::Keywords::Filehandles) {
395920┬Ás94┬Ás (my $stripped = $filehandle) =~ s< \A [*] ><>xms;
# spent 4┬Ás making 9 calls to Perl::Critic::Utils::CORE:subst, avg 444ns/call
39695┬Ás push @globals, $stripped;
397 }
398
399134┬Ás return @globals;
400}
401
402115┬Ás2222┬ÁsReadonly::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
404168┬Ás3799┬ÁsReadonly::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
406sub 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
41613┬Ás236┬ÁsReadonly::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
sub is_perl_filehandle {
4197726┬Ás my $elem = shift;
42077211┬Ás7735┬Ás return if !$elem;
# spent 35┬Ás making 77 calls to PPI::Util::TRUE, avg 460ns/call
421
42277413┬Ás154855┬Á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
42915┬Ás252┬ÁsReadonly::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 print
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
464sub 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
477162┬Ás32154┬ÁsReadonly::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
545sub 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
55714┬Ás246┬ÁsReadonly::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
586sub 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
59815┬Ás261┬ÁsReadonly::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
638sub 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)
651Readonly::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{ $_ } }
65511.18ms529918┬Á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
660sub 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
672sub 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
688sub 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
sub precedence_of {
6995515┬Ás my $elem = shift;
70055113┬Ás5023┬Ás return if !$elem;
# spent 23┬Ás making 50 calls to PPI::Util::TRUE, avg 464ns/call
70155300┬Ás105164┬Á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
sub is_hash_key {
707143193.01ms my $elem = shift;
7081431941.1ms143197.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
7111431921.9ms14319657ms 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;
7141158412.7ms1158447.4ms my $parent = $elem->parent();
# spent 47.4ms making 11584 calls to PPI::Element::parent, avg 4┬Ás/call
7151158440.4ms115846.81ms return if !$parent;
# spent 6.81ms making 11584 calls to PPI::Util::TRUE, avg 588ns/call
7161158411.7ms1158448.9ms my $grandparent = $parent->parent();
# spent 48.9ms making 11584 calls to PPI::Element::parent, avg 4┬Ás/call
7171158427.1ms115846.48ms return if !$grandparent;
# spent 6.48ms making 11584 calls to PPI::Util::TRUE, avg 559ns/call
7181158444.0ms1158413.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);
7221139911.3ms11399338ms my $sib = $elem->snext_sibling();
# spent 338ms making 11399 calls to PPI::Element::snext_sibling, avg 30┬Ás/call
7231139933.2ms112606.65ms return if !$sib;
# spent 6.65ms making 11260 calls to PPI::Util::TRUE, avg 591ns/call
7241126036.6ms1216431.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
7261075829.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
sub _is_followed_by_parens {
732143191.87ms my $elem = shift;
7331431942.3ms143195.71ms return if !$elem;
# spent 5.71ms making 14319 calls to PPI::Util::TRUE, avg 399ns/call
734
7351431958.0ms28319469ms 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
7361400070.8ms1400029.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
sub is_included_module_name {
7427723┬Ás my $elem = shift;
74377201┬Ás7734┬Ás return if !$elem;
# spent 34┬Ás making 77 calls to PPI::Util::TRUE, avg 442ns/call
74477108┬Ás774.12ms my $stmnt = $elem->statement();
# spent 4.12ms making 77 calls to PPI::Element::statement, avg 54┬Ás/call
74577196┬Ás7739┬Ás return if !$stmnt;
# spent 39┬Ás making 77 calls to PPI::Util::TRUE, avg 509ns/call
74677425┬Ás77106┬Á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
sub is_integer {
7533500ns my ($value) = @_;
7543600ns return 0 if not defined $value;
755
756320┬Ás35┬Á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
sub is_label_pointer {
7627726┬Ás my $elem = shift;
76377196┬Ás7734┬Ás return if !$elem;
# spent 34┬Ás making 77 calls to PPI::Util::TRUE, avg 445ns/call
764
76577106┬Ás771.43ms my $statement = $elem->statement();
# spent 1.43ms making 77 calls to PPI::Element::statement, avg 19┬Ás/call
76677200┬Ás7740┬Ás return if !$statement;
# spent 40┬Ás making 77 calls to PPI::Util::TRUE, avg 514ns/call
767
76877116┬Ás772.35ms my $psib = $elem->sprevious_sibling();
# spent 2.35ms making 77 calls to PPI::Element::sprevious_sibling, avg 31┬Ás/call
76977202┬Ás5232┬Ás return if !$psib;
# spent 32┬Ás making 52 calls to PPI::Util::TRUE, avg 625ns/call
770
77152377┬Ás76158┬Á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
sub is_method_call {
7787725┬Ás my $elem = shift;
77977207┬Ás7738┬Ás return if !$elem;
# spent 38┬Ás making 77 calls to PPI::Util::TRUE, avg 491ns/call
780
78177377┬Ás1545.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
sub is_class_name {
7877725┬Ás my $elem = shift;
78877200┬Ás7740┬Ás return if !$elem;
# spent 40┬Ás making 77 calls to PPI::Util::TRUE, avg 517ns/call
789
79077337┬Ás1542.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
sub _is_dereference_operator {
79715447┬Ás my $elem = shift;
798154382┬Ás12860┬Ás return if !$elem;
# spent 60┬Ás making 128 calls to PPI::Util::TRUE, avg 471ns/call
799
800128719┬Ás168752┬Á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
sub is_package_declaration {
8067725┬Ás my $elem = shift;
80777184┬Ás7735┬Ás return if !$elem;
# spent 35┬Ás making 77 calls to PPI::Util::TRUE, avg 458ns/call
8087797┬Ás771.39ms my $stmnt = $elem->statement();
# spent 1.39ms making 77 calls to PPI::Element::statement, avg 18┬Ás/call
80977192┬Ás7739┬Ás return if !$stmnt;
# spent 39┬Ás making 77 calls to PPI::Util::TRUE, avg 509ns/call
81077416┬Ás7797┬Á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
sub is_subroutine_name {
8177725┬Ás my $elem = shift;
81877216┬Ás7735┬Ás return if !$elem;
# spent 35┬Ás making 77 calls to PPI::Util::TRUE, avg 455ns/call
81977113┬Ás772.41ms my $sib = $elem->sprevious_sibling();
# spent 2.41ms making 77 calls to PPI::Element::sprevious_sibling, avg 31┬Ás/call
82077209┬Ás5234┬Ás return if !$sib;
# spent 34┬Ás making 52 calls to PPI::Util::TRUE, avg 646ns/call
8215294┬Ás521.19ms my $stmnt = $elem->statement();
# spent 1.19ms making 52 calls to PPI::Element::statement, avg 23┬Ás/call
82252134┬Ás5227┬Ás return if !$stmnt;
# spent 27┬Ás making 52 calls to PPI::Util::TRUE, avg 515ns/call
82352313┬Ás5276┬Á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
sub is_function_call {
8297928┬Ás my $elem = shift;
83079257┬Ás7942┬Ás return if !$elem;
# spent 42┬Ás making 79 calls to PPI::Util::TRUE, avg 537ns/call
831
83279125┬Ás7910.0ms return if is_hash_key($elem);
# spent 10.0ms making 79 calls to Perl::Critic::Utils::is_hash_key, avg 127┬Ás/call
83377129┬Ás776.15ms return if is_method_call($elem);
# spent 6.15ms making 77 calls to Perl::Critic::Utils::is_method_call, avg 80┬Ás/call
83477132┬Ás778.42ms return if is_class_name($elem);
# spent 8.42ms making 77 calls to Perl::Critic::Utils::is_class_name, avg 109┬Ás/call
83577128┬Ás774.84ms return if is_subroutine_name($elem);
# spent 4.84ms making 77 calls to Perl::Critic::Utils::is_subroutine_name, avg 63┬Ás/call
83677112┬Ás775.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
8377799┬Ás772.34ms return if is_package_declaration($elem);
# spent 2.34ms making 77 calls to Perl::Critic::Utils::is_package_declaration, avg 30┬Ás/call
83877206┬Ás772.18ms return if is_perl_bareword($elem);
# spent 2.18ms making 77 calls to Perl::Critic::Utils::is_perl_bareword, avg 28┬Ás/call
83977186┬Ás771.65ms return if is_perl_filehandle($elem);
# spent 1.65ms making 77 calls to Perl::Critic::Utils::is_perl_filehandle, avg 21┬Ás/call
84077143┬Ás775.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
84277194┬Ás return 1;
843}
844
845#-----------------------------------------------------------------------------
846
847sub 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
865sub _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
875sub 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
sub policy_long_name {
90328236┬Ás my ( $policy_name ) = @_;
9042821.94ms8462.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 }
907282579┬Á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
sub policy_short_name {
9131291348┬Ás my ( $policy_name ) = @_;
91412919.60ms387313.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
91512912.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
sub first_arg {
9216621┬Ás my $elem = shift;
9226690┬Ás662.12ms my $sib = $elem->snext_sibling();
# spent 2.12ms making 66 calls to PPI::Element::snext_sibling, avg 32┬Ás/call
92366172┬Ás6537┬Ás return if !$sib;
# spent 37┬Ás making 65 calls to PPI::Util::TRUE, avg 565ns/call
924
92565248┬Ás6589┬Á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
93265139┬Á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
sub parse_arg_list {
938184┬Ás my $elem = shift;
9391823┬Ás18464┬Ás my $sib = $elem->snext_sibling();
# spent 464┬Ás making 18 calls to PPI::Element::snext_sibling, avg 26┬Ás/call
9401850┬Ás1810┬Ás return if !$sib;
# spent 10┬Ás making 18 calls to PPI::Util::TRUE, avg 561ns/call
941
9421870┬Ás1827┬Á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
967186┬Ás my $iter = $elem;
968188┬Ás my @arg_list = ();
969
9701868┬Ás36430┬Á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
971120339┬Ás126206┬Á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
972117422┬Ás217766┬Á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 );
975105415┬Ás2073.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 }
9771890┬Ás181.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
sub split_nodes_on_comma {
9841815┬Ás my @nodes = @_;
985
986184┬Ás my $i = 0;
987182┬Ás my @node_stacks;
9881816┬Ás for my $node (@nodes) {
989105569┬Ás2541.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 ) {
9933811┬Ás if (@node_stacks) {
994 $i++; #Move forward to next 'node stack'
995 }
9963819┬Á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 }
10086757┬Ás push @{ $node_stacks[$i] }, $node;
1009 }
10101848┬Á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.
101712┬Ás136┬ÁsReadonly::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
103111┬Ás123┬ÁsReadonly::Scalar our $DEFAULT_VERBOSITY => 4;
# spent 23┬Ás making 1 call to Readonly::Scalar
10321800ns121┬ÁsReadonly::Scalar our $DEFAULT_VERBOSITY_WITH_FILE_NAME => 5;
# spent 21┬Ás making 1 call to Readonly::Scalar
103316┬Ás333┬ÁsReadonly::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
sub is_valid_numeric_verbosity {
10361400ns my ($verbosity) = @_;
1037
103817┬Ás13┬Ás return exists $FORMAT_OF{$verbosity};
# spent 3┬Ás making 1 call to Readonly::Hash::EXISTS
1039}
1040
1041sub 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
105011┬Ás124┬ÁsReadonly::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
1058Readonly::Array our @SEVERITY_NAMES => #This is exported!
1059 sort
1060156┬Ás22118┬Á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
1063sub 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
1075sub _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
108411┬Ás125┬ÁsReadonly::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
108519┬Ás390┬ÁsReadonly::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
sub all_perl_files {
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
109311┬Ás my @queue = @_;
10941400ns my @code_files = ();
1095
10961700ns while (@queue) {
109716257┬Ás my $file = shift @queue;
1098162803┬Ás162529┬Ás if ( -d $file ) {
# spent 529┬Ás making 162 calls to Perl::Critic::Utils::CORE:ftdir, avg 3┬Ás/call
109918220┬Ás18160┬Ás opendir my ($dh), $file or next;
# spent 160┬Ás making 18 calls to Perl::Critic::Utils::CORE:open_dir, avg 9┬Ás/call
110018472┬Ás36338┬Á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
11011892┬Ás1856┬Ás closedir $dh;
# spent 56┬Ás making 18 calls to Perl::Critic::Utils::CORE:closedir, avg 3┬Ás/call
1102
110318125┬Ás18349┬Ás @newfiles = File::Spec->no_upwards(@newfiles);
# spent 349┬Ás making 18 calls to File::Spec::Unix::no_upwards, avg 19┬Ás/call
110418463┬Ás161232┬Ás @newfiles = grep { not $SKIP_DIR{$_} } @newfiles;
# spent 232┬Ás making 161 calls to Readonly::Hash::FETCH, avg 1┬Ás/call
11051791.89ms6442.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
1108162996┬Ás4505.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 }
1112143┬Á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
sub _is_backup {
112014430┬Ás my ($file) = @_;
1121144243┬Ás14450┬Ás return 1 if $file =~ m{ [.] swp \z}xms;
# spent 50┬Ás making 144 calls to Perl::Critic::Utils::CORE:match, avg 345ns/call
1122144193┬Ás14432┬Ás return 1 if $file =~ m{ [.] bak \z}xms;
# spent 32┬Ás making 144 calls to Perl::Critic::Utils::CORE:match, avg 221ns/call
11231443.14ms14429┬Ás return 1 if $file =~ m{ ~ \z}xms;
# spent 29┬Ás making 144 calls to Perl::Critic::Utils::CORE:match, avg 204ns/call
1124144172┬Ás14430┬Ás return 1 if $file =~ m{ \A [#] .+ [#] \z}xms;
# spent 30┬Ás making 144 calls to Perl::Critic::Utils::CORE:match, avg 206ns/call
1125144217┬Á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
sub _is_perl {
113414430┬Ás my ($file) = @_;
1135
1136 #Check filename extensions
1137144231┬Ás14444┬Ás return 1 if $file =~ m{ [.] PL \z}xms;
# spent 44┬Ás making 144 calls to Perl::Critic::Utils::CORE:match, avg 306ns/call
1138144485┬Ás144116┬Á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
sub shebang_line {
115314461┬Ás my $doc = shift;
1154144461┬Ás1441.82ms my $first_element = $doc->first_element();
# spent 1.82ms making 144 calls to Perl::Critic::Document::AUTOLOAD, avg 13┬Ás/call
1155144490┬Ás144118┬Ás return if not $first_element;
# spent 118┬Ás making 144 calls to PPI::Util::TRUE, avg 816ns/call
1156144907┬Ás144242┬Á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
sub words_from_string {
1171409┬Ás my $str = shift;
1172
117340125┬Ás return split q{ }, $str; # This must be a literal space, not $SPACE
1174}
1175
1176#-----------------------------------------------------------------------------
1177
1178sub 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.
12305276┬Ás5259┬ÁsReadonly::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 (
1233197┬Ás141.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
1323sub _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
1356sub _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
13811106┬Ás1;
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
sub Perl::Critic::Utils::CORE:closedir; # opcode
# 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
sub Perl::Critic::Utils::CORE:ftdir; # opcode
# 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
sub Perl::Critic::Utils::CORE:ftfile; # opcode
# 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
sub Perl::Critic::Utils::CORE:match; # opcode
# 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
sub Perl::Critic::Utils::CORE:open_dir; # opcode
# 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
sub Perl::Critic::Utils::CORE:readdir; # opcode
# 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:regcomp; # opcode
# spent 96┬Ás (78+19) within Perl::Critic::Utils::CORE:sort which was called 19 times, avg 5┬Ás/call: # 18 times (28┬Ás+0s) by Perl::Critic::Utils::all_perl_files at line 1100, avg 2┬Ás/call # once (50┬Ás+19┬Ás) by Perl::Critic::Exception::Parse::BEGIN@18 at line 1060
sub Perl::Critic::Utils::CORE:sort; # opcode
# spent 1.68ms within Perl::Critic::Utils::CORE:subst which was called 1300 times, avg 1┬Ás/call: # 1291 times (1.68ms+0s) by Perl::Critic::Utils::policy_short_name at line 914, avg 1┬Ás/call # 9 times (4┬Ás+0s) by Perl::Critic::Utils::_build_globals_without_sigils at line 395, avg 444ns/call
sub Perl::Critic::Utils::CORE:subst; # opcode