Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/RegularExpressions/ProhibitUnusualDelimiters.pm |
Statements | Executed 23 statements in 435µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 26µs | 26µs | BEGIN@10 | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
1 | 1 | 1 | 8µs | 37µs | BEGIN@16 | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
1 | 1 | 1 | 8µs | 30µs | BEGIN@13 | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
1 | 1 | 1 | 8µs | 376µs | BEGIN@15 | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
1 | 1 | 1 | 8µs | 58µs | BEGIN@20 | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
1 | 1 | 1 | 7µs | 11µs | BEGIN@12 | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
1 | 1 | 1 | 7µs | 196µs | BEGIN@18 | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
1 | 1 | 1 | 5µs | 5µs | supported_parameters | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
0 | 0 | 0 | 0s | 0s | applies_to | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
0 | 0 | 0 | 0s | 0s | initialize_if_enabled | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
0 | 0 | 0 | 0s | 0s | violates | Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::
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::RegularExpressions::ProhibitUnusualDelimiters; | ||||
9 | |||||
10 | 2 | 50µs | 1 | 26µs | # spent 26µs within Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@10 which was called:
# once (26µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 26µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@10 |
11 | 2 | 21µs | 2 | 30µs | # spent 18µs (7+11) within Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@11 which was called:
# once (7µs+11µs) by Module::Pluggable::Object::_require at line 11 # spent 18µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 23µs | 2 | 15µs | # spent 11µs (7+4) within Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::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::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 23µs | 2 | 51µs | # spent 30µs (8+22) within Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@13 which was called:
# once (8µs+22µs) by Module::Pluggable::Object::_require at line 13 # spent 30µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@13
# spent 22µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 23µs | 2 | 744µs | # spent 376µs (8+368) within Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@15 which was called:
# once (8µs+368µs) by Module::Pluggable::Object::_require at line 15 # spent 376µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@15
# spent 368µs making 1 call to English::import |
16 | 2 | 23µs | 2 | 65µs | # spent 37µs (8+28) within Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@16 which was called:
# once (8µs+28µs) by Module::Pluggable::Object::_require at line 16 # spent 37µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@16
# spent 28µs making 1 call to Exporter::import |
17 | |||||
18 | 2 | 24µs | 2 | 386µs | # spent 196µs (7+189) within Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@18 which was called:
# once (7µs+189µs) by Module::Pluggable::Object::_require at line 18 # spent 196µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@18
# spent 189µs making 1 call to Exporter::import |
19 | |||||
20 | 2 | 230µs | 2 | 110µs | # spent 58µs (8+51) within Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@20 which was called:
# once (8µs+51µs) by Module::Pluggable::Object::_require at line 20 # spent 58µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::BEGIN@20
# spent 51µs making 1 call to base::import |
21 | |||||
22 | 1 | 500ns | our $VERSION = '1.121'; | ||
23 | |||||
24 | #----------------------------------------------------------------------------- | ||||
25 | |||||
26 | 1 | 2µs | 1 | 28µs | Readonly::Scalar my $DESC => q<Use only '//' or '{}' to delimit regexps>; # spent 28µs making 1 call to Readonly::Scalar |
27 | 1 | 2µs | 1 | 42µs | Readonly::Scalar my $EXPL => [246]; # spent 42µs making 1 call to Readonly::Scalar |
28 | |||||
29 | 1 | 1µs | 1 | 20µs | Readonly::Array my @EXTRA_BRACKETS => qw{ () [] <> }; # spent 20µs making 1 call to Readonly::Array |
30 | |||||
31 | #----------------------------------------------------------------------------- | ||||
32 | |||||
33 | # spent 5µs within Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::supported_parameters which was called:
# once (5µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||||
34 | return ( | ||||
35 | { | ||||
36 | 1 | 8µs | name => 'allow_all_brackets', | ||
37 | description => | ||||
38 | q[In addition to allowing '{}', allow '()', '[]', and '{}'.], | ||||
39 | behavior => 'boolean', | ||||
40 | }, | ||||
41 | ); | ||||
42 | } | ||||
43 | |||||
44 | 1 | 1µs | # spent 7µs (6+1) within Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
45 | sub default_themes { return qw( core pbp cosmetic ) } | ||||
46 | sub applies_to { return qw(PPI::Token::Regexp::Match | ||||
47 | PPI::Token::Regexp::Substitute | ||||
48 | PPI::Token::QuoteLike::Regexp) } | ||||
49 | |||||
50 | #----------------------------------------------------------------------------- | ||||
51 | |||||
52 | sub initialize_if_enabled { | ||||
53 | my ( $self, $config ) = @_; | ||||
54 | |||||
55 | my %delimiters = hashify( qw< // {} > ); | ||||
56 | if ( $self->{_allow_all_brackets} ) { | ||||
57 | @delimiters{ @EXTRA_BRACKETS } = (1) x @EXTRA_BRACKETS; | ||||
58 | } | ||||
59 | |||||
60 | $self->{_allowed_delimiters} = \%delimiters; | ||||
61 | |||||
62 | return $TRUE; | ||||
63 | } | ||||
64 | |||||
65 | #----------------------------------------------------------------------------- | ||||
66 | |||||
67 | sub violates { | ||||
68 | my ( $self, $elem, undef ) = @_; | ||||
69 | |||||
70 | my $allowed_delimiters = $self->{_allowed_delimiters}; | ||||
71 | foreach my $delimiter ($elem->get_delimiters()) { | ||||
72 | next if $allowed_delimiters->{$delimiter}; | ||||
73 | return $self->violation( $DESC, $EXPL, $elem ); | ||||
74 | } | ||||
75 | |||||
76 | return; # OK | ||||
77 | } | ||||
78 | |||||
79 | 1 | 4µs | 1; | ||
80 | |||||
81 | __END__ |