Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/TestingAndDebugging/ProhibitNoStrict.pm |
Statements | Executed 2132 statements in 3.85ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
982 | 1 | 1 | 3.30ms | 20.3ms | violates | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
144 | 1 | 1 | 330µs | 330µs | applies_to | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
1 | 1 | 1 | 16µs | 16µs | BEGIN@10 | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
1 | 1 | 1 | 14µs | 16µs | supported_parameters | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
1 | 1 | 1 | 13µs | 67µs | BEGIN@18 | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
1 | 1 | 1 | 8µs | 194µs | BEGIN@15 | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
1 | 1 | 1 | 8µs | 394µs | BEGIN@17 | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
1 | 1 | 1 | 8µs | 11µs | BEGIN@12 | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
1 | 1 | 1 | 7µs | 28µs | BEGIN@13 | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
1 | 1 | 1 | 6µs | 6µs | _parse_allow | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
0 | 0 | 0 | 0s | 0s | __ANON__[:82] | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ############################################################################## | ||||
2 | # $URL$ | ||||
3 | # $Date$ | ||||
4 | # $Author$ | ||||
5 | # $Revision$ | ||||
6 | ############################################################################## | ||||
7 | |||||
8 | package Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict; | ||||
9 | |||||
10 | 2 | 40µs | 1 | 16µs | # spent 16µs within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@10 which was called:
# once (16µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 16µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@10 |
11 | 2 | 20µs | 2 | 29µs | # spent 18µs (7+11) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@11 which was called:
# once (7µs+11µs) by Module::Pluggable::Object::_require at line 11 # spent 18µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 19µs | 2 | 15µs | # spent 11µs (8+4) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@12 which was called:
# once (8µs+4µs) by Module::Pluggable::Object::_require at line 12 # spent 11µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 23µs | 2 | 49µs | # spent 28µs (7+21) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@13 which was called:
# once (7µs+21µs) by Module::Pluggable::Object::_require at line 13 # spent 28µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@13
# spent 21µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 28µs | 2 | 379µs | # spent 194µs (8+185) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@15 which was called:
# once (8µs+185µs) by Module::Pluggable::Object::_require at line 15 # spent 194µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@15
# spent 185µs making 1 call to Exporter::Tiny::import |
16 | |||||
17 | 2 | 24µs | 2 | 779µs | # spent 394µs (8+386) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@17 which was called:
# once (8µs+386µs) by Module::Pluggable::Object::_require at line 17 # spent 394µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@17
# spent 386µs making 1 call to Exporter::import |
18 | 2 | 293µs | 2 | 121µs | # spent 67µs (13+54) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@18 which was called:
# once (13µs+54µs) by Module::Pluggable::Object::_require at line 18 # spent 67µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::BEGIN@18
# spent 54µs making 1 call to base::import |
19 | |||||
20 | 1 | 600ns | our $VERSION = '1.121'; | ||
21 | |||||
22 | #----------------------------------------------------------------------------- | ||||
23 | |||||
24 | 1 | 2µs | 1 | 30µs | Readonly::Scalar my $DESC => q{Stricture disabled}; # spent 30µs making 1 call to Readonly::Scalar |
25 | 1 | 2µs | 1 | 45µs | Readonly::Scalar my $EXPL => [ 429 ]; # spent 45µs making 1 call to Readonly::Scalar |
26 | |||||
27 | #----------------------------------------------------------------------------- | ||||
28 | |||||
29 | # spent 16µs (14+2) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::supported_parameters which was called:
# once (14µs+2µs) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||||
30 | return ( | ||||
31 | { | ||||
32 | 1 | 11µs | 2 | 2µs | name => 'allow', # spent 2µs making 2 calls to Readonly::Scalar::FETCH, avg 1µs/call |
33 | description => 'Allow vars, subs, and/or refs.', | ||||
34 | default_string => $EMPTY, | ||||
35 | parser => \&_parse_allow, | ||||
36 | }, | ||||
37 | ); | ||||
38 | } | ||||
39 | |||||
40 | 1 | 1µs | # spent 7µs (6+1) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
41 | sub default_themes { return qw( core pbp bugs certrec ) } | ||||
42 | 144 | 430µs | # spent 330µs within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::applies_to which was called 144 times, avg 2µs/call:
# 144 times (330µs+0s) by Perl::Critic::_critique at line 165 of Perl/Critic.pm, avg 2µs/call | ||
43 | |||||
44 | #----------------------------------------------------------------------------- | ||||
45 | |||||
46 | # spent 6µs within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::_parse_allow which was called:
# once (6µs+0s) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 231 of Perl/Critic/PolicyParameter.pm | ||||
47 | 1 | 700ns | my ($self, $parameter, $config_string) = @_; | ||
48 | |||||
49 | 1 | 2µs | $self->{_allow} = {}; | ||
50 | |||||
51 | 1 | 400ns | if( defined $config_string ) { | ||
52 | my $allowed = lc $config_string; #String of words | ||||
53 | my %allowed = hashify( $allowed =~ m/ (\w+) /gxms ); | ||||
54 | $self->{_allow} = \%allowed; | ||||
55 | } | ||||
56 | |||||
57 | 1 | 4µs | return; | ||
58 | } | ||||
59 | |||||
60 | #----------------------------------------------------------------------------- | ||||
61 | |||||
62 | # spent 20.3ms (3.30+17.0) within Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::violates which was called 982 times, avg 21µs/call:
# 982 times (3.30ms+17.0ms) by Perl::Critic::_critique at line 183 of Perl/Critic.pm, avg 21µs/call | ||||
63 | 982 | 286µs | my ( $self, $elem, undef ) = @_; | ||
64 | |||||
65 | 982 | 2.66ms | 982 | 17.0ms | return if $elem->type() ne 'no'; # spent 17.0ms making 982 calls to PPI::Statement::Include::type, avg 17µs/call |
66 | return if $elem->pragma() ne 'strict'; | ||||
67 | |||||
68 | #Arguments to 'no strict' are usually a list of literals or a qw() | ||||
69 | #list. Rather than trying to parse the various PPI elements, I | ||||
70 | #just use a regex to split the statement into words. This is | ||||
71 | #kinda lame, but it does the trick for now. | ||||
72 | |||||
73 | # TODO consider: a possible alternate implementation: | ||||
74 | # my $re = join q{|}, keys %{$self->{allow}}; | ||||
75 | # return if $re && $stmnt =~ m/\b(?:$re)\b/mx; | ||||
76 | # May need to detaint for that to work... Not sure. | ||||
77 | |||||
78 | my $stmnt = $elem->statement(); | ||||
79 | return if !$stmnt; | ||||
80 | my @words = $stmnt =~ m/ ([[:lower:]]+) /gxms; | ||||
81 | @words = grep { $_ ne 'qw' && $_ ne 'no' && $_ ne 'strict' } @words; | ||||
82 | return if @words && all { exists $self->{_allow}->{$_} } @words; | ||||
83 | |||||
84 | #If we get here, then it must be a violation | ||||
85 | return $self->violation( $DESC, $EXPL, $elem ); | ||||
86 | } | ||||
87 | |||||
88 | 1 | 3µs | 1; | ||
89 | |||||
90 | __END__ |