← 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:13 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/CodeLayout/ProhibitQuotedWordLists.pm
StatementsExecuted 18 statements in 491µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11118µs18µsPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::BEGIN@10Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@10
1118µs8µsPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::supported_parametersPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::supported_parameters
1118µs582µsPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::BEGIN@16Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@16
1118µs70µsPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::BEGIN@17Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@17
1117µs20µsPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::BEGIN@11Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@11
1117µs11µsPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::BEGIN@12Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@12
1117µs29µsPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::BEGIN@14Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@14
1116µs7µsPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::default_severityPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::default_severity
0000s0sPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::_is_literalPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::_is_literal
0000s0sPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::applies_toPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::applies_to
0000s0sPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::default_themesPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::default_themes
0000s0sPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::::violatesPerl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::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::CodeLayout::ProhibitQuotedWordLists;
9
10243µs118µs
# spent 18µs within Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@10 which was called: # once (18µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11221µs233µs
# spent 20µs (7+13) within Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@11 which was called: # once (7µs+13µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 20µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@11 # spent 13µs making 1 call to strict::import
12220µs215µs
# spent 11µs (7+4) within Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@12 which was called: # once (7µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 11µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14225µs252µs
# spent 29µs (7+22) within Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@14 which was called: # once (7µs+22µs) by Module::Pluggable::Object::_require at line 14
use Readonly;
# spent 29µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@14 # spent 22µs making 1 call to Exporter::import
15
16225µs21.16ms
# spent 582µs (8+575) within Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@16 which was called: # once (8µs+575µs) by Module::Pluggable::Object::_require at line 16
use Perl::Critic::Utils qw{ :characters :severities :classification};
# spent 582µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@16 # spent 575µs making 1 call to Exporter::import
172340µs2132µs
# spent 70µs (8+62) within Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@17 which was called: # once (8µs+62µs) by Module::Pluggable::Object::_require at line 17
use base 'Perl::Critic::Policy';
# spent 70µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::BEGIN@17 # spent 62µs making 1 call to base::import
18
191500nsour $VERSION = '1.121';
20
21#-----------------------------------------------------------------------------
22
2312µs129µsReadonly::Scalar my $DESC => q{List of quoted literal words};
# spent 29µs making 1 call to Readonly::Scalar
241900ns121µsReadonly::Scalar my $EXPL => q{Use 'qw()' instead};
# spent 21µs making 1 call to Readonly::Scalar
25
26#-----------------------------------------------------------------------------
27
28
# spent 8µs within Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::supported_parameters which was called: # once (8µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
29 return (
30 {
31110µs name => 'min_elements',
32 description => 'The minimum number of words in a list that will be complained about.',
33 default_string => '2',
34 behavior => 'integer',
35 integer_minimum => 1,
36 },
37 {
38 name => 'strict',
39 description => 'Complain even if there are non-word characters in the values.',
40 default_string => '0',
41 behavior => 'boolean',
42 },
43 );
44}
45
4611µs
# spent 7µs (6+1) within Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::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 }
47sub default_themes { return qw( core cosmetic ) }
48sub applies_to { return 'PPI::Structure::List' }
49
50#-----------------------------------------------------------------------------
51
52sub violates {
53 my ( $self, $elem, undef ) = @_;
54
55 # Don't worry about subroutine calls
56 my $sibling = $elem->sprevious_sibling();
57 return if not $sibling;
58
59 return if $sibling->isa('PPI::Token::Symbol');
60 return if $sibling->isa('PPI::Token::Operator') and $sibling eq '->';
61 return if $sibling->isa('PPI::Token::Word') and not is_included_module_name($sibling);
62
63 # Get the list elements
64 my $expr = $elem->schild(0);
65 return if not $expr;
66 my @children = $expr->schildren();
67 return if not @children;
68
69 my $count = 0;
70 for my $child ( @children ) {
71 next if $child->isa('PPI::Token::Operator') && $child eq $COMMA;
72
73 # All elements must be literal strings,
74 # and must contain 1 or more word characters.
75
76 return if not _is_literal($child);
77
78 my $string = $child->string();
79 return if $string =~ m{ \s }xms;
80 return if $string eq $EMPTY;
81 return if not $self->{_strict} and $string !~ m{\A [\w-]+ \z}xms;
82 $count++;
83 }
84
85 # Were there enough?
86 return if $count < $self->{_min_elements};
87
88 # If we get here, then all elements were literals
89 return $self->violation( $DESC, $EXPL, $elem );
90}
91
92sub _is_literal {
93 my $elem = shift;
94 return $elem->isa('PPI::Token::Quote::Single')
95 || $elem->isa('PPI::Token::Quote::Literal');
96}
97
9813µs1;
99
100__END__