← 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/ProhibitNegativeExpressionsInUnlessAndUntilConditions.pm
StatementsExecuted 20 statements in 590µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11118µs18µsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::BEGIN@10Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@10
11111µs15µsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::BEGIN@12Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@12
1118µs29µsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::BEGIN@14Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@14
1118µs395µsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::BEGIN@13Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@13
1118µs607µsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::BEGIN@16Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@16
1118µs68µsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::BEGIN@18Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@18
1117µs19µsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::BEGIN@11Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@11
1116µs7µsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::default_severityPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::default_severity
1112µs2µsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::supported_parametersPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::supported_parameters
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::_get_condition_elementsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::_get_condition_elements
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::_get_negative_operatorsPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::_get_negative_operators
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::_is_negative_operatorPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::_is_negative_operator
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::_violation_for_operatorPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::_violation_for_operator
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::applies_toPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::applies_to
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::default_themesPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::default_themes
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::::violatesPerl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::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::ProhibitNegativeExpressionsInUnlessAndUntilConditions;
9
10241µs118µs
# spent 18µs within Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@10 which was called: # once (18µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11221µs231µs
# spent 19µs (7+12) within Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@11 which was called: # once (7µs+12µs) by Module::Pluggable::Object::_require at line 11
use strict;
12222µs219µs
# spent 15µs (11+4) within Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@12 which was called: # once (11µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
13224µs2783µs
# spent 395µs (8+388) within Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@13 which was called: # once (8µs+388µs) by Module::Pluggable::Object::_require at line 13
use English qw(-no_match_vars);
14225µs249µs
# spent 29µs (8+20) within Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@14 which was called: # once (8µs+20µs) by Module::Pluggable::Object::_require at line 14
use Readonly;
15
16226µs21.21ms
# spent 607µs (8+599) within Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@16 which was called: # once (8µs+599µs) by Module::Pluggable::Object::_require at line 16
use Perl::Critic::Utils qw< :characters :severities :classification hashify >;
17
182412µs2128µs
# spent 68µs (8+60) within Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::BEGIN@18 which was called: # once (8µs+60µs) by Module::Pluggable::Object::_require at line 18
use base 'Perl::Critic::Policy';
19
201600nsour $VERSION = '1.121';
21
22#-----------------------------------------------------------------------------
23
2413µs151µsReadonly::Scalar my $EXPL => [99];
# spent 51µs making 1 call to Readonly::Scalar
25
26#-----------------------------------------------------------------------------
27
2814µs
# spent 2µs within Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::supported_parameters which was called: # once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters { return qw< > }
2912µs
# spent 7µs (6+1) within Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions::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_MEDIUM }
30sub default_themes { return qw( core maintenance pbp ) }
31sub applies_to { return 'PPI::Token::Word' }
32
33#-----------------------------------------------------------------------------
34
35sub violates {
36 my ( $self, $token, undef ) = @_;
37
38 return if $token ne 'until' && $token ne 'unless';
39
40 return if is_hash_key($token);
41 return if is_subroutine_name($token);
42 return if is_method_call($token);
43 return if is_included_module_name($token);
44
45 return
46 map
47 { $self->_violation_for_operator( $_, $token ) }
48 _get_negative_operators( $token );
49}
50
51#-----------------------------------------------------------------------------
52
53sub _get_negative_operators {
54 my ($token) = @_;
55
56 my @operators;
57 foreach my $element ( _get_condition_elements($token) ) {
58 if ( $element->isa('PPI::Node') ) {
59 my $operators = $element->find( \&_is_negative_operator );
60 if ($operators) {
61 push @operators, @{$operators};
62 }
63 }
64 else {
65 if ( _is_negative_operator( undef, $element ) ) {
66 push @operators, $element;
67 }
68 }
69 }
70
71 return @operators;
72}
73
74#-----------------------------------------------------------------------------
75
76sub _get_condition_elements {
77 my ($token) = @_;
78
79 my $statement = $token->statement();
80 return if not $statement;
81
82 if ($statement->isa('PPI::Statement::Compound')) {
83 my $condition = $token->snext_sibling();
84
85 return if not $condition;
86 return if not $condition->isa('PPI::Structure::Condition');
87
88 return ( $condition );
89 }
90
91 my @condition_elements;
92 my $element = $token;
93 while (
94 $element = $element->snext_sibling()
95 and $element ne $SCOLON
96 ) {
97 push @condition_elements, $element;
98 }
99
100 return @condition_elements;
101}
102
103#-----------------------------------------------------------------------------
104
10514µs246µsReadonly::Hash my %NEGATIVE_OPERATORS => hashify(
# spent 40µs making 1 call to Readonly::Hash # spent 5µs making 1 call to Perl::Critic::Utils::hashify
106 qw/
107 ! not
108 !~ ne !=
109 < > <= >= <=>
110 lt gt le ge cmp
111 /
112);
113
114sub _is_negative_operator {
115 my (undef, $element) = @_;
116
117 return
118 $element->isa('PPI::Token::Operator')
119 && $NEGATIVE_OPERATORS{$element};
120}
121
122#-----------------------------------------------------------------------------
123
124sub _violation_for_operator {
125 my ($self, $operator, $control_structure) = @_;
126
127 return
128 $self->violation(
129 qq<Found "$operator" in condition for an "$control_structure">,
130 $EXPL,
131 $control_structure,
132 );
133}
134
13516µs1;
136
137#-----------------------------------------------------------------------------
138
139__END__