line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
our $VERSION = '0.4001'; # VERSION |
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GEEKRUTH'; # AUTHORITY |
4
|
|
|
|
|
|
|
# ABSTRACT: Trigger perlcritic alerts on deprecated Dancer2 keywords |
5
|
|
|
|
|
|
|
use 5.006001; |
6
|
2
|
|
|
2
|
|
1505
|
use strict; |
|
2
|
|
|
|
|
6
|
|
7
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
40
|
|
8
|
2
|
|
|
2
|
|
9
|
use Readonly; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
59
|
|
9
|
2
|
|
|
2
|
|
10
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
117
|
|
10
|
|
|
|
|
|
|
use Perl::Critic::Utils qw{ |
11
|
2
|
|
|
|
|
147
|
:booleans :characters :severities :classification :data_conversion |
12
|
|
|
|
|
|
|
}; |
13
|
2
|
|
|
2
|
|
14
|
use Perl::Critic::Utils::PPI qw{ is_ppi_expression_or_generic_statement }; |
|
2
|
|
|
|
|
4
|
|
14
|
2
|
|
|
2
|
|
1174
|
use base 'Perl::Critic::Policy'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
88
|
|
15
|
2
|
|
|
2
|
|
13
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
728
|
|
16
|
|
|
|
|
|
|
# ('PPI::Structure::Constructor', |
17
|
4
|
|
|
4
|
1
|
41
|
# 'PPI::Structure::List', |
18
|
0
|
|
|
0
|
1
|
0
|
# # this policy is not for blocks, but PPI |
19
|
2
|
|
|
2
|
1
|
93117
|
# # mis-reports some anonymous hashref |
20
|
|
|
|
|
|
|
# # constructors as blocks, so look at them |
21
|
|
|
|
|
|
|
# 'PPI::Structure::Block');} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Readonly::Hash my %deprecated_words => ( |
24
|
|
|
|
|
|
|
context => 'app', |
25
|
|
|
|
|
|
|
header => 'response_header', |
26
|
|
|
|
|
|
|
headers => 'request_headers', |
27
|
|
|
|
|
|
|
push_header => 'push_response_header' |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => |
30
|
|
|
|
|
|
|
'You are using a Dancer2 keyword that is being or has been deprecated.'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my ( $self, $elem, $doc ) = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $included = $doc->find_any( |
35
|
|
|
|
|
|
|
sub { |
36
|
|
|
|
|
|
|
$_[1]->isa('PPI::Statement::Include') |
37
|
48
|
|
|
48
|
1
|
1103
|
and defined( $_[1]->module() ) |
38
|
|
|
|
|
|
|
and ( $_[1]->module() eq 'Dancer2' ) |
39
|
|
|
|
|
|
|
and $_[1]->type() eq 'use'; |
40
|
|
|
|
|
|
|
} |
41
|
4798
|
50
|
66
|
4798
|
|
44089
|
); |
|
|
|
66
|
|
|
|
|
42
|
|
|
|
|
|
|
return if !$included; |
43
|
|
|
|
|
|
|
if ( defined $deprecated_words{$elem} ) { |
44
|
|
|
|
|
|
|
return if is_hash_key($elem); |
45
|
|
|
|
|
|
|
my $alternative = $deprecated_words{$elem}; |
46
|
48
|
|
|
|
|
175
|
my $desc = qq{Use '$alternative' instead of deprecated Dancer2 keyword '$elem'}; |
47
|
48
|
100
|
|
|
|
1790
|
return $self->violation( $desc, $EXPL, $elem ); |
48
|
25
|
100
|
|
|
|
48
|
} |
49
|
7
|
100
|
|
|
|
87
|
return; |
50
|
4
|
|
|
|
|
219
|
} |
51
|
4
|
|
|
|
|
50
|
|
52
|
4
|
|
|
|
|
27
|
1; |
53
|
|
|
|
|
|
|
|
54
|
18
|
|
|
|
|
190
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=encoding UTF-8 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Perl::Critic::Policy::Dancer2::ProhibitDeprecatedKeywords - Trigger perlcritic alerts on deprecated Dancer2 keywords |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 VERSION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
version 0.4001 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
The L<Dancer2> team has a deprecation policy, detailed at |
70
|
|
|
|
|
|
|
L<Dancer2::DeprecationPolicy>, that will, in time, cause certain |
71
|
|
|
|
|
|
|
keywords to be removed from the Dancer2 codebase. You should not |
72
|
|
|
|
|
|
|
use these keywords, to prevent breaking your application when |
73
|
|
|
|
|
|
|
you update Dancer2 beyond that deprecation point. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AFFILIATION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This policy is part of L<Perl::Critic::Dancer2>. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 CONFIGURATION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This Policy is not configurable except for the standard options. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
D Ruth Holloway <ruth@hiruthie.me> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This software is copyright (c) 2022 by D Ruth Holloway. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
94
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |