line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use utf8; |
3
|
8
|
|
|
8
|
|
1835
|
|
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
41
|
|
4
|
|
|
|
|
|
|
use 5.010; |
5
|
8
|
|
|
8
|
|
289
|
|
|
8
|
|
|
|
|
28
|
|
6
|
|
|
|
|
|
|
use strict; |
7
|
8
|
|
|
8
|
|
67
|
use warnings; |
|
8
|
|
|
|
|
49
|
|
|
8
|
|
|
|
|
184
|
|
8
|
8
|
|
|
8
|
|
39
|
|
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
362
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Readonly; |
12
|
8
|
|
|
8
|
|
1033
|
use List::Util qw( first ); |
|
8
|
|
|
|
|
6888
|
|
|
8
|
|
|
|
|
573
|
|
13
|
8
|
|
|
8
|
|
59
|
|
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
651
|
|
14
|
|
|
|
|
|
|
use Perl::Critic::Utils qw{ is_hash_key }; |
15
|
8
|
|
|
8
|
|
1273
|
|
|
8
|
|
|
|
|
220587
|
|
|
8
|
|
|
|
|
332
|
|
16
|
|
|
|
|
|
|
use base 'Exporter'; |
17
|
8
|
|
|
8
|
|
1038
|
|
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
2892
|
|
18
|
|
|
|
|
|
|
our @EXPORT_OK = qw( search_for_block_keyword ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Readonly::Array my @BLOCK_SEARCH_KEYWORD => qw( |
21
|
|
|
|
|
|
|
SUB |
22
|
|
|
|
|
|
|
IF ELSIF UNLESS |
23
|
|
|
|
|
|
|
WHILE UNTIL |
24
|
|
|
|
|
|
|
DO |
25
|
|
|
|
|
|
|
FOR FOREACH |
26
|
|
|
|
|
|
|
EVAL |
27
|
|
|
|
|
|
|
SORT MAP GREP |
28
|
|
|
|
|
|
|
BEGIN UNITCHECK CHECK INIT END |
29
|
|
|
|
|
|
|
PACKAGE ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Readonly::Scalar my $MAX_KEYWORD_LOOKUP_DEPTH => 10; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
my ( $keyword ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
67
|
|
|
67
|
|
139
|
$keyword = uc $keyword; |
37
|
|
|
|
|
|
|
|
38
|
67
|
|
|
|
|
165
|
my $found = first { $_ eq $keyword } @BLOCK_SEARCH_KEYWORD; |
39
|
|
|
|
|
|
|
|
40
|
67
|
|
|
760
|
|
315
|
return $found; |
|
760
|
|
|
|
|
3805
|
|
41
|
|
|
|
|
|
|
} |
42
|
67
|
|
|
|
|
507
|
|
43
|
|
|
|
|
|
|
{ |
44
|
|
|
|
|
|
|
my ( $elem ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
if ( !ref $elem ) { |
47
|
49
|
|
|
49
|
0
|
109
|
last; |
48
|
|
|
|
|
|
|
} |
49
|
49
|
50
|
|
|
|
137
|
|
50
|
0
|
|
|
|
|
0
|
my $word_search = $elem; |
51
|
|
|
|
|
|
|
my $block_keyword = q{}; |
52
|
|
|
|
|
|
|
|
53
|
49
|
|
|
|
|
93
|
my $i = 1; |
54
|
49
|
|
|
|
|
84
|
|
55
|
|
|
|
|
|
|
while ( !$block_keyword ) { |
56
|
49
|
|
|
|
|
79
|
if ( $i >= $MAX_KEYWORD_LOOKUP_DEPTH ) { |
57
|
|
|
|
|
|
|
last; # recurse abort! |
58
|
49
|
|
|
|
|
109
|
} |
59
|
67
|
50
|
|
|
|
147
|
|
60
|
0
|
|
|
|
|
0
|
my $sprevious = $word_search->sprevious_sibling; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
if ( !$sprevious || $sprevious == $word_search ) { |
63
|
67
|
|
|
|
|
554
|
last; |
64
|
|
|
|
|
|
|
} |
65
|
67
|
50
|
33
|
|
|
1822
|
|
66
|
0
|
|
|
|
|
0
|
if ( !is_hash_key( $sprevious ) ) { |
67
|
|
|
|
|
|
|
$word_search = $sprevious; |
68
|
|
|
|
|
|
|
|
69
|
67
|
50
|
|
|
|
543
|
my $content_search = $word_search->content; |
70
|
67
|
|
|
|
|
3989
|
|
71
|
|
|
|
|
|
|
$block_keyword = _keyword_in_searchlist( $content_search ); |
72
|
67
|
|
|
|
|
160
|
} |
73
|
|
|
|
|
|
|
|
74
|
67
|
|
|
|
|
733
|
$i++; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
67
|
|
|
|
|
160
|
return $block_keyword; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
49
|
|
|
|
|
146
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=pod |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=encoding utf8 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Mardem::RefactoringPerlCriticPolicies::Util - Internal Util module! |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Util module with internal subroutines for the |
96
|
|
|
|
|
|
|
L<Perl::Critic::Policy::Mardem>> modules. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AFFILIATION |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This policy is part of L<Mardem::RefactoringPerlCriticPolicies>. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Markus Demml, mardem@cpan.com |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Copyright (c) 2022, Markus Demml |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it |
111
|
|
|
|
|
|
|
under the same terms as the Perl 5 programming language system itself. |
112
|
|
|
|
|
|
|
The full text of this license can be found in the LICENSE file included |
113
|
|
|
|
|
|
|
with this module. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |