← 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:11 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/ValuesAndExpressions/ProhibitLeadingZeros.pm
StatementsExecuted 162 statements in 1.11ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
14411284µs284µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::applies_toPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::applies_to
11119µs19µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::BEGIN@10Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@10
1118µs61µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::BEGIN@17Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@17
1117µs28µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::BEGIN@14Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@14
1117µs11µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::BEGIN@12Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@12
1117µs18µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::BEGIN@11Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@11
1117µs336µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::BEGIN@16Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@16
1116µs8µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::default_severityPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::default_severity
1116µs6µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::supported_parametersPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::supported_parameters
1112µs2µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::CORE:qrPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::CORE:qr (opcode)
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::_create_violationPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::_create_violation
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::_is_first_argument_of_chmod_or_umaskPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::_is_first_argument_of_chmod_or_umask
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::_is_fourth_argument_of_sysopenPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::_is_fourth_argument_of_sysopen
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::_is_second_argument_of_mkdirPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::_is_second_argument_of_mkdir
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::_is_third_argument_of_dbmopenPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::_is_third_argument_of_dbmopen
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::_previous_token_that_isnt_a_parenthesisPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::_previous_token_that_isnt_a_parenthesis
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::default_themesPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::default_themes
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::::violatesPerl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::violates
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
8package Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros;
9
10241µs119µs
# spent 19µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@10 which was called: # once (19µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220µs229µs
# spent 18µs (7+11) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@11 which was called: # once (7µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 18µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@11 # spent 11µs making 1 call to strict::import
12219µs215µs
# spent 11µs (7+4) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@12 which was called: # once (7µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 11µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14223µs249µs
# spent 28µs (7+21) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@14 which was called: # once (7µs+21µs) by Module::Pluggable::Object::_require at line 14
use Readonly;
# spent 28µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@14 # spent 21µs making 1 call to Exporter::import
15
16224µs2665µs
# spent 336µs (7+329) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@16 which was called: # once (7µs+329µs) by Module::Pluggable::Object::_require at line 16
use Perl::Critic::Utils qw{ :characters :severities };
# spent 336µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@16 # spent 329µs making 1 call to Exporter::import
172567µs2115µs
# spent 61µs (8+54) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@17 which was called: # once (8µs+54µs) by Module::Pluggable::Object::_require at line 17
use base 'Perl::Critic::Policy';
# spent 61µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::BEGIN@17 # spent 54µs making 1 call to base::import
18
191600nsour $VERSION = '1.121';
20
21#-----------------------------------------------------------------------------
22
2319µs230µsReadonly::Scalar my $LEADING_RX => qr<\A [+-]? (?: 0+ _* )+ [1-9]>xms;
# spent 28µs making 1 call to Readonly::Scalar # spent 2µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::CORE:qr
2412µs143µsReadonly::Scalar my $EXPL => [ 58 ];
# spent 43µs making 1 call to Readonly::Scalar
25
26#-----------------------------------------------------------------------------
27
28
# spent 6µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::supported_parameters which was called: # once (6µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
29 return (
30 {
3119µs name => 'strict',
32 description =>
33 q<Don't allow any leading zeros at all. Otherwise builtins that deal with Unix permissions, e.g. chmod, don't get flagged.>,
34 default_string => '0',
35 behavior => 'boolean',
36 },
37 );
38}
39
4012µs
# spent 8µs (6+1) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::default_severity which was called: # once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm
sub default_severity { return $SEVERITY_HIGHEST }
41sub default_themes { return qw< core pbp bugs certrec > }
42144392µs
# spent 284µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::applies_to which was called 144 times, avg 2µs/call: # 144 times (284µs+0s) by Perl::Critic::_critique at line 165 of Perl/Critic.pm, avg 2µs/call
sub applies_to { return 'PPI::Token::Number::Octal' }
43
44#-----------------------------------------------------------------------------
45
46sub violates {
47 my ( $self, $elem, undef ) = @_;
48
49 return if $elem !~ $LEADING_RX;
50 return $self->_create_violation($elem) if $self->{_strict};
51 return if $self->_is_first_argument_of_chmod_or_umask($elem);
52 return if $self->_is_second_argument_of_mkdir($elem);
53 return if $self->_is_third_argument_of_dbmopen($elem);
54 return if $self->_is_fourth_argument_of_sysopen($elem);
55 return $self->_create_violation($elem);
56}
57
58sub _create_violation {
59 my ($self, $elem) = @_;
60
61 return $self->violation(
62 qq<Integer with leading zeros: "$elem">,
63 $EXPL,
64 $elem
65 );
66}
67
68sub _is_first_argument_of_chmod_or_umask {
69 my ($self, $elem) = @_;
70
71 my $previous_token = _previous_token_that_isnt_a_parenthesis($elem);
72 return if not $previous_token;
73
74 my $content = $previous_token->content();
75 return $content eq 'chmod' || $content eq 'umask';
76}
77
78sub _is_second_argument_of_mkdir {
79 my ($self, $elem) = @_;
80
81 # Preceding comma.
82 my $previous_token = _previous_token_that_isnt_a_parenthesis($elem);
83 return if not $previous_token;
84 return if $previous_token->content() ne $COMMA; # Don't know what it is.
85
86 # Directory name.
87 $previous_token =
88 _previous_token_that_isnt_a_parenthesis($previous_token);
89 return if not $previous_token;
90
91 $previous_token =
92 _previous_token_that_isnt_a_parenthesis($previous_token);
93 return if not $previous_token;
94
95 return $previous_token->content() eq 'mkdir';
96}
97
98sub _is_third_argument_of_dbmopen {
99 my ($self, $elem) = @_;
100
101 # Preceding comma.
102 my $previous_token = _previous_token_that_isnt_a_parenthesis($elem);
103 return if not $previous_token;
104 return if $previous_token->content() ne $COMMA; # Don't know what it is.
105
106 # File path.
107 $previous_token =
108 _previous_token_that_isnt_a_parenthesis($previous_token);
109 return if not $previous_token;
110
111 # Another comma.
112 $previous_token =
113 _previous_token_that_isnt_a_parenthesis($previous_token);
114 return if not $previous_token;
115 return if $previous_token->content() ne $COMMA; # Don't know what it is.
116
117 # Variable name.
118 $previous_token =
119 _previous_token_that_isnt_a_parenthesis($previous_token);
120 return if not $previous_token;
121
122 $previous_token =
123 _previous_token_that_isnt_a_parenthesis($previous_token);
124 return if not $previous_token;
125
126 return $previous_token->content() eq 'dbmopen';
127}
128
129sub _is_fourth_argument_of_sysopen {
130 my ($self, $elem) = @_;
131
132 # Preceding comma.
133 my $previous_token = _previous_token_that_isnt_a_parenthesis($elem);
134 return if not $previous_token;
135 return if $previous_token->content() ne $COMMA; # Don't know what it is.
136
137 # Mode.
138 $previous_token =
139 _previous_token_that_isnt_a_parenthesis($previous_token);
140 while ($previous_token and $previous_token->content() ne $COMMA) {
141 $previous_token =
142 _previous_token_that_isnt_a_parenthesis($previous_token);
143 }
144 return if not $previous_token;
145 return if $previous_token->content() ne $COMMA; # Don't know what it is.
146
147 # File name.
148 $previous_token =
149 _previous_token_that_isnt_a_parenthesis($previous_token);
150 return if not $previous_token;
151
152 # Yet another comma.
153 $previous_token =
154 _previous_token_that_isnt_a_parenthesis($previous_token);
155 return if not $previous_token;
156 return if $previous_token->content() ne $COMMA; # Don't know what it is.
157
158 # File handle.
159 $previous_token =
160 _previous_token_that_isnt_a_parenthesis($previous_token);
161 return if not $previous_token;
162
163 $previous_token =
164 _previous_token_that_isnt_a_parenthesis($previous_token);
165 return if not $previous_token;
166
167 return $previous_token->content() eq 'sysopen';
168}
169
170sub _previous_token_that_isnt_a_parenthesis {
171 my ($elem) = @_;
172
173 my $previous_token = $elem->previous_token();
174 while (
175 $previous_token
176 and (
177 not $previous_token->significant()
178 or $previous_token->content() eq $LEFT_PAREN
179 or $previous_token->content() eq $RIGHT_PAREN
180 )
181 ) {
182 $previous_token = $previous_token->previous_token();
183 }
184
185 return $previous_token;
186}
187
18813µs1;
189
190__END__
 
# spent 2µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::CORE:qr which was called: # once (2µs+0s) by Module::Pluggable::Object::_require at line 23
sub Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros::CORE:qr; # opcode