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

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/Modules/ProhibitAutomaticExportation.pm
StatementsExecuted 20 statements in 565µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs16µsPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::BEGIN@10Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@10
1119µs173µsPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::BEGIN@16Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@16
1117µs148µsPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::BEGIN@15Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@15
1117µs58µsPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::BEGIN@17Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@17
1117µs9µsPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::default_severityPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::default_severity
1117µs27µsPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::BEGIN@13Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@13
1117µs11µsPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::BEGIN@12Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@12
1117µs18µsPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::BEGIN@11Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@11
1112µs2µsPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::supported_parametersPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::supported_parameters
0000s0sPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::__ANON__[:64]Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::__ANON__[:64]
0000s0sPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::__ANON__[:77]Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::__ANON__[:77]
0000s0sPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::_has_exportsPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::_has_exports
0000s0sPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::_our_exportPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::_our_export
0000s0sPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::_package_exportPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::_package_export
0000s0sPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::_uses_exporterPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::_uses_exporter
0000s0sPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::_vars_exportPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::_vars_export
0000s0sPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::applies_toPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::applies_to
0000s0sPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::default_themesPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::default_themes
0000s0sPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::::violatesPerl::Critic::Policy::Modules::ProhibitAutomaticExportation::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::Modules::ProhibitAutomaticExportation;
9
10239µs116µs
# spent 16µs within Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@10 which was called: # once (16µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220µs229µs
# spent 18µs (7+11) within Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@11 which was called: # once (7µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 18µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@11 # spent 11µs making 1 call to strict::import
12218µs214µs
# spent 11µs (7+4) within Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::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::Modules::ProhibitAutomaticExportation::BEGIN@12 # spent 4µs making 1 call to warnings::import
13225µs247µs
# spent 27µs (7+20) within Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@13 which was called: # once (7µs+20µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 27µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@13 # spent 20µs making 1 call to Exporter::import
14
15224µs2290µs
# spent 148µs (7+141) within Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@15 which was called: # once (7µs+141µs) by Module::Pluggable::Object::_require at line 15
use Perl::Critic::Utils qw{ :severities };
# spent 148µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@15 # spent 141µs making 1 call to Exporter::import
16225µs2337µs
# spent 173µs (9+164) within Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@16 which was called: # once (9µs+164µs) by Module::Pluggable::Object::_require at line 16
use List::MoreUtils qw(any);
# spent 173µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@16 # spent 164µs making 1 call to Exporter::Tiny::import
172401µs2110µs
# spent 58µs (7+51) within Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@17 which was called: # once (7µs+51µs) by Module::Pluggable::Object::_require at line 17
use base 'Perl::Critic::Policy';
# spent 58µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@17 # spent 51µs making 1 call to base::import
18
191600nsour $VERSION = '1.121';
20
21#-----------------------------------------------------------------------------
22
2312µs129µsReadonly::Scalar my $DESC => q{Symbols are exported by default};
# spent 29µs making 1 call to Readonly::Scalar
241900ns121µsReadonly::Scalar my $EXPL => q{Use '@EXPORT_OK' or '%EXPORT_TAGS' instead}; ## no critic (RequireInterpolation)
# spent 21µs making 1 call to Readonly::Scalar
25
26#-----------------------------------------------------------------------------
27
2815µs
# spent 2µs within Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::supported_parameters which was called: # once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters { return () }
2912µs
# spent 9µs (7+2) within Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::default_severity which was called: # once (7µs+2µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm
sub default_severity { return $SEVERITY_HIGH }
30sub default_themes { return qw( core bugs ) }
31sub applies_to { return 'PPI::Document' }
32
33#-----------------------------------------------------------------------------
34
35sub violates {
36 my ( $self, $elem, $doc ) = @_;
37
38 if ( _uses_exporter($doc) ) {
39 if ( my $exp = _has_exports($doc) ) {
40 return $self->violation( $DESC, $EXPL, $exp );
41 }
42 }
43 return; #ok
44}
45
46#-----------------------------------------------------------------------------
47
48sub _uses_exporter {
49 my ($doc) = @_;
50
51 my $includes_ref = $doc->find('PPI::Statement::Include');
52 return if not $includes_ref;
53
54 # This covers both C<use Exporter;> and C<use base 'Exporter';>
55 return scalar grep { m/ \b Exporter \b/xms } @{ $includes_ref };
56}
57
58#------------------
59
60sub _has_exports {
61 my ($doc) = @_;
62
63 my $wanted =
64 sub { _our_export(@_) or _vars_export(@_) or _package_export(@_) };
65
66 return $doc->find_first( $wanted );
67}
68
69#------------------
70
71sub _our_export {
72 my (undef, $elem) = @_;
73
74 $elem->isa('PPI::Statement::Variable') or return 0;
75 $elem->type() eq 'our' or return 0;
76
77 return any { $_ eq '@EXPORT' } $elem->variables(); ## no critic(RequireInterpolationOfMetachars)
78}
79
80#------------------
81
82sub _vars_export {
83 my (undef, $elem) = @_;
84
85 $elem->isa('PPI::Statement::Include') or return 0;
86 $elem->pragma() eq 'vars' or return 0;
87
88 return $elem =~ m{ \@EXPORT \b }xms; #Crude, but usually works
89}
90
91#------------------
92
93sub _package_export {
94 my (undef, $elem) = @_;
95
96 $elem->isa('PPI::Token::Symbol') or return 0;
97
98 return $elem =~ m{ \A \@ \S+ ::EXPORT \z }xms;
99 #TODO: ensure that it is in _this_ package!
100}
101
10213µs1;
103
104__END__