| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Plicease::ProhibitSpecificModules; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2979887
|
use strict; |
|
|
5
|
|
|
|
|
18
|
|
|
|
5
|
|
|
|
|
215
|
|
|
4
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
255
|
|
|
5
|
5
|
|
|
5
|
|
115
|
use 5.010001; |
|
|
5
|
|
|
|
|
30
|
|
|
6
|
5
|
|
|
5
|
|
29
|
use Perl::Critic::Utils qw( $SEVERITY_HIGH ); |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
731
|
|
|
7
|
5
|
|
|
5
|
|
29
|
use base qw( Perl::Critic::Policy ); |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
2567
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Prohibit the use of specific modules or pragmas |
|
10
|
|
|
|
|
|
|
our $VERSION = '0.10'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub supported_parameters |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
|
|
|
|
|
|
return ( |
|
16
|
|
|
|
|
|
|
{ |
|
17
|
3
|
|
|
3
|
0
|
2063389
|
name => 'illicit_modules', |
|
18
|
|
|
|
|
|
|
description => 'Modules that should not be allowed.', |
|
19
|
|
|
|
|
|
|
behavior => 'string list', |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
1
|
45
|
sub default_severity { $SEVERITY_HIGH } |
|
25
|
0
|
|
|
0
|
1
|
0
|
sub default_themes { () } |
|
26
|
3
|
|
|
3
|
1
|
34270
|
sub applies_to { 'PPI::Statement::Include' } |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub violates |
|
29
|
|
|
|
|
|
|
{ |
|
30
|
9
|
|
|
9
|
1
|
207
|
my($self, $elem) = @_; |
|
31
|
9
|
|
|
|
|
18
|
my @violations; |
|
32
|
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
34
|
my $module_name = $elem->module; |
|
34
|
9
|
100
|
66
|
|
|
311
|
if(defined $module_name && $self->{_illicit_modules}->{$module_name}) |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
3
|
|
|
|
|
22
|
push @violations, $self->violation( |
|
37
|
|
|
|
|
|
|
"Used module $module_name", |
|
38
|
|
|
|
|
|
|
"Module $module_name should not be used.", |
|
39
|
|
|
|
|
|
|
$elem |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
9
|
|
|
|
|
744
|
return @violations; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=encoding UTF-8 |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Perl::Critic::Policy::Plicease::ProhibitSpecificModules - Prohibit the use of specific modules or pragmas |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 VERSION |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
version 0.10 |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
perlcriticrc: |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
[Plicease::ProhibitSpecificModules] |
|
67
|
|
|
|
|
|
|
illicit_modules = Foo Bar |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
code: |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
use Foo; # not ok |
|
72
|
|
|
|
|
|
|
use Bar; # not ok |
|
73
|
|
|
|
|
|
|
use Baz; # ok |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The policy L<Perl::Critic::Policy::Community::DiscouragedModules> |
|
78
|
|
|
|
|
|
|
provides a good start for modules that typically should not be used |
|
79
|
|
|
|
|
|
|
in new code, however for specific organizational policies, you may |
|
80
|
|
|
|
|
|
|
want to disallow specific modules. This policy has been designed |
|
81
|
|
|
|
|
|
|
to allow you to do exactly that without any "starter" disallowed |
|
82
|
|
|
|
|
|
|
modules. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AFFILIATION |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
None. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over 4 |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * illicit_modules |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Space separated list of modules that should be disallowed. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The policy is also configurable with the standard options. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt> |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Contributors: |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Ville Skyttä (SCOP) |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Yoshikazu Sawa (yoshikazusawa) |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Christian Walde (wchristian, MITHALDU) |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This software is copyright (c) 2019-2024 by Graham Ollis. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
117
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |