line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Freenode::PreferredAlternatives; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
656
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Perl::Critic::Utils qw(:severities :classification :ppi); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
7
|
1
|
|
|
1
|
|
363
|
use parent 'Perl::Critic::Policy'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.033'; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
0
|
8441
|
sub supported_parameters { () } |
12
|
5
|
|
|
5
|
1
|
55
|
sub default_severity { $SEVERITY_LOW } |
13
|
0
|
|
|
0
|
1
|
0
|
sub default_themes { 'freenode' } |
14
|
2
|
|
|
2
|
1
|
24992
|
sub applies_to { 'PPI::Statement::Include' } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %modules = ( |
17
|
|
|
|
|
|
|
'Getopt::Std' => 'Getopt::Std was the original very simplistic command-line option processing module. It is now obsoleted by the much more complete solution Getopt::Long, which also supports short options, and is wrapped by module such as Getopt::Long::Descriptive and Getopt::Long::Modern for simpler usage.', |
18
|
|
|
|
|
|
|
'JSON' => 'JSON.pm is old and full of slow logic. Use JSON::MaybeXS instead, it is a drop-in replacement in most cases.', |
19
|
|
|
|
|
|
|
'List::MoreUtils' => 'List::MoreUtils is a far more complex distribution than it needs to be. Use List::SomeUtils instead, or see List::Util or List::UtilsBy for alternatives.', |
20
|
|
|
|
|
|
|
'Mouse' => 'Mouse was created to be a faster version of Moose, a niche that has since been better filled by Moo. Use Moo instead.', |
21
|
|
|
|
|
|
|
'Readonly' => 'Readonly.pm is buggy and slow. Use Const::Fast or ReadonlyX instead, or the core pragma constant.', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _violation { |
25
|
5
|
|
|
5
|
|
111
|
my ($self, $module, $elem) = @_; |
26
|
5
|
|
|
|
|
16
|
my $desc = "Used module $module"; |
27
|
5
|
|
33
|
|
|
16
|
my $expl = $modules{$module} // "Module $module has preferred alternatives."; |
28
|
5
|
|
|
|
|
21
|
return $self->violation($desc, $expl, $elem); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub violates { |
32
|
17
|
|
|
17
|
1
|
1417
|
my ($self, $elem) = @_; |
33
|
17
|
100
|
66
|
|
|
46
|
return () unless defined $elem->module and exists $modules{$elem->module}; |
34
|
5
|
|
|
|
|
245
|
return $self->_violation($elem->module, $elem); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Perl::Critic::Policy::Freenode::PreferredAlternatives - Various modules with |
42
|
|
|
|
|
|
|
preferred alternatives |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Various modules have alternatives that are preferred by the denizens of #perl |
47
|
|
|
|
|
|
|
on Freenode IRC, for various reasons which may include: buggy behavior, cruft, |
48
|
|
|
|
|
|
|
performance problems, maintainer issues, or simply better modern replacements. |
49
|
|
|
|
|
|
|
This is a low severity complement to |
50
|
|
|
|
|
|
|
L<Perl::Critic::Policy::Freenode::DiscouragedModules>. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 MODULES |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 Getopt::Std |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
L<Getopt::Std> was the original very simplistic command-line option processing |
57
|
|
|
|
|
|
|
module. It is now obsoleted by the much more complete solution L<Getopt::Long>, |
58
|
|
|
|
|
|
|
which also supports short options, and is wrapped by modules such as |
59
|
|
|
|
|
|
|
L<Getopt::Long::Descriptive> and L<Getopt::Long::Modern> for simpler usage. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 JSON |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
L<JSON>.pm is old and full of slow logic. Use L<JSON::MaybeXS> instead, it is a |
64
|
|
|
|
|
|
|
drop-in replacement in most cases. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 List::MoreUtils |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L<List::MoreUtils> is a far more complex distribution than it needs to be. Use |
69
|
|
|
|
|
|
|
L<List::SomeUtils> instead, or see L<List::Util> or L<List::UtilsBy> for |
70
|
|
|
|
|
|
|
alternatives. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 Mouse |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
L<Mouse> was created to be a faster version of L<Moose>, a niche that has since |
75
|
|
|
|
|
|
|
been better filled by L<Moo>. Use L<Moo> instead. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 Readonly |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
L<Readonly>.pm is buggy and slow. Use L<Const::Fast> or L<ReadonlyX> instead, |
80
|
|
|
|
|
|
|
or the core pragma L<constant>. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AFFILIATION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This policy is part of L<Perl::Critic::Freenode>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 CONFIGURATION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This policy is not configurable except for the standard options. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Dan Book, C<dbook@cpan.org> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Copyright 2015, Dan Book. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This library is free software; you may redistribute it and/or modify it under |
99
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SEE ALSO |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L<Perl::Critic> |