← 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/Documentation/RequirePackageMatchesPodName.pm
StatementsExecuted 21 statements in 611µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11117µs17µsPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::BEGIN@10Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@10
11114µs408µsPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::BEGIN@16Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@16
11110µs34µsPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::BEGIN@15Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@15
1118µs61µsPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::BEGIN@18Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@18
1118µs14µsPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::BEGIN@13Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@13
1117µs399µsPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::BEGIN@17Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@17
1117µs19µsPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::BEGIN@12Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@12
1116µs8µsPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::default_severityPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::default_severity
1112µs2µsPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::supported_parametersPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::supported_parameters
1112µs2µsPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::CORE:qrPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::CORE:qr (opcode)
0000s0sPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::applies_toPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::applies_to
0000s0sPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::default_themesPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::default_themes
0000s0sPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::prepare_to_scan_documentPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::prepare_to_scan_document
0000s0sPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::::violatesPerl::Critic::Policy::Documentation::RequirePackageMatchesPodName::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::Documentation::RequirePackageMatchesPodName;
9
10242µs117µs
# spent 17µs within Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@10 which was called: # once (17µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11
12220µs231µs
# spent 19µs (7+12) within Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@12 which was called: # once (7µs+12µs) by Module::Pluggable::Object::_require at line 12
use strict;
# spent 19µs making 1 call to Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@12 # spent 12µs making 1 call to strict::import
13224µs221µs
# spent 14µs (8+7) within Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@13 which was called: # once (8µs+7µs) by Module::Pluggable::Object::_require at line 13
use warnings;
# spent 14µs making 1 call to Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@13 # spent 7µs making 1 call to warnings::import
14
15225µs257µs
# spent 34µs (10+23) within Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@15 which was called: # once (10µs+23µs) by Module::Pluggable::Object::_require at line 15
use Readonly;
# spent 34µs making 1 call to Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@15 # spent 23µs making 1 call to Exporter::import
16227µs2802µs
# spent 408µs (14+394) within Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@16 which was called: # once (14µs+394µs) by Module::Pluggable::Object::_require at line 16
use English qw{ -no_match_vars };
# spent 408µs making 1 call to Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@16 # spent 394µs making 1 call to English::import
17225µs2790µs
# spent 399µs (7+391) within Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@17 which was called: # once (7µs+391µs) by Module::Pluggable::Object::_require at line 17
use Perl::Critic::Utils qw{ :severities :classification };
# spent 399µs making 1 call to Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@17 # spent 391µs making 1 call to Exporter::import
182424µs2115µs
# spent 61µs (8+54) within Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@18 which was called: # once (8µs+54µs) by Module::Pluggable::Object::_require at line 18
use base 'Perl::Critic::Policy';
# spent 61µs making 1 call to Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::BEGIN@18 # spent 54µs making 1 call to base::import
19
201600nsour $VERSION = '1.121';
21
22#-----------------------------------------------------------------------------
23
24110µs230µsReadonly::Scalar my $PKG_RX => qr{ [[:alpha:]](?:[\w:\']*\w)? }xms;
# spent 28µs making 1 call to Readonly::Scalar # spent 2µs making 1 call to Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::CORE:qr
251900ns122µsReadonly::Scalar my $DESC =>
# spent 22µs making 1 call to Readonly::Scalar
26 q{Pod NAME on line %d does not match the package declaration};
271900ns120µsReadonly::Scalar my $EXPL => q{};
# spent 20µs making 1 call to Readonly::Scalar
28
29#-----------------------------------------------------------------------------
30
3114µs
# spent 2µs within Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::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 () }
3212µs
# spent 8µs (6+1) within Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::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_LOWEST }
33sub default_themes { return qw( core cosmetic ) }
34sub applies_to { return 'PPI::Document' }
35
36#-----------------------------------------------------------------------------
37
38sub prepare_to_scan_document {
39 my ( $self, $document ) = @_;
40
41 # idea: force NAME to match the file name in programs?
42 return $document->is_module(); # mismatch is normal in program entry points
43}
44
45sub violates {
46 my ( $self, $elem, $doc ) = @_;
47
48 # No POD means no violation
49 my $pods_ref = $doc->find('PPI::Token::Pod');
50 return if !$pods_ref;
51
52 for my $pod (@{$pods_ref}) {
53 my $content = $pod->content;
54
55 next if $content !~ m{^=head1 [ \t]+ NAME [ \t]*$ \s*}cgxms;
56
57 my $line_number = $pod->line_number() + (
58 substr( $content, 0, $LAST_MATCH_START[0] + 1 ) =~ tr/\n/\n/ );
59
60 my ($pod_pkg) = $content =~ m{\G (\S+) }cgxms;
61
62 if (!$pod_pkg) {
63 return $self->violation( sprintf( $DESC, $line_number ),
64 q{Empty name declaration}, $pod );
65 }
66
67 # idea: worry about POD escapes?
68 $pod_pkg =~ s{\A [CL]<(.*)>\z}{$1}gxms; # unwrap
69 $pod_pkg =~ s{\'}{::}gxms; # perl4 -> perl5
70
71 foreach my $stmt ( @{ $doc->find('PPI::Statement::Package') || [] } ) {
72 my $pkg = $stmt->namespace();
73 $pkg =~ s{\'}{::}gxms;
74 return if $pkg eq $pod_pkg;
75 }
76
77 return $self->violation( sprintf( $DESC, $line_number ),
78 $EXPL, $pod );
79 }
80
81 return; # no NAME section found
82}
83
8416µs1;
85
86__END__
 
# spent 2µs within Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::CORE:qr which was called: # once (2µs+0s) by Module::Pluggable::Object::_require at line 24
sub Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName::CORE:qr; # opcode