← 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/RegularExpressions/ProhibitEscapedMetacharacters.pm
StatementsExecuted 23 statements in 476µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs16µsPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::BEGIN@10Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@10
1118µs136µsPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::BEGIN@15Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@15
1118µs27µsPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::BEGIN@16Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@16
1118µs19µsPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::BEGIN@11Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@11
1118µs11µsPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::BEGIN@12Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@12
1117µs60µsPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::BEGIN@19Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@19
1117µs218µsPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::BEGIN@18Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@18
1117µs372µsPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::BEGIN@14Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@14
1116µs7µsPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::default_severityPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::default_severity
1112µs2µsPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::supported_parametersPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::supported_parameters
0000s0sPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::applies_toPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::applies_to
0000s0sPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::default_themesPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::default_themes
0000s0sPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::::violatesPerl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::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::RegularExpressions::ProhibitEscapedMetacharacters;
9
10242µs116µs
# spent 16µs within Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@10 which was called: # once (16µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220µs230µs
# spent 19µs (8+11) within Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@11 which was called: # once (8µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 19µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@11 # spent 11µs making 1 call to strict::import
12221µs215µs
# spent 11µs (8+4) within Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::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::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14224µs2737µs
# spent 372µs (7+365) within Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@14 which was called: # once (7µs+365µs) by Module::Pluggable::Object::_require at line 14
use English qw(-no_match_vars);
# spent 372µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@14 # spent 365µs making 1 call to English::import
15222µs2264µs
# spent 136µs (8+128) within Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@15 which was called: # once (8µs+128µs) by Module::Pluggable::Object::_require at line 15
use List::MoreUtils qw(any);
# spent 136µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@15 # spent 128µs making 1 call to Exporter::Tiny::import
16223µs246µs
# spent 27µs (8+19) within Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@16 which was called: # once (8µs+19µs) by Module::Pluggable::Object::_require at line 16
use Readonly;
# spent 27µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@16 # spent 19µs making 1 call to Exporter::import
17
18223µs2429µs
# spent 218µs (7+211) within Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@18 which was called: # once (7µs+211µs) by Module::Pluggable::Object::_require at line 18
use Perl::Critic::Utils qw{ :booleans :severities hashify };
# spent 218µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@18 # spent 211µs making 1 call to Exporter::import
192277µs2112µs
# spent 60µs (7+52) within Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@19 which was called: # once (7µs+52µs) by Module::Pluggable::Object::_require at line 19
use base 'Perl::Critic::Policy';
# spent 60µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::BEGIN@19 # spent 52µs making 1 call to base::import
20
211600nsour $VERSION = '1.121';
22
23#-----------------------------------------------------------------------------
24
2512µs12.84msReadonly::Scalar my $DESC => q{Use character classes for literal metachars instead of escapes};
# spent 2.84ms making 1 call to Readonly::Scalar
2612µs148µsReadonly::Scalar my $EXPL => [247];
# spent 48µs making 1 call to Readonly::Scalar
27
2817µs244µsReadonly::Hash my %REGEXP_METACHARS => hashify(split / /xms, '{ } ( ) . * + ? |');
# spent 39µs making 1 call to Readonly::Hash # spent 6µs making 1 call to Perl::Critic::Utils::hashify
29
30#-----------------------------------------------------------------------------
31
3214µs
# spent 2µs within Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::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() }
3312µs
# spent 7µs (6+1) within Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters::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_LOWEST }
34sub default_themes { return qw( core pbp cosmetic ) }
35sub applies_to { return qw(PPI::Token::Regexp::Match
36 PPI::Token::Regexp::Substitute
37 PPI::Token::QuoteLike::Regexp) }
38
39#-----------------------------------------------------------------------------
40
41sub violates {
42 my ( $self, $elem, $document ) = @_;
43
44 # optimization: don't bother parsing the regexp if there are no escapes
45 return if $elem !~ m/\\/xms;
46
47 my $re = $document->ppix_regexp_from_element( $elem ) or return;
48 $re->failures() and return;
49 my $qr = $re->regular_expression() or return;
50
51 my $exacts = $qr->find( 'PPIx::Regexp::Token::Literal' ) or return;
52 foreach my $exact( @{ $exacts } ) {
53 $exact->content() =~ m/ \\ ( . ) /xms or next;
54 return $self->violation( $DESC, $EXPL, $elem ) if $REGEXP_METACHARS{$1};
55 }
56
57 return; # OK
58}
59
6015µs1;
61
62__END__