← 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/RequireVersionVar.pm
StatementsExecuted 20 statements in 608µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11119µs19µsPerl::Critic::Policy::Modules::RequireVersionVar::::BEGIN@10Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@10
1118µs59µsPerl::Critic::Policy::Modules::RequireVersionVar::::BEGIN@18Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@18
1117µs11µsPerl::Critic::Policy::Modules::RequireVersionVar::::BEGIN@12Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@12
1117µs154µsPerl::Critic::Policy::Modules::RequireVersionVar::::BEGIN@15Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@15
1117µs28µsPerl::Critic::Policy::Modules::RequireVersionVar::::BEGIN@13Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@13
1117µs148µsPerl::Critic::Policy::Modules::RequireVersionVar::::BEGIN@17Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@17
1116µs18µsPerl::Critic::Policy::Modules::RequireVersionVar::::BEGIN@11Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@11
1116µs7µsPerl::Critic::Policy::Modules::RequireVersionVar::::default_severityPerl::Critic::Policy::Modules::RequireVersionVar::default_severity
1112µs2µsPerl::Critic::Policy::Modules::RequireVersionVar::::supported_parametersPerl::Critic::Policy::Modules::RequireVersionVar::supported_parameters
0000s0sPerl::Critic::Policy::Modules::RequireVersionVar::::__ANON__[:62]Perl::Critic::Policy::Modules::RequireVersionVar::__ANON__[:62]
0000s0sPerl::Critic::Policy::Modules::RequireVersionVar::::_is_our_versionPerl::Critic::Policy::Modules::RequireVersionVar::_is_our_version
0000s0sPerl::Critic::Policy::Modules::RequireVersionVar::::_is_package_argument_versionPerl::Critic::Policy::Modules::RequireVersionVar::_is_package_argument_version
0000s0sPerl::Critic::Policy::Modules::RequireVersionVar::::_is_package_versionPerl::Critic::Policy::Modules::RequireVersionVar::_is_package_version
0000s0sPerl::Critic::Policy::Modules::RequireVersionVar::::_is_readonly_versionPerl::Critic::Policy::Modules::RequireVersionVar::_is_readonly_version
0000s0sPerl::Critic::Policy::Modules::RequireVersionVar::::_is_vars_versionPerl::Critic::Policy::Modules::RequireVersionVar::_is_vars_version
0000s0sPerl::Critic::Policy::Modules::RequireVersionVar::::_is_version_declarationPerl::Critic::Policy::Modules::RequireVersionVar::_is_version_declaration
0000s0sPerl::Critic::Policy::Modules::RequireVersionVar::::applies_toPerl::Critic::Policy::Modules::RequireVersionVar::applies_to
0000s0sPerl::Critic::Policy::Modules::RequireVersionVar::::default_themesPerl::Critic::Policy::Modules::RequireVersionVar::default_themes
0000s0sPerl::Critic::Policy::Modules::RequireVersionVar::::violatesPerl::Critic::Policy::Modules::RequireVersionVar::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::RequireVersionVar;
9
10243µs119µs
# spent 19µs within Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@10 which was called: # once (19µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11223µs230µs
# spent 18µs (6+12) within Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@11 which was called: # once (6µs+12µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 18µs making 1 call to Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@11 # spent 12µs making 1 call to strict::import
12222µs215µs
# spent 11µs (7+4) within Perl::Critic::Policy::Modules::RequireVersionVar::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::RequireVersionVar::BEGIN@12 # spent 4µs making 1 call to warnings::import
13222µs249µs
# spent 28µs (7+21) within Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@13 which was called: # once (7µs+21µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 28µs making 1 call to Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@13 # spent 21µs making 1 call to Exporter::import
14
15224µs2301µs
# spent 154µs (7+147) within Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@15 which was called: # once (7µs+147µs) by Module::Pluggable::Object::_require at line 15
use List::MoreUtils qw(any);
# spent 154µs making 1 call to Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@15 # spent 147µs making 1 call to Exporter::Tiny::import
16
17226µs2289µs
# spent 148µs (7+141) within Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@17 which was called: # once (7µs+141µs) by Module::Pluggable::Object::_require at line 17
use Perl::Critic::Utils qw{ :severities };
# spent 148µs making 1 call to Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@17 # spent 141µs making 1 call to Exporter::import
182433µs2110µs
# spent 59µs (8+51) within Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@18 which was called: # once (8µs+51µs) by Module::Pluggable::Object::_require at line 18
use base 'Perl::Critic::Policy';
# spent 59µs making 1 call to Perl::Critic::Policy::Modules::RequireVersionVar::BEGIN@18 # spent 51µs making 1 call to base::import
19
201600nsour $VERSION = '1.121';
21
22#-----------------------------------------------------------------------------
23
2412µs129µsReadonly::Scalar my $DESC => q{No package-scoped "$VERSION" variable found}; ## no critic (RequireInterpolation)
# spent 29µs making 1 call to Readonly::Scalar
2512µs145µsReadonly::Scalar my $EXPL => [ 404 ];
# spent 45µs making 1 call to Readonly::Scalar
26
27#-----------------------------------------------------------------------------
28
2914µs
# spent 2µs within Perl::Critic::Policy::Modules::RequireVersionVar::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 () }
3012µs
# spent 7µs (6+1) within Perl::Critic::Policy::Modules::RequireVersionVar::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_LOW }
31sub default_themes { return qw(core pbp readability) }
32sub applies_to { return 'PPI::Document' }
33
34#-----------------------------------------------------------------------------
35
36sub violates {
37 my ( $self, $elem, $doc ) = @_;
38
39 return if $doc->find_first( \&_is_version_declaration );
40
41 #If we get here, then no $VERSION was found
42 return $self->violation( $DESC, $EXPL, $doc );
43}
44
45#-----------------------------------------------------------------------------
46
47sub _is_version_declaration { ## no critic (ArgUnpacking)
48 return 1 if _is_our_version(@_);
49 return 1 if _is_vars_version(@_);
50 return 1 if _is_package_version(@_);
51 return 1 if _is_readonly_version(@_);
52 return 1 if _is_package_argument_version(@_);
53 return 0;
54}
55
56#-----------------------------------------------------------------------------
57
58sub _is_our_version {
59 my (undef, $elem) = @_;
60 $elem->isa('PPI::Statement::Variable') || return 0;
61 $elem->type() eq 'our' || return 0;
62 return any { $_ eq '$VERSION' } $elem->variables(); ## no critic (RequireInterpolation)
63}
64
65#-----------------------------------------------------------------------------
66
67sub _is_vars_version {
68 my (undef, $elem) = @_;
69 $elem->isa('PPI::Statement::Include') || return 0;
70 $elem->pragma() eq 'vars' || return 0;
71 return $elem =~ m{ \$VERSION }xms; #Crude, but usually works
72}
73
74#-----------------------------------------------------------------------------
75
76sub _is_package_version {
77 my (undef, $elem) = @_;
78 $elem->isa('PPI::Token::Symbol') || return 0;
79 return $elem =~ m{ \A \$ \S+ ::VERSION \z }xms;
80 #TODO: ensure that it is in _this_ package!
81}
82
83#-----------------------------------------------------------------------------
84
85sub _is_readonly_version {
86
87 #---------------------------------------------------------------
88 # Readonly VERSION statements usually come in one of two forms:
89 #
90 # Readonly our $VERSION = 1.0;
91 # Readonly::Scalar our $VERSION = 1.0;
92 #---------------------------------------------------------------
93
94 my (undef, $elem) = @_;
95 $elem->isa('PPI::Token::Symbol') || return 0;
96 return 0 if $elem !~ m{ \A \$VERSION \z }xms;
97
98 my $psib = $elem->sprevious_sibling() || return 0;
99 return 0 if $psib ne 'our';
100
101 my $ppsib = $psib->sprevious_sibling() || return 0;
102 return $ppsib eq 'Readonly' || $ppsib eq 'Readonly::Scalar';
103}
104
105#-----------------------------------------------------------------------------
106
107sub _is_package_argument_version {
108 my (undef, $elem) = @_;
109 $elem->isa( 'PPI::Statement::Package' ) or return 0;
110 # Perldoc for 5.12.3 documents the statement as
111 # package NAMESPACE VERSION
112 # with no comma, and the compiler in fact does not accept one.
113 my $ver = $elem->schild( 2 )
114 or return 0;
115 return $ver->isa( 'PPI::Token::Number' );
116}
117
11813µs1;
119
120__END__