line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::logicLAB::ProhibitUseLib; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id$ |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
274014
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
112
|
|
6
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
102
|
|
7
|
3
|
|
|
3
|
|
14
|
use base 'Perl::Critic::Policy'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2910
|
|
8
|
3
|
|
|
3
|
|
504535
|
use Perl::Critic::Utils qw{ $SEVERITY_MEDIUM }; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
316
|
|
9
|
3
|
|
|
3
|
|
70
|
use 5.008; #5.8.0 |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
233
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Use PERL5LIB environment instead}; |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
20
|
use constant supported_parameters => (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
251
|
|
16
|
3
|
|
|
3
|
|
17
|
use constant default_severity => $SEVERITY_MEDIUM; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
144
|
|
17
|
3
|
|
|
3
|
|
15
|
use constant default_themes => qw(logiclab); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
122
|
|
18
|
3
|
|
|
3
|
|
14
|
use constant applies_to => 'PPI::Statement::Include'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
410
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub violates { |
21
|
6
|
|
|
6
|
1
|
1967810
|
my ( $self, $elem ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
|
|
25
|
my $child = $elem->schild(1); #second token |
24
|
6
|
100
|
|
|
|
95
|
return if !$child; #return if no token, this will not be relevant to us |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#second token should read: lib |
27
|
|
|
|
|
|
|
#See t/test.t for examples of variations |
28
|
5
|
100
|
|
|
|
14
|
$child =~ m{ |
29
|
|
|
|
|
|
|
\A #beginning of string |
30
|
|
|
|
|
|
|
lib #the word 'lib' |
31
|
|
|
|
|
|
|
\Z #end of string |
32
|
|
|
|
|
|
|
}xsm or return; |
33
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
38
|
return $self->violation( q{Do not use 'use lib' statements}, $EXPL, |
35
|
|
|
|
|
|
|
$child ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Perl::Critic::Policy::logicLAB::ProhibitUseLib - simple policy prohibiting the use of 'use lib' |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 AFFILIATION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This policy is a policy in the L<Perl::Critic::logicLAB> distribution. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 VERSION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This documentation describes version 0.03 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
The 'use lib' statement, hardcodes the include path to be used. This can give |
59
|
|
|
|
|
|
|
issues when moving modules and scripts between diverse environments. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
use lib '/some/path'; #not ok |
62
|
|
|
|
|
|
|
use lib qw(/you/do/not/want/to/go/down/this/path /or/this); #not ok |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Instead use the environment variable PERL5LIB |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#bash |
67
|
|
|
|
|
|
|
export PERL5LIB='/some/path/some/where' |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#tcsh and csh |
70
|
|
|
|
|
|
|
setenv PERL5LIB '/some/path/some/where' |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This Policy is not configurable except for the standard options. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DEPENDENCIES AND REQUIREMENTS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=over |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item * L<Perl::Critic> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * L<Perl::Critic::Utils> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * L<Readonly> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * L<Test::More> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * L<Test::Perl::Critic> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This distribution has no known incompatibilities. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Currently the policy has no special opinion on L<FindBin>. It only aims to |
99
|
|
|
|
|
|
|
address messy, misleading, buggy and obscuring use of 'use lib'. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 BUG REPORTING |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Please use Requets Tracker for bug reporting: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Perl-Critic-logicLAB-ProhibitUseLib |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 TEST AND QUALITY |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
The following policies have been disabled for this distribution |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * L<Perl::Crititc::Policy::ValuesAndExpressions::ProhibitConstantPragma> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * L<Perl::Crititc::Policy::NamingConventions::Capitalization> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
See also F<t/perlcriticrc> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 TEST COVERAGE |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
---------------------------- ------ ------ ------ ------ ------ ------ ------ |
124
|
|
|
|
|
|
|
File stmt bran cond sub pod time total |
125
|
|
|
|
|
|
|
---------------------------- ------ ------ ------ ------ ------ ------ ------ |
126
|
|
|
|
|
|
|
...ogicLAB/ProhibitUseLib.pm 100.0 50.0 n/a 100.0 100.0 100.0 95.3 |
127
|
|
|
|
|
|
|
Total 100.0 50.0 n/a 100.0 100.0 100.0 95.3 |
128
|
|
|
|
|
|
|
---------------------------- ------ ------ ------ ------ ------ ------ ------ |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SEE ALSO |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=over |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * L<http://perldoc.perl.org/perlrun.html#ENVIRONMENT> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * L<http://logiclab.jira.com/wiki/display/OPEN/Development#Development-MakeyourComponentsEnvironmentAgnostic> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * L<http://logicLAB.jira.com/wiki/display/PCPMPUL/Home> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=over |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * Jonas B. Nielsen, jonasbn C<< <jonasbn@cpan.org> >> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Copyright (c) 2009-2014 Jonas B. Nielsen. All rights reserved. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |