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

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/ControlStructures/ProhibitPostfixControls.pm
StatementsExecuted 17 statements in 454µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11150µs67µsPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::supported_parametersPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::supported_parameters
11117µs17µsPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::BEGIN@10Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@10
1118µs30µsPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::BEGIN@13Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@13
1118µs11µsPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::BEGIN@12Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@12
1117µs19µsPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::BEGIN@11Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@11
1117µs654µsPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::BEGIN@15Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@15
1117µs58µsPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::BEGIN@16Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@16
1116µs7µsPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::default_severityPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::default_severity
1113µs3µsPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::CORE:sortPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::CORE:sort (opcode)
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::applies_toPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::applies_to
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::default_themesPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::default_themes
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::::violatesPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls::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::ControlStructures::ProhibitPostfixControls;
9
10241µs117µs
# spent 17µs within Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@10 which was called: # once (17µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220µs231µs
# spent 19µs (7+12) within Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@11 which was called: # once (7µs+12µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 19µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@11 # spent 12µs making 1 call to strict::import
12223µs215µs
# spent 11µs (8+4) within Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@12 which was called: # once (8µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 11µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@12 # spent 4µs making 1 call to warnings::import
13224µs251µs
# spent 30µs (8+22) within Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@13 which was called: # once (8µs+22µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 30µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@13 # spent 22µs making 1 call to Exporter::import
14
15225µs21.30ms
# spent 654µs (7+647) within Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@15 which was called: # once (7µs+647µs) by Module::Pluggable::Object::_require at line 15
use Perl::Critic::Utils qw{ :characters :severities :data_conversion :classification };
# spent 654µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@15 # spent 647µs making 1 call to Exporter::import
162271µs2109µs
# spent 58µs (7+51) within Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@16 which was called: # once (7µs+51µs) by Module::Pluggable::Object::_require at line 16
use base 'Perl::Critic::Policy';
# spent 58µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::BEGIN@16 # spent 51µs making 1 call to base::import
17
181600nsour $VERSION = '1.121';
19
20#-----------------------------------------------------------------------------
21
2214µs1147µsReadonly::Hash my %PAGES_OF => (
# spent 147µs making 1 call to Readonly::Hash
23 if => [ 93, 94 ],
24 unless => [ 96, 97 ],
25 until => [ 96, 97 ],
26 for => [ 96 ],
27 foreach => [ 96 ],
28 while => [ 96 ],
29 when => q<Similar to "if", postfix "when" should only be used with flow-control>,
30);
31
32#-----------------------------------------------------------------------------
33
34
# spent 67µs (50+17) within Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::supported_parameters which was called: # once (50µs+17µs) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
35 return (
36 {
37139µs1117µs name => 'allow',
# spent 9µs making 7 calls to Readonly::Hash::NEXTKEY, avg 1µs/call # spent 4µs making 1 call to Readonly::Hash::FIRSTKEY # spent 3µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::CORE:sort # spent 2µs making 2 calls to Readonly::Scalar::FETCH, avg 1µs/call
38 description => 'The permitted postfix controls.',
39 default_string => $EMPTY,
40 behavior => 'enumeration',
41 enumeration_values => [ sort keys %PAGES_OF ],
42 enumeration_allow_multiple_values => 1,
43 },
44 {
45 name => 'flowcontrol',
46 description => 'The exempt flow control functions.',
47 default_string => 'carp cluck confess croak die exit goto warn',
48 behavior => 'string list',
49 },
50 );
51}
52
5312µs
# spent 7µs (6+1) within Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::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_LOW }
54sub default_themes { return qw(core pbp cosmetic) }
55sub applies_to { return 'PPI::Token::Word' }
56
57#-----------------------------------------------------------------------------
58
59sub violates {
60 my ( $self, $elem, undef ) = @_;
61
62 my $expl = $PAGES_OF{$elem};
63 return if not $expl;
64
65 return if is_hash_key($elem);
66 return if is_method_call($elem);
67 return if is_subroutine_name($elem);
68 return if is_included_module_name($elem);
69 return if is_package_declaration($elem);
70
71 # Skip controls that are allowed
72 return if exists $self->{_allow}->{ $elem->content() };
73
74 # Skip Compound variety (these are good)
75 my $stmnt = $elem->statement();
76 return if not $stmnt;
77 return if $stmnt->isa('PPI::Statement::Compound');
78 return if $stmnt->isa('PPI::Statement::When');
79
80 # Handle special cases
81 my $content = $elem->content();
82 if ($content eq 'if' or $content eq 'when') {
83 # Postfix 'if' allowed with loop breaks, or other
84 # flow-controls like 'die', 'warn', and 'croak'
85 return if $stmnt->isa('PPI::Statement::Break');
86 return if defined $self->{_flowcontrol}{ $stmnt->schild(0)->content() };
87 }
88
89 # If we get here, it must be postfix.
90 my $desc = qq{Postfix control "$content" used};
91 return $self->violation($desc, $expl, $elem);
92}
93
9414µs1;
95
96__END__
 
# spent 3µs within Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::CORE:sort which was called: # once (3µs+0s) by Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::supported_parameters at line 37
sub Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls::CORE:sort; # opcode