Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/TestingAndDebugging/RequireTestLabels.pm |
Statements | Executed 21 statements in 455µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 16µs | 16µs | BEGIN@10 | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
1 | 1 | 1 | 14µs | 16µs | supported_parameters | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
1 | 1 | 1 | 8µs | 19µs | BEGIN@11 | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
1 | 1 | 1 | 8µs | 28µs | BEGIN@13 | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
1 | 1 | 1 | 8µs | 11µs | BEGIN@12 | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
1 | 1 | 1 | 7µs | 648µs | BEGIN@16 | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
1 | 1 | 1 | 7µs | 58µs | BEGIN@19 | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
1 | 1 | 1 | 7µs | 138µs | BEGIN@15 | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
0 | 0 | 0 | 0s | 0s | __ANON__[:88] | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
0 | 0 | 0 | 0s | 0s | _has_test_more | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
0 | 0 | 0 | 0s | 0s | applies_to | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
0 | 0 | 0 | 0s | 0s | violates | Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::
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::TestingAndDebugging::RequireTestLabels; | ||||
9 | |||||
10 | 2 | 40µs | 1 | 16µ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 # spent 16µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@10 |
11 | 2 | 20µs | 2 | 30µ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 # spent 19µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 22µs | 2 | 15µ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 # spent 11µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 22µs | 2 | 49µ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 # spent 28µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@13
# spent 21µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 26µs | 2 | 270µ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 # spent 138µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@15
# spent 132µs making 1 call to Exporter::Tiny::import |
16 | 1 | 300ns | # 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 | ||
17 | :characters :severities :data_conversion :classification :ppi | ||||
18 | 1 | 24µs | 2 | 1.29ms | }; # spent 648µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@16
# spent 641µs making 1 call to Exporter::import |
19 | 2 | 277µs | 2 | 109µ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 # spent 58µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels::BEGIN@19
# spent 51µs making 1 call to base::import |
20 | |||||
21 | 1 | 600ns | our $VERSION = '1.121'; | ||
22 | |||||
23 | 1 | 3µs | 1 | 56µs | Readonly::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 | |||||
37 | 1 | 1µs | 1 | 24µs | Readonly::Scalar my $DESC => q{Test without a label}; # spent 24µs making 1 call to Readonly::Scalar |
38 | 1 | 900ns | 1 | 31µs | Readonly::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 | ||||
43 | return ( | ||||
44 | { | ||||
45 | 1 | 11µs | 2 | 2µ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 | |||||
54 | 1 | 2µ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 | ||
55 | sub default_themes { return qw( core maintenance tests ) } | ||||
56 | sub applies_to { return 'PPI::Token::Word' } | ||||
57 | |||||
58 | #----------------------------------------------------------------------------- | ||||
59 | |||||
60 | sub 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 | |||||
77 | sub _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 | |||||
92 | 1 | 6µs | 1; | ||
93 | |||||
94 | #----------------------------------------------------------------------------- | ||||
95 | |||||
96 | __END__ |