| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/Modules/ProhibitAutomaticExportation.pm |
| Statements | Executed 20 statements in 565µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 16µs | 16µs | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@10 |
| 1 | 1 | 1 | 9µs | 173µs | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@16 |
| 1 | 1 | 1 | 7µs | 148µs | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@15 |
| 1 | 1 | 1 | 7µs | 58µs | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@17 |
| 1 | 1 | 1 | 7µs | 9µs | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::default_severity |
| 1 | 1 | 1 | 7µs | 27µs | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@13 |
| 1 | 1 | 1 | 7µs | 11µs | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@12 |
| 1 | 1 | 1 | 7µs | 18µs | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@11 |
| 1 | 1 | 1 | 2µs | 2µs | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::supported_parameters |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::__ANON__[:64] |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::__ANON__[:77] |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::_has_exports |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::_our_export |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::_package_export |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::_uses_exporter |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::_vars_export |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::applies_to |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::default_themes |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::violates |
| 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::Modules::ProhibitAutomaticExportation; | ||||
| 9 | |||||
| 10 | 2 | 39µs | 1 | 16µ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 # spent 16µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@10 |
| 11 | 2 | 20µs | 2 | 29µ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 # spent 18µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@11
# spent 11µs making 1 call to strict::import |
| 12 | 2 | 18µs | 2 | 14µ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 # spent 11µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@12
# spent 4µs making 1 call to warnings::import |
| 13 | 2 | 25µs | 2 | 47µ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 # spent 27µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@13
# spent 20µs making 1 call to Exporter::import |
| 14 | |||||
| 15 | 2 | 24µs | 2 | 290µ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 # spent 148µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@15
# spent 141µs making 1 call to Exporter::import |
| 16 | 2 | 25µs | 2 | 337µ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 # spent 173µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@16
# spent 164µs making 1 call to Exporter::Tiny::import |
| 17 | 2 | 401µs | 2 | 110µ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 # spent 58µs making 1 call to Perl::Critic::Policy::Modules::ProhibitAutomaticExportation::BEGIN@17
# spent 51µs making 1 call to base::import |
| 18 | |||||
| 19 | 1 | 600ns | our $VERSION = '1.121'; | ||
| 20 | |||||
| 21 | #----------------------------------------------------------------------------- | ||||
| 22 | |||||
| 23 | 1 | 2µs | 1 | 29µs | Readonly::Scalar my $DESC => q{Symbols are exported by default}; # spent 29µs making 1 call to Readonly::Scalar |
| 24 | 1 | 900ns | 1 | 21µs | Readonly::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 | |||||
| 28 | 1 | 5µ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 | ||
| 29 | 1 | 2µ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 | ||
| 30 | sub default_themes { return qw( core bugs ) } | ||||
| 31 | sub applies_to { return 'PPI::Document' } | ||||
| 32 | |||||
| 33 | #----------------------------------------------------------------------------- | ||||
| 34 | |||||
| 35 | sub 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 | |||||
| 48 | sub _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 | |||||
| 60 | sub _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 | |||||
| 71 | sub _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 | |||||
| 82 | sub _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 | |||||
| 93 | sub _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 | |||||
| 102 | 1 | 3µs | 1; | ||
| 103 | |||||
| 104 | __END__ |