← 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/PodSpelling.pm
StatementsExecuted 36 statements in 1.49ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1114.99ms13.3msPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@18Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@18
111902┬Ás842msPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@21Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21
111809┬Ás900┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@22Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@22
11124┬Ás29┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::supported_parametersPerl::Critic::Policy::Documentation::PodSpelling::supported_parameters
11118┬Ás18┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@10Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@10
11113┬Ás36┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@30Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@30
11111┬Ás442┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@24Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@24
11110┬Ás81┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@32Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@32
1118┬Ás170┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@20Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@20
1118┬Ás12┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@12Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@12
1118┬Ás21┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@11Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@11
1118┬Ás455┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@14Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@14
1118┬Ás27┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@15Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@15
1116┬Ás8┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::default_severityPerl::Critic::Policy::Documentation::PodSpelling::default_severity
1115┬Ás5┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@17Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@17
1114┬Ás4┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::BEGIN@19Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@19
1112┬Ás2┬ÁsPerl::Critic::Policy::Documentation::PodSpelling::::CORE:qrPerl::Critic::Policy::Documentation::PodSpelling::CORE:qr (opcode)
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::__ANON__[:208]Perl::Critic::Policy::Documentation::PodSpelling::__ANON__[:208]
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::_derive_spell_command_linePerl::Critic::Policy::Documentation::PodSpelling::_derive_spell_command_line
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::_get_spell_commandPerl::Critic::Policy::Documentation::PodSpelling::_get_spell_command
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::_get_spell_command_linePerl::Critic::Policy::Documentation::PodSpelling::_get_spell_command_line
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::_get_stop_wordsPerl::Critic::Policy::Documentation::PodSpelling::_get_stop_words
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::_get_stop_words_filePerl::Critic::Policy::Documentation::PodSpelling::_get_stop_words_file
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::_load_stop_words_filePerl::Critic::Policy::Documentation::PodSpelling::_load_stop_words_file
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::_run_spell_commandPerl::Critic::Policy::Documentation::PodSpelling::_run_spell_command
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::_set_spell_command_linePerl::Critic::Policy::Documentation::PodSpelling::_set_spell_command_line
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::_set_stop_wordsPerl::Critic::Policy::Documentation::PodSpelling::_set_stop_words
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::_word_from_linePerl::Critic::Policy::Documentation::PodSpelling::_word_from_line
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::applies_toPerl::Critic::Policy::Documentation::PodSpelling::applies_to
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::default_themesPerl::Critic::Policy::Documentation::PodSpelling::default_themes
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::got_sigpipePerl::Critic::Policy::Documentation::PodSpelling::got_sigpipe
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::initialize_if_enabledPerl::Critic::Policy::Documentation::PodSpelling::initialize_if_enabled
0000s0sPerl::Critic::Policy::Documentation::PodSpelling::::violatesPerl::Critic::Policy::Documentation::PodSpelling::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::PodSpelling;
9
10248┬Ás118┬Ás
# spent 18┬Ás within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@10 which was called: # once (18┬Ás+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11223┬Ás234┬Ás
# spent 21┬Ás (8+13) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@11 which was called: # once (8┬Ás+13┬Ás) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 21┬Ás making 1 call to Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@11 # spent 13┬Ás making 1 call to strict::import
12224┬Ás217┬Ás
# spent 12┬Ás (8+4) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@12 which was called: # once (8┬Ás+4┬Ás) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 12┬Ás making 1 call to Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@12 # spent 4┬Ás making 1 call to warnings::import
13
14224┬Ás2903┬Ás
# spent 455┬Ás (8+448) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@14 which was called: # once (8┬Ás+448┬Ás) by Module::Pluggable::Object::_require at line 14
use English qw(-no_match_vars);
# spent 455┬Ás making 1 call to Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@14 # spent 448┬Ás making 1 call to English::import
15221┬Ás247┬Ás
# spent 27┬Ás (8+20) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@15 which was called: # once (8┬Ás+20┬Ás) by Module::Pluggable::Object::_require at line 15
use Readonly;
# spent 27┬Ás making 1 call to Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@15 # spent 20┬Ás making 1 call to Exporter::import
16
17218┬Ás15┬Ás
# spent 5┬Ás within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@17 which was called: # once (5┬Ás+0s) by Module::Pluggable::Object::_require at line 17
use File::Spec;
182106┬Ás213.3ms
# spent 13.3ms (4.99+8.30) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@18 which was called: # once (4.99ms+8.30ms) by Module::Pluggable::Object::_require at line 18
use File::Temp;
# spent 13.3ms making 1 call to Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@18 # spent 50┬Ás making 1 call to Exporter::import
19221┬Ás14┬Ás
# spent 4┬Ás within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@19 which was called: # once (4┬Ás+0s) by Module::Pluggable::Object::_require at line 19
use IO::String qw< >;
20224┬Ás2332┬Ás
# spent 170┬Ás (8+162) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@20 which was called: # once (8┬Ás+162┬Ás) by Module::Pluggable::Object::_require at line 20
use List::MoreUtils qw(uniq);
# spent 170┬Ás making 1 call to Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@20 # spent 162┬Ás making 1 call to Exporter::Tiny::import
21290┬Ás1842ms
# spent 842ms (902┬Ás+841) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 which was called: # once (902┬Ás+841ms) by Module::Pluggable::Object::_require at line 21
use Pod::Spell qw< >;
22295┬Ás1900┬Ás
# spent 900┬Ás (809+91) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@22 which was called: # once (809┬Ás+91┬Ás) by Module::Pluggable::Object::_require at line 22
use Text::ParseWords qw< >;
23
241600ns
# spent 442┬Ás (11+431) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@24 which was called: # once (11┬Ás+431┬Ás) by Module::Pluggable::Object::_require at line 29
use Perl::Critic::Utils qw{
25 :characters
26 :booleans
27 :severities
28 words_from_string
29130┬Ás2873┬Ás};
# spent 442┬Ás making 1 call to Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@24 # spent 431┬Ás making 1 call to Exporter::import
30228┬Ás258┬Ás
# spent 36┬Ás (13+22) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@30 which was called: # once (13┬Ás+22┬Ás) by Module::Pluggable::Object::_require at line 30
use Perl::Critic::Exception::Fatal::Generic qw{ throw_generic };
# spent 36┬Ás making 1 call to Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@30 # spent 22┬Ás making 1 call to Exporter::import
31
322890┬Ás2152┬Ás
# spent 81┬Ás (10+71) within Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@32 which was called: # once (10┬Ás+71┬Ás) by Module::Pluggable::Object::_require at line 32
use base 'Perl::Critic::Policy';
# spent 81┬Ás making 1 call to Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@32 # spent 71┬Ás making 1 call to base::import
33
341600nsour $VERSION = '1.121';
35
36#-----------------------------------------------------------------------------
37
38111┬Ás247┬ÁsReadonly::Scalar my $POD_RX => qr{\A = (?: for|begin|end ) }xms;
# spent 46┬Ás making 1 call to Readonly::Scalar # spent 2┬Ás making 1 call to Perl::Critic::Policy::Documentation::PodSpelling::CORE:qr
3911┬Ás122┬ÁsReadonly::Scalar my $DESC => q{Check the spelling in your POD};
# spent 22┬Ás making 1 call to Readonly::Scalar
4012┬Ás151┬ÁsReadonly::Scalar my $EXPL => [148];
# spent 51┬Ás making 1 call to Readonly::Scalar
41
42#-----------------------------------------------------------------------------
43
44
# spent 29┬Ás (24+5) within Perl::Critic::Policy::Documentation::PodSpelling::supported_parameters which was called: # once (24┬Ás+5┬Ás) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
45 return (
46 {
47120┬Ás45┬Ás name => 'spell_command',
# spent 5┬Ás making 4 calls to Readonly::Scalar::FETCH, avg 1┬Ás/call
48 description => 'The command to invoke to check spelling.',
49 default_string => 'aspell list',
50 behavior => 'string',
51 },
52 {
53 name => 'stop_words',
54 description => 'The words to not consider as misspelled.',
55 default_string => $EMPTY,
56 behavior => 'string list',
57 },
58 {
59 name => 'stop_words_file',
60 description => 'A file containing words to not consider as misspelled.',
61 default_string => $EMPTY,
62 behavior => 'string',
63 },
64 );
65}
66
6712┬Ás
# spent 8┬Ás (6+1) within Perl::Critic::Policy::Documentation::PodSpelling::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 }
68sub default_themes { return qw( core cosmetic pbp ) }
69sub applies_to { return 'PPI::Document' }
70
71#-----------------------------------------------------------------------------
72
731100nsmy $got_sigpipe = 0;
74sub got_sigpipe {
75 return $got_sigpipe;
76}
77
78#-----------------------------------------------------------------------------
79
80sub initialize_if_enabled {
81 my ( $self, $config ) = @_;
82
83 eval { require File::Which; 1 } or return $FALSE;
84
85 return $FALSE if not $self->_derive_spell_command_line();
86
87 return $FALSE if not $self->_run_spell_command( <<'END_TEST_CODE' );
88=pod
89
90=head1 Test The Spell Command
91
92=cut
93END_TEST_CODE
94
95 $self->_load_stop_words_file();
96
97 return $TRUE;
98}
99
100#-----------------------------------------------------------------------------
101
102sub violates {
103 my ( $self, $elem, $doc ) = @_;
104
105 my $code = $doc->serialize();
106
107 my $words = $self->_run_spell_command($code);
108
109 return if not $words; # error running spell command
110
111 return if not @{$words}; # no problems found
112
113 return $self->violation( "$DESC: @{$words}", $EXPL, $doc );
114}
115
116#-----------------------------------------------------------------------------
117
118sub _derive_spell_command_line {
119 my ($self) = @_;
120
121 my @words = Text::ParseWords::shellwords($self->_get_spell_command());
122 if (!@words) {
123 return;
124 }
125 if (! File::Spec->file_name_is_absolute($words[0])) {
126 $words[0] = File::Which::which($words[0]);
127 }
128 if (! $words[0] || ! -x $words[0]) {
129 return;
130 }
131 $self->_set_spell_command_line(\@words);
132
133 return $self->_get_spell_command_line();
134}
135
136#-----------------------------------------------------------------------------
137
138sub _get_spell_command {
139 my ( $self ) = @_;
140
141 return $self->{_spell_command};
142}
143
144#-----------------------------------------------------------------------------
145
146sub _get_spell_command_line {
147 my ( $self ) = @_;
148
149 return $self->{_spell_command_line};
150}
151
152sub _set_spell_command_line {
153 my ( $self, $spell_command_line ) = @_;
154
155 $self->{_spell_command_line} = $spell_command_line;
156
157 return;
158}
159
160#-----------------------------------------------------------------------------
161
162sub _get_stop_words {
163 my ( $self ) = @_;
164
165 return $self->{_stop_words};
166}
167
168sub _set_stop_words {
169 my ( $self, $stop_words ) = @_;
170
171 $self->{_stop_words} = $stop_words;
172
173 return;
174}
175
176#-----------------------------------------------------------------------------
177
178sub _get_stop_words_file {
179 my ( $self ) = @_;
180
181 return $self->{_stop_words_file};
182}
183
184#-----------------------------------------------------------------------------
185
186sub _run_spell_command {
187 my ($self, $code) = @_;
188
189 my $infh = IO::String->new( $code );
190
191 my $outfh = File::Temp->new();
192
193 my $outfile = $outfh->filename();
194 my @words;
195
196 local $EVAL_ERROR = undef;
197
198 eval {
199 # temporarily add our special wordlist to this annoying global
200 local %Pod::Wordlist::Wordlist = ## no critic (ProhibitPackageVars)
201 %{ $self->_get_stop_words() };
202
203 Pod::Spell->new()->parse_from_filehandle($infh, $outfh);
204 close $outfh or throw_generic "Failed to close pod temp file: $OS_ERROR";
205 return if not -s $outfile; # Bail out if no words to spellcheck
206
207 # run spell command and fetch output
208 local $SIG{PIPE} = sub { $got_sigpipe = 1; };
209 my $command_line = join $SPACE, @{$self->_get_spell_command_line()};
210 open my $aspell_out_fh, q{-|}, "$command_line < $outfile" ## Is this portable??
211 or throw_generic "Failed to open handle to spelling program: $OS_ERROR";
212
213 @words = uniq( <$aspell_out_fh> );
214 close $aspell_out_fh
215 or throw_generic "Failed to close handle to spelling program: $OS_ERROR";
216
217 for (@words) {
218 chomp;
219 }
220
221 # Why is this extra step needed???
222 @words = grep { not exists $Pod::Wordlist::Wordlist{$_} } @words; ## no critic (ProhibitPackageVars)
223 1;
224 }
225 or do {
226 # Eat anything we did ourselves above, propagate anything else.
227 if (
228 $EVAL_ERROR
229 and not ref Perl::Critic::Exception::Fatal::Generic->caught()
230 ) {
231 ref $EVAL_ERROR ? $EVAL_ERROR->rethrow() : die $EVAL_ERROR; ## no critic (ErrorHandling::RequireCarping)
232 }
233
234 return;
235 };
236
237 return [ @words ];
238}
239
240#-----------------------------------------------------------------------------
241
242sub _load_stop_words_file {
243 my ($self) = @_;
244
245 my %stop_words = %{ $self->_get_stop_words() };
246
247 my $file_name = $self->_get_stop_words_file() or return;
248
249 open my $handle, '<', $file_name
250 or do { warn qq<Could not open "$file_name": $OS_ERROR\n>; return; };
251
252 while ( my $line = <$handle> ) {
253 if ( my $word = _word_from_line($line) ) {
254 $stop_words{$word} = 1;
255 }
256 }
257
258 close $handle or warn qq<Could not close "$file_name": $OS_ERROR\n>;
259
260 $self->_set_stop_words(\%stop_words);
261
262 return;
263}
264
265sub _word_from_line {
266 my ($line) = @_;
267
268 $line =~ s< [#] .* \z ><>xms;
269 $line =~ s< \s+ \z ><>xms;
270 $line =~ s< \A \s+ ><>xms;
271
272 return $line;
273}
274
275#-----------------------------------------------------------------------------
276
27719┬Ás1;
278
279__END__
 
# spent 2┬Ás within Perl::Critic::Policy::Documentation::PodSpelling::CORE:qr which was called: # once (2┬Ás+0s) by Module::Pluggable::Object::_require at line 38
sub Perl::Critic::Policy::Documentation::PodSpelling::CORE:qr; # opcode