← 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/TestingAndDebugging/ProhibitNoWarnings.pm
StatementsExecuted 28 statements in 649µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs16µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::BEGIN@10Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@10
11116µs19µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::supported_parametersPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::supported_parameters
11111µs34µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::BEGIN@17Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@17
1118µs12µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::BEGIN@12Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@12
1117µs19µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::BEGIN@11Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@11
1117µs29µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::BEGIN@13Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@13
1117µs58µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::BEGIN@19Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@19
1117µs387µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::BEGIN@18Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@18
1117µs148µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::BEGIN@15Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@15
1116µs7µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::default_severityPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::default_severity
1114µs4µsPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::_parse_allowPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::_parse_allow
0000s0sPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::__ANON__[:107]Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::__ANON__[:107]
0000s0sPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::__ANON__[:109]Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::__ANON__[:109]
0000s0sPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::__ANON__[:110]Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::__ANON__[:110]
0000s0sPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::__ANON__[:111]Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::__ANON__[:111]
0000s0sPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::__ANON__[:87]Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::__ANON__[:87]
0000s0sPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::_extract_potential_categoriesPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::_extract_potential_categories
0000s0sPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::applies_toPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::applies_to
0000s0sPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::default_themesPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::default_themes
0000s0sPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::::violatesPerl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::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::TestingAndDebugging::ProhibitNoWarnings;
9
10240µs116µs
# spent 16µs within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::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 (7+11) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@11 which was called: # once (7µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 19µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@11 # spent 12µs making 1 call to strict::import
12219µs216µs
# spent 12µs (8+4) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@12 which was called: # once (8µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 12µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@12 # spent 4µs making 1 call to warnings::import
13222µs250µs
# spent 29µs (7+21) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@13 which was called: # once (7µs+21µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 29µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@13 # spent 21µs making 1 call to Exporter::import
14
15225µs2289µs
# spent 148µs (7+141) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@15 which was called: # once (7µs+141µs) by Module::Pluggable::Object::_require at line 15
use List::MoreUtils qw(all);
# spent 148µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@15 # spent 141µs making 1 call to Exporter::Tiny::import
16
17226µs256µs
# spent 34µs (11+22) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@17 which was called: # once (11µs+22µs) by Module::Pluggable::Object::_require at line 17
use Perl::Critic::Exception::Fatal::Internal qw{ throw_internal };
# spent 34µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@17 # spent 22µs making 1 call to Exporter::import
18228µs2766µs
# spent 387µs (7+379) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@18 which was called: # once (7µs+379µs) by Module::Pluggable::Object::_require at line 18
use Perl::Critic::Utils qw{ :characters :severities :data_conversion };
# spent 387µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@18 # spent 379µs making 1 call to Exporter::import
192430µs2109µs
# spent 58µs (7+51) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@19 which was called: # once (7µs+51µs) by Module::Pluggable::Object::_require at line 19
use base 'Perl::Critic::Policy';
# spent 58µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::BEGIN@19 # spent 51µs making 1 call to base::import
20
211600nsour $VERSION = '1.121';
22
23#-----------------------------------------------------------------------------
24
2512µs130µsReadonly::Scalar my $DESC => q{Warnings disabled};
# spent 30µs making 1 call to Readonly::Scalar
2612µs144µsReadonly::Scalar my $EXPL => [ 431 ];
# spent 44µs making 1 call to Readonly::Scalar
27
28#-----------------------------------------------------------------------------
29
30
# spent 19µs (16+2) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::supported_parameters which was called: # once (16µs+2µs) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
31 return (
32 {
33114µs22µs name => 'allow',
# spent 2µs making 2 calls to Readonly::Scalar::FETCH, avg 1µs/call
34 description => 'Permitted warning categories.',
35 default_string => $EMPTY,
36 parser => \&_parse_allow,
37 },
38 {
39 name => 'allow_with_category_restriction',
40 description =>
41 'Allow "no warnings" if it restricts the kinds of warnings that are turned off.',
42 default_string => '0',
43 behavior => 'boolean',
44 },
45 );
46}
47
4812µs
# spent 7µs (6+1) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::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_HIGH }
49sub default_themes { return qw( core bugs pbp certrec ) }
50sub applies_to { return 'PPI::Statement::Include' }
51
52#-----------------------------------------------------------------------------
53
54
# spent 4µs within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::_parse_allow which was called: # once (4µs+0s) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 231 of Perl/Critic/PolicyParameter.pm
sub _parse_allow {
551500ns my ($self, $parameter, $config_string) = @_;
56
5711µs $self->{_allow} = {};
58
591400ns if( defined $config_string ) {
60 my $allowed = lc $config_string; #String of words
61 my %allowed = hashify( $allowed =~ m/ (\w+) /gxms );
62
63 $self->{_allow} = \%allowed;
64 }
65
6614µs return;
67}
68
69#-----------------------------------------------------------------------------
70
71sub violates {
72
73 my ( $self, $elem, undef ) = @_;
74
75 return if $elem->type() ne 'no';
76 return if $elem->pragma() ne 'warnings';
77
78 my @words = _extract_potential_categories( $elem );
79 @words >= 2
80 and 'no' eq $words[0]
81 and 'warnings' eq $words[1]
82 or throw_internal
83 q<'no warnings' word list did not begin with qw{ no warnings }>;
84 splice @words, 0, 2;
85
86 return if $self->{_allow_with_category_restriction} and @words;
87 return if @words && all { exists $self->{_allow}->{$_} } @words;
88
89 #If we get here, then it must be a violation
90 return $self->violation( $DESC, $EXPL, $elem );
91}
92
93#-----------------------------------------------------------------------------
94
95# Traverse the element, accumulating and ultimately returning things
96# that might be warnings categories. These are:
97# * Words (because of the 'foo' in 'no warnings foo => "bar"');
98# * Quotes (because of 'no warnings "foo"');
99# * qw{} strings (obviously);
100# * Nodes (because of 'no warnings ( "foo", "bar" )').
101# We don't lop off the 'no' and 'warnings' because we recurse.
102# RT #74647.
103
104{
105
10612µs Readonly::Array my @HANDLER => (
107 [ 'PPI::Token::Word' => sub { return $_[0]->content() } ],
108 [ 'PPI::Token::QuoteLike::Words' =>
109 sub { return $_[0]->literal() }, ],
110 [ 'PPI::Token::Quote' => sub { return $_[0]->string() } ],
11116µs1106µs [ 'PPI::Node' => sub { _extract_potential_categories( $_[0] ) } ],
# spent 106µs making 1 call to Readonly::Array
112 );
113
114 sub _extract_potential_categories {
115 my ( $elem ) = @_;
116
117 my @words;
118 foreach my $child ( $elem->schildren() ) {
119 foreach my $hdlr ( @HANDLER ) {
120 $child->isa( $hdlr->[0] )
121 or next;
122 push @words, $hdlr->[1]->( $child );
123 last;
124 }
125 }
126
127 return @words;
128 }
129
130}
131
13215µs1;
133
134__END__