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

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/TestingAndDebugging/RequireTestLabels.pm
StatementsExecuted 21 statements in 455µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs16µsPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::BEGIN@10Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@10
11114µs16µsPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::supported_parametersPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::supported_parameters
1118µs19µsPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::BEGIN@11Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@11
1118µs28µsPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::BEGIN@13Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@13
1118µs11µsPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::BEGIN@12Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@12
1117µs648µsPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::BEGIN@16Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@16
1117µs58µsPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::BEGIN@19Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@19
1117µs138µsPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::BEGIN@15Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@15
1116µs7µsPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::default_severityPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::default_severity
0000s0sPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::__ANON__[:88]Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::__ANON__[:88]
0000s0sPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::_has_test_morePerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::_has_test_more
0000s0sPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::applies_toPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::applies_to
0000s0sPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::default_themesPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::default_themes
0000s0sPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::::violatesPerl::Critic::Policy::TestingAndDebugging::RequireTestLabels::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::TestingAndDebugging::RequireTestLabels;
9
10240µs116µs
# spent 16µs within Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@10 which was called: # once (16µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220µs230µs
# spent 19µs (8+11) within Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@11 which was called: # once (8µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 19µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@11 # spent 11µs making 1 call to strict::import
12222µs215µs
# spent 11µs (8+4) within Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@12 which was called: # once (8µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 11µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@12 # spent 4µs making 1 call to warnings::import
13222µs249µs
# spent 28µs (8+21) within Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@13 which was called: # once (8µs+21µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 28µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@13 # spent 21µs making 1 call to Exporter::import
14
15226µs2270µs
# spent 138µs (7+132) within Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@15 which was called: # once (7µs+132µs) by Module::Pluggable::Object::_require at line 15
use List::MoreUtils qw(any);
# spent 138µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@15 # spent 132µs making 1 call to Exporter::Tiny::import
161300ns
# spent 648µs (7+641) within Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@16 which was called: # once (7µs+641µs) by Module::Pluggable::Object::_require at line 18
use Perl::Critic::Utils qw{
17 :characters :severities :data_conversion :classification :ppi
18124µs21.29ms};
# spent 648µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@16 # spent 641µs making 1 call to Exporter::import
192277µs2109µs
# spent 58µs (7+51) within Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@19 which was called: # once (7µs+51µs) by Module::Pluggable::Object::_require at line 19
use base 'Perl::Critic::Policy';
# spent 58µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@19 # spent 51µs making 1 call to base::import
20
211600nsour $VERSION = '1.121';
22
2313µs156µsReadonly::Hash my %LABEL_ARG_POS => (
# spent 56µs making 1 call to Readonly::Hash
24 ok => 1,
25 is => 2,
26 isnt => 2,
27 like => 2,
28 unlike => 2,
29 cmp_ok => 3,
30 is_deeply => 2,
31 pass => 0,
32 fail => 0,
33);
34
35#-----------------------------------------------------------------------------
36
3711µs124µsReadonly::Scalar my $DESC => q{Test without a label};
# spent 24µs making 1 call to Readonly::Scalar
381900ns131µsReadonly::Scalar my $EXPL => q{Add a label argument to all Test::More functions};
# spent 31µs making 1 call to Readonly::Scalar
39
40#-----------------------------------------------------------------------------
41
42
# spent 16µs (14+2) within Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::supported_parameters which was called: # once (14µs+2µs) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
43 return (
44 {
45111µs22µs name => 'modules',
# spent 2µs making 2 calls to Readonly::Scalar::FETCH, avg 1µs/call
46 description => 'The additional modules to require labels for.',
47 default_string => $EMPTY,
48 behavior => 'string list',
49 list_always_present_values => [ qw( Test::More ) ],
50 },
51 );
52}
53
5412µs
# spent 7µs (6+1) within Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::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_MEDIUM }
55sub default_themes { return qw( core maintenance tests ) }
56sub applies_to { return 'PPI::Token::Word' }
57
58#-----------------------------------------------------------------------------
59
60sub violates {
61 my ($self, $elem, $doc) = @_;
62
63 my $arg_index = $LABEL_ARG_POS{$elem};
64 return if not defined $arg_index;
65 return if not is_function_call($elem);
66 return if not $self->_has_test_more($doc);
67
68 # Does the function call have enough arguments?
69 my @args = parse_arg_list($elem);
70 return if ( @args > $arg_index );
71
72 return $self->violation( $DESC, $EXPL, $elem );
73}
74
75#-----------------------------------------------------------------------------
76
77sub _has_test_more {
78 my ( $self, $doc ) = @_;
79
80 # TODO: This method gets called every time violates() is invoked,
81 # but it only needs to happen once per document. Perhaps this
82 # policy should just apply to PPI::Document, and then do its own
83 # search for method calls. Since Perl::Critic::Document is
84 # optimized, this should be pretty fast.
85
86 my $includes = $doc->find('PPI::Statement::Include');
87 return if not $includes;
88 return any { exists $self->{_modules}->{$_->module()} }
89 @{ $includes };
90}
91
9216µs1;
93
94#-----------------------------------------------------------------------------
95
96__END__