line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Freenode::DiscouragedModules; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
670
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Perl::Critic::Utils qw(:severities :classification :ppi); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
51
|
|
7
|
1
|
|
|
1
|
|
381
|
use parent 'Perl::Critic::Policy'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.030'; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
0
|
9978
|
sub supported_parameters { () } |
12
|
14
|
|
|
14
|
1
|
111
|
sub default_severity { $SEVERITY_HIGH } |
13
|
0
|
|
|
0
|
1
|
0
|
sub default_themes { 'freenode' } |
14
|
2
|
|
|
2
|
1
|
39939
|
sub applies_to { 'PPI::Statement::Include' } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %modules = ( |
17
|
|
|
|
|
|
|
'AnyEvent' => 'AnyEvent\'s author refuses to use public bugtracking and actively breaks interoperability. POE, IO::Async, and Mojo::IOLoop are widely used and interoperable async event loops.', |
18
|
|
|
|
|
|
|
'Any::Moose' => 'Any::Moose is deprecated. Use Moo instead.', |
19
|
|
|
|
|
|
|
'Class::DBI' => 'Class::DBI is an ancient database ORM abstraction layer which is buggy and abandoned. See DBIx::Class for a more modern DBI-based ORM, or Mad::Mapper for a Mojolicious-style ORM.', |
20
|
|
|
|
|
|
|
'CGI' => 'CGI.pm is an ancient module for communicating via the CGI protocol, with tons of bad practices and cruft. Use a modern framework such as those based on Plack (Web::Simple, Dancer2, Catalyst) or Mojolicious, they can still be served via CGI if you choose.', |
21
|
|
|
|
|
|
|
'Coro' => 'Coro no longer works on perl 5.22, you need to use the author\'s forked version of Perl. Avoid at all costs.', |
22
|
|
|
|
|
|
|
'Error' => 'Error.pm is overly magical and discouraged by its maintainers. Try Throwable for exception classes in Moo/Moose, or Exception::Class otherwise. Try::Tiny or Try are recommended for the try/catch syntax.', |
23
|
|
|
|
|
|
|
'File::Slurp' => 'File::Slurp gets file encodings all wrong, line endings on win32 are messed up, and it was written before layers were properly added. Use File::Slurper, Path::Tiny, Data::Munge, or Mojo::File.', |
24
|
|
|
|
|
|
|
'HTML::Template' => 'HTML::Template is an old and buggy module, try Template Toolkit, HTML::Zoom, or Text::Template instead, or HTML::Template::Pro if you must use the same syntax.', |
25
|
|
|
|
|
|
|
'IO::Socket::INET6' => 'IO::Socket::INET6 is an old attempt at an IPv6 compatible version of IO::Socket::INET, but has numerous issues and is discouraged by the maintainer in favor of IO::Socket::IP, which transparently creates IPv4 and IPv6 sockets.', |
26
|
|
|
|
|
|
|
'JSON::Any' => 'JSON::Any is deprecated. Use JSON::MaybeXS instead.', |
27
|
|
|
|
|
|
|
'JSON::XS' => 'JSON::XS\'s author refuses to use public bugtracking and actively breaks interoperability. Cpanel::JSON::XS is a fork with several bugfixes and a more collaborative maintainer. See also JSON::MaybeXS.', |
28
|
|
|
|
|
|
|
'Net::IRC' => 'Net::IRC is an ancient module implementing the IRC protocol. Use a modern event-loop-based module instead. Choices are POE::Component::IRC (and Bot::BasicBot based on that), Net::Async::IRC, and Mojo::IRC.', |
29
|
|
|
|
|
|
|
'Switch' => 'Switch.pm is a buggy and outdated source filter which can cause any number of strange errors, in addition to the problems with smart-matching shared by its replacement, the \'switch\' feature (given/when). Try Switch::Plain instead.', |
30
|
|
|
|
|
|
|
'XML::Simple' => 'XML::Simple tries to coerce complex XML documents into perl data structures. This leads to overcomplicated structures and unexpected behavior. Use a proper DOM parser instead like XML::LibXML, XML::TreeBuilder, XML::Twig, or Mojo::DOM.', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _violation { |
34
|
14
|
|
|
14
|
|
252
|
my ($self, $module, $elem) = @_; |
35
|
14
|
|
|
|
|
33
|
my $desc = "Used module $module"; |
36
|
14
|
|
33
|
|
|
31
|
my $expl = $modules{$module} // "Module $module is discouraged."; |
37
|
14
|
|
|
|
|
40
|
return $self->violation($desc, $expl, $elem); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub violates { |
41
|
42
|
|
|
42
|
1
|
2982
|
my ($self, $elem) = @_; |
42
|
42
|
100
|
66
|
|
|
80
|
return () unless defined $elem->module and exists $modules{$elem->module}; |
43
|
14
|
|
|
|
|
562
|
return $self->_violation($elem->module, $elem); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Perl::Critic::Policy::Freenode::DiscouragedModules - Various modules |
51
|
|
|
|
|
|
|
discouraged from use |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Various modules are discouraged by the denizens of #perl on Freenode IRC, for |
56
|
|
|
|
|
|
|
various reasons which may include: buggy behavior, cruft, performance problems, |
57
|
|
|
|
|
|
|
maintainer issues, or simply better modern replacements. This is a high |
58
|
|
|
|
|
|
|
severity complement to |
59
|
|
|
|
|
|
|
L<Perl::Critic::Policy::Freenode::PreferredAlternatives>. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 MODULES |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 AnyEvent |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
L<AnyEvent>'s author refuses to use public bugtracking and actively breaks |
66
|
|
|
|
|
|
|
interoperability. L<POE>, L<IO::Async>, and L<Mojo::IOLoop> are widely used and |
67
|
|
|
|
|
|
|
interoperable async event loops. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 Any::Moose |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
L<Any::Moose> is deprecated. Use L<Moo> instead. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 Class::DBI |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L<Class::DBI> is an ancient database L<ORM|https://en.wikipedia.org/wiki/Object-relational_mapping> |
76
|
|
|
|
|
|
|
abstraction layer which is buggy and abandoned. See L<DBIx::Class> for a more |
77
|
|
|
|
|
|
|
modern L<DBI>-based ORM, or L<Mad::Mapper> for a L<Mojolicious>-style ORM. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 CGI |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
L<CGI>.pm is an ancient module for communicating via the CGI protocol, with |
82
|
|
|
|
|
|
|
tons of bad practices and cruft. Use a modern framework such as those based on |
83
|
|
|
|
|
|
|
L<Plack> (L<Web::Simple>, L<Dancer2>, L<Catalyst>) or L<Mojolicious>, they can |
84
|
|
|
|
|
|
|
still be served via CGI if you choose. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 Coro |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L<Coro> no longer works on perl 5.22, you need to use the author's forked |
89
|
|
|
|
|
|
|
version of Perl. Avoid at all costs. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 Error |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L<Error>.pm is overly magical and discouraged by its maintainers. Try |
94
|
|
|
|
|
|
|
L<Throwable> for exception classes in L<Moo>/L<Moose>, or L<Exception::Class> |
95
|
|
|
|
|
|
|
otherwise. L<Try::Tiny> or L<Try> are recommended for the C<try>/C<catch> |
96
|
|
|
|
|
|
|
syntax. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 File::Slurp |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L<File::Slurp> gets file encodings all wrong, line endings on win32 are messed |
101
|
|
|
|
|
|
|
up, and it was written before layers were properly added. Use L<File::Slurper>, |
102
|
|
|
|
|
|
|
L<Path::Tiny/"slurp">, L<Data::Munge/"slurp">, or L<Mojo::File/"slurp">. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 HTML::Template |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L<HTML::Template> is an old and buggy module, try L<Template::Toolkit>, |
107
|
|
|
|
|
|
|
L<HTML::Zoom>, or L<Text::Template> instead, or L<HTML::Template::Pro> if you |
108
|
|
|
|
|
|
|
must use the same syntax. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 IO::Socket::INET6 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L<IO::Socket::INET6> is an old attempt at an IPv6 compatible version of |
113
|
|
|
|
|
|
|
L<IO::Socket::INET>, but has numerous issues and is discouraged by the |
114
|
|
|
|
|
|
|
maintainer in favor of L<IO::Socket::IP>, which transparently creates IPv4 and |
115
|
|
|
|
|
|
|
IPv6 sockets. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 JSON::Any |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L<JSON::Any> is deprecated. Use L<JSON::MaybeXS> instead. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 JSON::XS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L<JSON::XS>'s author refuses to use public bugtracking and actively breaks |
124
|
|
|
|
|
|
|
interoperability. L<Cpanel::JSON::XS> is a fork with several bugfixes and a |
125
|
|
|
|
|
|
|
more collaborative maintainer. See also L<JSON::MaybeXS>. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 Net::IRC |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
L<Net::IRC> is an ancient module implementing the IRC protocol. Use a modern |
130
|
|
|
|
|
|
|
event-loop-based module instead. Choices are L<POE::Component::IRC> (used for |
131
|
|
|
|
|
|
|
L<Bot::BasicBot>), L<Net::Async::IRC>, and L<Mojo::IRC>. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 Switch |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L<Switch>.pm is a buggy and outdated source filter which can cause any number |
136
|
|
|
|
|
|
|
of strange errors, in addition to the problems with smart-matching shared by |
137
|
|
|
|
|
|
|
its replacement, L<feature/"The 'switch' feature"> (C<given>/C<when>). Try |
138
|
|
|
|
|
|
|
L<Switch::Plain> instead. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 XML::Simple |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<XML::Simple> tries to coerce complex XML documents into perl data structures. |
143
|
|
|
|
|
|
|
This leads to overcomplicated structures and unexpected behavior. Use a proper |
144
|
|
|
|
|
|
|
DOM parser instead like L<XML::LibXML>, L<XML::TreeBuilder>, L<XML::Twig>, or |
145
|
|
|
|
|
|
|
L<Mojo::DOM>. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AFFILIATION |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This policy is part of L<Perl::Critic::Freenode>. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 CONFIGURATION |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This policy is not configurable except for the standard options. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 AUTHOR |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Dan Book, C<dbook@cpan.org> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Copyright 2015, Dan Book. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This library is free software; you may redistribute it and/or modify it under |
164
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 SEE ALSO |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L<Perl::Critic> |