| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Bangs::ProhibitDebuggingModules; |
|
2
|
4
|
|
|
4
|
|
3410
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
125
|
|
|
3
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
169
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.11_02'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
22
|
use List::MoreUtils qw(any); |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
196
|
|
|
8
|
4
|
|
|
4
|
|
21
|
use Readonly; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
163
|
|
|
9
|
4
|
|
|
4
|
|
17
|
use Perl::Critic::Utils qw( :severities ); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
216
|
|
|
10
|
4
|
|
|
4
|
|
533
|
use base qw(Perl::Critic::Policy); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
1494
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Perl::Critic::Policy::Bangs::ProhibitDebuggingModules - Prohibit loading of debugging modules like Data::Dumper |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This policy prohibits loading common debugging modules like L<Data::Dumper>. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
While such modules are incredibly useful during development and debugging, |
|
21
|
|
|
|
|
|
|
they should probably not be loaded in production use. If this policy is |
|
22
|
|
|
|
|
|
|
violated, it probably means you forgot to remove a C<use Data::Dumper;> line |
|
23
|
|
|
|
|
|
|
that you had added when you were debugging. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
The current list of detected debugging modules is: |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over 4 |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item * L<Data::Dumper> |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item * L<Data::Printer> |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=back |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
To add more modules that shouldn't be loaded unless you're actively debugging |
|
38
|
|
|
|
|
|
|
something, add them in F<.perlcriticrc> using the C<deubgging_modules> option. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q/Debugging module loaded/; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub supported_parameters { |
|
45
|
|
|
|
|
|
|
return ( |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
9
|
|
|
9
|
0
|
42129
|
name => 'debugging_modules', |
|
48
|
|
|
|
|
|
|
description => 'Module names which are considered to be banned debugging modules', |
|
49
|
|
|
|
|
|
|
behavior => 'string list', |
|
50
|
|
|
|
|
|
|
list_always_present_values => [qw( |
|
51
|
|
|
|
|
|
|
B::Stats |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Carp::Always.* |
|
54
|
|
|
|
|
|
|
Carp::Diagnostics |
|
55
|
|
|
|
|
|
|
Carp::REPL |
|
56
|
|
|
|
|
|
|
Carp::Source::Always |
|
57
|
|
|
|
|
|
|
Carp::Trace |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Data::Dump |
|
60
|
|
|
|
|
|
|
Data::Dump::Filtered |
|
61
|
|
|
|
|
|
|
Data::Dump::Streamer |
|
62
|
|
|
|
|
|
|
Data::Dump::Trace |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Data::Dumper.* |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Data::Printer |
|
67
|
|
|
|
|
|
|
Data::PrettyPrintObjects |
|
68
|
|
|
|
|
|
|
Data::Show |
|
69
|
|
|
|
|
|
|
Data::Skeleton |
|
70
|
|
|
|
|
|
|
Data::TreeDumper |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
DDP |
|
73
|
|
|
|
|
|
|
DDS |
|
74
|
|
|
|
|
|
|
Devel::Ditto |
|
75
|
|
|
|
|
|
|
Devel::Dwarn |
|
76
|
|
|
|
|
|
|
Devel::Modlist |
|
77
|
|
|
|
|
|
|
Devel::Monitor |
|
78
|
|
|
|
|
|
|
Devel::StackTrace |
|
79
|
|
|
|
|
|
|
Devel::Trace |
|
80
|
|
|
|
|
|
|
Devel::Unplug |
|
81
|
|
|
|
|
|
|
) ], # DDP and DDS are shorthand module names |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
9
|
|
|
9
|
1
|
98
|
sub default_severity { return $SEVERITY_HIGH } |
|
86
|
0
|
|
|
0
|
1
|
0
|
sub default_themes { return qw/ bangs maintenance / } |
|
87
|
5
|
|
|
5
|
1
|
48947
|
sub applies_to { return 'PPI::Statement::Include' } |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub violates { |
|
90
|
21
|
|
|
21
|
1
|
1629
|
my ($self, $include, undef) = @_; |
|
91
|
21
|
50
|
66
|
|
|
72
|
return unless defined $include->type and ($include->type eq 'use' || $include->type eq 'require'); |
|
|
|
|
33
|
|
|
|
|
|
92
|
21
|
100
|
|
|
|
1594
|
my $included = $include->module or return; |
|
93
|
16
|
|
|
|
|
438
|
my $EXPL = "You've loaded $included, which probably shouln't be loaded in production"; |
|
94
|
|
|
|
|
|
|
|
|
95
|
16
|
|
|
|
|
27
|
my @banned = ( keys %{ $self->{_debugging_modules} } ); |
|
|
16
|
|
|
|
|
283
|
|
|
96
|
|
|
|
|
|
|
return $self->violation($DESC, $EXPL, $include) |
|
97
|
16
|
100
|
|
310
|
|
112
|
if (any { $included =~ m/$_/xms } @banned); |
|
|
310
|
|
|
|
|
3079
|
|
|
98
|
7
|
|
|
|
|
53
|
return; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AFFILIATION |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This policy is part of L<Perl::Critic::Bangs>. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Mike Doherty C<doherty@cpan.org> |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Copyright (c) 2012 Mike Doherty |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
114
|
|
|
|
|
|
|
it under the terms of the Artistic License 2.0. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |