← 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__