Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/ValuesAndExpressions/ProhibitMixedBooleanOperators.pm |
Statements | Executed 21 statements in 425µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 16µs | 16µs | BEGIN@10 | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
1 | 1 | 1 | 10µs | 21µs | BEGIN@11 | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
1 | 1 | 1 | 8µs | 58µs | BEGIN@16 | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
1 | 1 | 1 | 7µs | 28µs | BEGIN@13 | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
1 | 1 | 1 | 7µs | 11µs | BEGIN@12 | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
1 | 1 | 1 | 7µs | 193µs | BEGIN@15 | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
1 | 1 | 1 | 1µs | 1µs | supported_parameters | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
0 | 0 | 0 | 0s | 0s | _high_boolean | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
0 | 0 | 0 | 0s | 0s | _low_boolean | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
0 | 0 | 0 | 0s | 0s | applies_to | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
0 | 0 | 0 | 0s | 0s | violates | Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ############################################################################## | ||||
2 | # $URL$ | ||||
3 | # $Date$ | ||||
4 | # $Author$ | ||||
5 | # $Revision$ | ||||
6 | ############################################################################## | ||||
7 | |||||
8 | package Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators; | ||||
9 | |||||
10 | 2 | 39µs | 1 | 16µs | # spent 16µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@10 which was called:
# once (16µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 16µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@10 |
11 | 2 | 20µs | 2 | 32µs | # spent 21µs (10+11) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@11 which was called:
# once (10µs+11µs) by Module::Pluggable::Object::_require at line 11 # spent 21µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 18µs | 2 | 14µs | # spent 11µs (7+4) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@12 which was called:
# once (7µs+4µs) by Module::Pluggable::Object::_require at line 12 # spent 11µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 23µs | 2 | 48µs | # spent 28µs (7+20) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@13 which was called:
# once (7µs+20µs) by Module::Pluggable::Object::_require at line 13 # spent 28µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@13
# spent 20µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 27µs | 2 | 379µs | # spent 193µs (7+186) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@15 which was called:
# once (7µs+186µs) by Module::Pluggable::Object::_require at line 15 # spent 193µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@15
# spent 186µs making 1 call to Exporter::import |
16 | 2 | 273µs | 2 | 108µs | # spent 58µs (8+50) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@16 which was called:
# once (8µs+50µs) by Module::Pluggable::Object::_require at line 16 # spent 58µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::BEGIN@16
# spent 50µs making 1 call to base::import |
17 | |||||
18 | |||||
19 | #----------------------------------------------------------------------------- | ||||
20 | |||||
21 | 1 | 500ns | our $VERSION = '1.121'; | ||
22 | #----------------------------------------------------------------------------- | ||||
23 | |||||
24 | 1 | 3µs | 2 | 31µs | Readonly::Hash my %LOW_BOOLEANS => hashify( qw( not or and ) ); # spent 27µs making 1 call to Readonly::Hash
# spent 4µs making 1 call to Perl::Critic::Utils::hashify |
25 | 1 | 2µs | 2 | 24µs | Readonly::Hash my %HIGH_BOOLEANS => hashify( qw( ! || && ) ); # spent 22µs making 1 call to Readonly::Hash
# spent 2µs making 1 call to Perl::Critic::Utils::hashify |
26 | |||||
27 | 1 | 3µs | 2 | 32µs | Readonly::Hash my %EXEMPT_TYPES => hashify( # spent 29µs making 1 call to Readonly::Hash
# spent 3µs making 1 call to Perl::Critic::Utils::hashify |
28 | qw( | ||||
29 | PPI::Statement::Block | ||||
30 | PPI::Statement::Scheduled | ||||
31 | PPI::Statement::Package | ||||
32 | PPI::Statement::Include | ||||
33 | PPI::Statement::Sub | ||||
34 | PPI::Statement::Variable | ||||
35 | PPI::Statement::Compound | ||||
36 | PPI::Statement::Data | ||||
37 | PPI::Statement::End | ||||
38 | ) | ||||
39 | ); | ||||
40 | |||||
41 | #----------------------------------------------------------------------------- | ||||
42 | |||||
43 | 1 | 1µs | 1 | 23µs | Readonly::Scalar my $DESC => q{Mixed high and low-precedence booleans}; # spent 23µs making 1 call to Readonly::Scalar |
44 | 1 | 2µs | 1 | 40µs | Readonly::Scalar my $EXPL => [ 70 ]; # spent 40µs making 1 call to Readonly::Scalar |
45 | |||||
46 | #----------------------------------------------------------------------------- | ||||
47 | |||||
48 | 1 | 5µs | # spent 1µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::supported_parameters which was called:
# once (1µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||
49 | 1 | 2µs | # spent 7µs (6+1) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
50 | sub default_themes { return qw( core bugs pbp certrec ) } | ||||
51 | sub applies_to { return 'PPI::Statement' } | ||||
52 | |||||
53 | #----------------------------------------------------------------------------- | ||||
54 | |||||
55 | sub violates { | ||||
56 | |||||
57 | my ( $self, $elem, undef ) = @_; | ||||
58 | |||||
59 | # PPI::Statement is the ancestor of several types of PPI elements. | ||||
60 | # But for this policy, we only want the ones that generally | ||||
61 | # represent a single statement or expression. There might be | ||||
62 | # better ways to do this, such as scanning for a semi-colon or | ||||
63 | # some other marker. | ||||
64 | |||||
65 | return if exists $EXEMPT_TYPES{ ref $elem }; | ||||
66 | |||||
67 | if ( $elem->find_first(\&_low_boolean) | ||||
68 | && $elem->find_first(\&_high_boolean) ) { | ||||
69 | |||||
70 | return $self->violation( $DESC, $EXPL, $elem ); | ||||
71 | } | ||||
72 | return; #ok! | ||||
73 | } | ||||
74 | |||||
75 | #----------------------------------------------------------------------------- | ||||
76 | |||||
77 | sub _low_boolean { | ||||
78 | my (undef, $elem) = @_; | ||||
79 | return if $elem->isa('PPI::Statement'); | ||||
80 | $elem->isa('PPI::Token::Operator') || return 0; | ||||
81 | return exists $LOW_BOOLEANS{$elem}; | ||||
82 | } | ||||
83 | |||||
84 | #----------------------------------------------------------------------------- | ||||
85 | |||||
86 | sub _high_boolean { | ||||
87 | my (undef, $elem) = @_; | ||||
88 | return if $elem->isa('PPI::Statement'); | ||||
89 | $elem->isa('PPI::Token::Operator') || return 0; | ||||
90 | return exists $HIGH_BOOLEANS{$elem}; | ||||
91 | } | ||||
92 | |||||
93 | 1 | 6µs | 1; | ||
94 | |||||
95 | __END__ |