Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/Objects/ProhibitIndirectSyntax.pm |
Statements | Executed 24 statements in 428µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 19µs | 19µs | BEGIN@10 | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
1 | 1 | 1 | 8µs | 26µs | BEGIN@17 | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
1 | 1 | 1 | 8µs | 11µs | BEGIN@12 | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
1 | 1 | 1 | 8µs | 398µs | BEGIN@16 | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
1 | 1 | 1 | 7µs | 374µs | BEGIN@15 | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
1 | 1 | 1 | 7µs | 37µs | BEGIN@14 | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
1 | 1 | 1 | 7µs | 60µs | BEGIN@19 | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
1 | 1 | 1 | 7µs | 17µs | BEGIN@11 | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
1 | 1 | 1 | 6µs | 6µs | supported_parameters | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
0 | 0 | 0 | 0s | 0s | applies_to | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
0 | 0 | 0 | 0s | 0s | violates | Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::
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::Objects::ProhibitIndirectSyntax; | ||||
9 | |||||
10 | 2 | 38µs | 1 | 19µs | # spent 19µs within Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@10 which was called:
# once (19µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 19µs making 1 call to Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@10 |
11 | 2 | 20µs | 2 | 28µs | # spent 17µs (7+10) within Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@11 which was called:
# once (7µs+10µs) by Module::Pluggable::Object::_require at line 11 # spent 17µs making 1 call to Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@11
# spent 10µs making 1 call to strict::import |
12 | 2 | 18µs | 2 | 15µs | # spent 11µs (8+4) within Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::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::Objects::ProhibitIndirectSyntax::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | |||||
14 | 2 | 21µs | 2 | 66µs | # spent 37µs (7+30) within Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@14 which was called:
# once (7µs+30µs) by Module::Pluggable::Object::_require at line 14 # spent 37µs making 1 call to Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@14
# spent 30µs making 1 call to Exporter::import |
15 | 2 | 25µs | 2 | 741µs | # spent 374µs (7+367) within Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@15 which was called:
# once (7µs+367µs) by Module::Pluggable::Object::_require at line 15 # spent 374µs making 1 call to Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@15
# spent 367µs making 1 call to English::import |
16 | 2 | 22µs | 2 | 789µs | # spent 398µs (8+391) within Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@16 which was called:
# once (8µs+391µs) by Module::Pluggable::Object::_require at line 16 # spent 398µs making 1 call to Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@16
# spent 391µs making 1 call to Exporter::import |
17 | 2 | 21µs | 2 | 45µs | # spent 26µs (8+18) within Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@17 which was called:
# once (8µs+18µs) by Module::Pluggable::Object::_require at line 17 # spent 26µs making 1 call to Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@17
# spent 18µs making 1 call to Exporter::import |
18 | |||||
19 | 2 | 243µs | 2 | 112µs | # spent 60µs (7+52) within Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@19 which was called:
# once (7µs+52µs) by Module::Pluggable::Object::_require at line 19 # spent 60µs making 1 call to Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::BEGIN@19
# spent 52µs making 1 call to base::import |
20 | |||||
21 | 1 | 600ns | our $VERSION = '1.121'; | ||
22 | |||||
23 | #----------------------------------------------------------------------------- | ||||
24 | |||||
25 | 1 | 4µs | 1 | 31µs | Readonly::Hash my %COMMA => { # spent 31µs making 1 call to Readonly::Hash |
26 | q<,> => 1, | ||||
27 | q{=>} => 1, | ||||
28 | }; | ||||
29 | 1 | 1µs | 1 | 22µs | Readonly::Scalar my $DOLLAR => q<$>; # spent 22µs making 1 call to Readonly::Scalar |
30 | |||||
31 | 1 | 900ns | 1 | 20µs | Readonly::Scalar my $DESC => 'Subroutine "%s" called using indirect syntax'; # spent 20µs making 1 call to Readonly::Scalar |
32 | 1 | 2µs | 1 | 40µs | Readonly::Scalar my $EXPL => [ 349 ]; # spent 40µs making 1 call to Readonly::Scalar |
33 | |||||
34 | #----------------------------------------------------------------------------- | ||||
35 | |||||
36 | # spent 6µs within Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::supported_parameters which was called:
# once (6µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||||
37 | return ( | ||||
38 | { | ||||
39 | 1 | 8µs | name => 'forbid', | ||
40 | description => 'Indirect method syntax is forbidden for these methods.', | ||||
41 | behavior => 'string list', | ||||
42 | list_always_present_values => [ qw{ new } ], | ||||
43 | } | ||||
44 | ) | ||||
45 | } | ||||
46 | |||||
47 | 1 | 2µs | # spent 7µs (6+1) within Perl::Critic::Policy::Objects::ProhibitIndirectSyntax::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
48 | sub default_themes { return qw( core pbp maintenance certrule ) } | ||||
49 | sub applies_to { return 'PPI::Token::Word' } | ||||
50 | |||||
51 | #----------------------------------------------------------------------------- | ||||
52 | |||||
53 | sub violates { | ||||
54 | my ( $self, $elem, $doc ) = @_; | ||||
55 | |||||
56 | # We are only interested in the functions we have been told to check. | ||||
57 | # Do this before calling is_function_call() because we want to weed | ||||
58 | # out as many candidate tokens as possible before calling it. | ||||
59 | return if not $self->{_forbid}->{$elem->content()}; | ||||
60 | |||||
61 | # Make sure it really is a function call. | ||||
62 | return if not is_function_call($elem); | ||||
63 | |||||
64 | # Per perlobj, it is only an indirect object call if the next sibling | ||||
65 | # is a word, a scalar symbol, or a block. | ||||
66 | my $object = $elem->snext_sibling() or return; | ||||
67 | return if not ( | ||||
68 | $object->isa( 'PPI::Token::Word' ) | ||||
69 | or $object->isa( 'PPI::Token::Symbol' ) | ||||
70 | and $DOLLAR eq $object->raw_type() | ||||
71 | or $object->isa( 'PPI::Structure::Block' ) | ||||
72 | ); | ||||
73 | |||||
74 | # Per perlobj, it is not an indirect object call if the operator after | ||||
75 | # the possible indirect object is a comma. | ||||
76 | if ( my $operator = $object->snext_sibling() ) { | ||||
77 | return if | ||||
78 | $operator->isa( 'PPI::Token::Operator' ) | ||||
79 | and $COMMA{ $operator->content() }; | ||||
80 | } | ||||
81 | |||||
82 | my $message = sprintf $DESC, $elem->content(); | ||||
83 | |||||
84 | return $self->violation( $message, $EXPL, $elem ); | ||||
85 | } | ||||
86 | |||||
87 | 1 | 4µs | 1; | ||
88 | |||||
89 | __END__ |