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