| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Critic::Utils::SourceLocation v0.2.4; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
329121
|
use v5.26.0; |
|
|
7
|
|
|
|
|
21
|
|
|
4
|
7
|
|
|
7
|
|
24
|
use strict; |
|
|
7
|
|
|
|
|
8
|
|
|
|
7
|
|
|
|
|
166
|
|
|
5
|
7
|
|
|
7
|
|
22
|
use warnings; |
|
|
7
|
|
|
|
|
7
|
|
|
|
7
|
|
|
|
|
300
|
|
|
6
|
7
|
|
|
7
|
|
56
|
use feature "signatures"; |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
969
|
|
|
7
|
7
|
|
|
7
|
|
526
|
use experimental "signatures"; |
|
|
7
|
|
|
|
|
1259
|
|
|
|
7
|
|
|
|
|
100
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
804
|
use parent qw( PPI::Element ); |
|
|
7
|
|
|
|
|
225
|
|
|
|
7
|
|
|
|
|
49
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# This is NOT a Perl::Critic policy - it's a helper class |
|
12
|
1
|
|
|
1
|
1
|
8
|
sub is_policy { 0 } |
|
13
|
|
|
|
|
|
|
|
|
14
|
12
|
|
|
12
|
1
|
230588
|
sub new ($class, %args) { |
|
|
12
|
|
|
|
|
15
|
|
|
|
12
|
|
|
|
|
30
|
|
|
|
12
|
|
|
|
|
15
|
|
|
15
|
|
|
|
|
|
|
bless { |
|
16
|
|
|
|
|
|
|
line_number => $args{line_number}, |
|
17
|
|
|
|
|
|
|
column_number => $args{column_number} // 1, |
|
18
|
|
|
|
|
|
|
content => $args{content} // "", |
|
19
|
|
|
|
|
|
|
filename => $args{filename}, |
|
20
|
|
|
|
|
|
|
}, |
|
21
|
12
|
|
100
|
|
|
84
|
$class |
|
|
|
|
100
|
|
|
|
|
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# CRITICAL: This is what Perl::Critic::Violation actually calls |
|
25
|
7
|
|
|
7
|
1
|
36
|
sub location ($self) { |
|
|
7
|
|
|
|
|
7
|
|
|
|
7
|
|
|
|
|
6
|
|
|
26
|
7
|
|
|
|
|
8
|
my $line = $self->{line_number}; |
|
27
|
7
|
|
|
|
|
9
|
my $col = $self->{column_number}; |
|
28
|
7
|
|
|
|
|
12
|
[ $line, $col, $col, $line, $self->{filename} ] |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Standard PPI::Element interface |
|
32
|
15
|
|
|
15
|
1
|
396
|
sub line_number ($self) { $self->{line_number} } |
|
|
15
|
|
|
|
|
14
|
|
|
|
15
|
|
|
|
|
13
|
|
|
|
15
|
|
|
|
|
80
|
|
|
33
|
3
|
|
|
3
|
1
|
4
|
sub column_number ($self) { $self->{column_number} } |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
9
|
|
|
34
|
1
|
|
|
1
|
1
|
2
|
sub logical_line_number ($self) { $self->{line_number} } |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
4
|
|
|
35
|
1
|
|
|
1
|
1
|
2
|
sub visual_column_number ($self) { $self->{column_number} } |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
3
|
|
|
36
|
2
|
|
|
2
|
1
|
3
|
sub logical_filename ($self) { $self->{filename} } |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
6
|
|
|
37
|
9
|
|
|
9
|
1
|
88
|
sub content ($self) { $self->{content} } |
|
|
9
|
|
|
|
|
10
|
|
|
|
9
|
|
|
|
|
9
|
|
|
|
9
|
|
|
|
|
18
|
|
|
38
|
9
|
|
|
9
|
1
|
26
|
sub filename ($self) { $self->{filename} } |
|
|
9
|
|
|
|
|
9
|
|
|
|
9
|
|
|
|
|
8
|
|
|
|
9
|
|
|
|
|
53
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Support for filename extraction by violation system |
|
41
|
|
|
|
|
|
|
# Return self as the "document" |
|
42
|
7
|
|
|
7
|
1
|
264
|
sub top ($self) { $self } |
|
|
7
|
|
|
|
|
8
|
|
|
|
7
|
|
|
|
|
7
|
|
|
|
7
|
|
|
|
|
20
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
" |
|
45
|
|
|
|
|
|
|
She sent him scented letters |
|
46
|
|
|
|
|
|
|
And he received them with a strange delight |
|
47
|
|
|
|
|
|
|
" |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Perl::Critic::Utils::SourceLocation - Synthetic PPI element |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 VERSION |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
version v0.2.4 |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Used internally by ProhibitLongLines policy |
|
64
|
|
|
|
|
|
|
my $location = SourceLocation->new( |
|
65
|
|
|
|
|
|
|
line_number => 42, |
|
66
|
|
|
|
|
|
|
content => "long line content" |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This is a synthetic PPI element used by ProhibitLongLines policy to provide |
|
72
|
|
|
|
|
|
|
accurate line number reporting when no real PPI token exists on a line (such as |
|
73
|
|
|
|
|
|
|
within POD blocks). |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 METHODS |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 new |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $location = Perl::Critic::Utils::SourceLocation->new( |
|
80
|
|
|
|
|
|
|
line_number => 42, |
|
81
|
|
|
|
|
|
|
column_number => 1, |
|
82
|
|
|
|
|
|
|
content => "line content", |
|
83
|
|
|
|
|
|
|
filename => "file.pl" |
|
84
|
|
|
|
|
|
|
); |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Creates a new SourceLocation object. Parameters: |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=over 4 |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * line_number (required) - The line number in the source file |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * column_number (optional) - The column number, defaults to 1 |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * content (optional) - The content of the line, defaults to empty string |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * filename (optional) - The filename, can be undef |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=back |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 is_policy |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $is_policy = $location->is_policy; # Always returns 0 |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns false to indicate this is not a Perl::Critic policy. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 filename |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $filename = $location->filename; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns the filename associated with this location, or undef if none was set. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Paul Johnson C<< <paul@pjcj.net> >> |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Copyright 2025 Paul Johnson. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 LICENCE |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
123
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |