← 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/ProhibitFixedStringMatches.pm
StatementsExecuted 23 statements in 503µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11119µs19µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::BEGIN@10Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@10
11112µs16µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::BEGIN@12Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@12
1118µs37µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::BEGIN@16Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@16
1118µs28µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::BEGIN@13Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@13
1117µs375µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::BEGIN@15Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@15
1117µs61µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::BEGIN@20Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@20
1117µs183µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::BEGIN@18Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@18
1117µs18µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::BEGIN@11Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@11
1116µs7µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::default_severityPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::default_severity
1112µs2µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::supported_parametersPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::supported_parameters
1111µs1µsPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::CORE:qrPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::CORE:qr (opcode)
0000s0sPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::applies_toPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::applies_to
0000s0sPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::default_themesPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::default_themes
0000s0sPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::::violatesPerl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::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::ProhibitFixedStringMatches;
9
10240µs119µs
# spent 19µs within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@10 which was called: # once (19µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220µs229µs
# spent 18µs (7+11) within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@11 which was called: # once (7µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 18µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@11 # spent 11µs making 1 call to strict::import
12222µs220µs
# spent 16µs (12+4) within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@12 which was called: # once (12µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 16µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@12 # spent 4µs making 1 call to warnings::import
13226µs249µs
# spent 28µs (8+21) within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@13 which was called: # once (8µs+21µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 28µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@13 # spent 21µs making 1 call to Exporter::import
14
15223µs2743µs
# spent 375µs (7+368) within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@15 which was called: # once (7µs+368µs) by Module::Pluggable::Object::_require at line 15
use English qw(-no_match_vars);
# spent 375µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@15 # spent 368µs making 1 call to English::import
16223µs265µs
# spent 37µs (8+29) within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@16 which was called: # once (8µs+29µs) by Module::Pluggable::Object::_require at line 16
use Carp;
# spent 37µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@16 # spent 29µs making 1 call to Exporter::import
17
18224µs2359µs
# spent 183µs (7+176) within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@18 which was called: # once (7µs+176µs) by Module::Pluggable::Object::_require at line 18
use Perl::Critic::Utils qw{ :booleans :severities };
# spent 183µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@18 # spent 176µs making 1 call to Exporter::import
19
202303µs2115µs
# spent 61µs (7+54) within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@20 which was called: # once (7µs+54µs) by Module::Pluggable::Object::_require at line 20
use base 'Perl::Critic::Policy';
# spent 61µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::BEGIN@20 # spent 54µs making 1 call to base::import
21
221600nsour $VERSION = '1.121';
23
24#-----------------------------------------------------------------------------
25
2612µs129µsReadonly::Scalar my $DESC => q{Use 'eq' or hash instead of fixed-pattern regexps};
# spent 29µs making 1 call to Readonly::Scalar
2712µs142µsReadonly::Scalar my $EXPL => [271,272];
# spent 42µs making 1 call to Readonly::Scalar
28
2916µs222µsReadonly::Scalar my $RE_METACHAR => qr/[\\#\$()*+.?\@\[\]^{|}]/xms;
# spent 21µs making 1 call to Readonly::Scalar # spent 1µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::CORE:qr
30
31#-----------------------------------------------------------------------------
32
3315µs
# spent 2µs within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::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() }
3412µs
# spent 7µs (6+1) within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::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 }
35sub default_themes { return qw( core pbp performance ) }
36sub applies_to { return qw(PPI::Token::Regexp::Match
37 PPI::Token::Regexp::Substitute
38 PPI::Token::QuoteLike::Regexp) }
39
40#-----------------------------------------------------------------------------
41
42sub violates {
43 my ( $self, $elem, $doc ) = @_;
44
45 my $re = $elem->get_match_string();
46
47 # only flag regexps that are anchored front and back
48 if ($re =~ m{\A \s*
49 (\\A|\^) # front anchor == $1
50 (.*?)
51 (\\z|\$) # end anchor == $2
52 \s* \z}xms) {
53
54 my ($front_anchor, $words, $end_anchor) = ($1, $2, $3);
55
56 # If it's a multiline match, then end-of-line anchors don't represent the whole string
57 if ($front_anchor eq q{^} || $end_anchor eq q{$}) {
58 my $regexp = $doc->ppix_regexp_from_element( $elem )
59 or return;
60 return if $regexp->modifier_asserted( 'm' );
61 }
62
63 # check for grouping and optional alternation. Grouping may or may not capture
64 if ($words =~ m{\A \s*
65 [(] # start group
66 (?:[?]:)? # optional non-capturing indicator
67 \s* (.*?) \s* # interior of group
68 [)] # end of group
69 \s* \z}xms) {
70 $words = $1;
71 $words =~ s/[|]//gxms; # ignore alternation inside of parens -- just look at words
72 }
73
74 # Regexps that contain metachars are not fixed strings
75 return if $words =~ m/$RE_METACHAR/oxms;
76
77 return $self->violation( $DESC, $EXPL, $elem );
78
79 } else {
80 return; # OK
81 }
82}
83
8414µs1;
85
86__END__
 
# spent 1µs within Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::CORE:qr which was called: # once (1µs+0s) by Module::Pluggable::Object::_require at line 29
sub Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches::CORE:qr; # opcode