| 1 | package Perl::Critic::Policy::logicLAB::ProhibitUseLib; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use base 'Perl::Critic::Policy'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use Perl::Critic::Utils qw{ $SEVERITY_MEDIUM }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 3 | ▶ | use 5.008; #5.8.0 | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 3 | our $VERSION = '0.04'; | |||||||||
| 10 | |||||||||||
| 11 | 3 | Readonly::Scalar my $EXPL => q{Use PERL5LIB environment instead}; | |||||||||
| 12 | |||||||||||
| 13 | 3 | ▶ | use constant supported_parameters => (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 3 | ▶ | use constant default_severity => $SEVERITY_MEDIUM; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 3 | ▶ | use constant default_themes => qw(logiclab); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 3 | ▶ | use constant applies_to => 'PPI::Statement::Include'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 6 | ▶ | sub violates { | ||||||||
|
Subroutine
violates: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 19 | 6 | my ( $self, $elem ) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 6 | my $child = $elem->schild(1); #second token | |||||||||
| 22 | 6 | ▶ | return if !$child; #return if no token, this will not be relevant to us | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | |||||||||||
| 24 | #second token should read: lib | ||||||||||
| 25 | #See t/test.t for examples of variations | ||||||||||
| 26 | 5 | ▶ | $child =~ m{ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | \A #beginning of string | ||||||||||
| 28 | lib #the word 'lib' | ||||||||||
| 29 | \Z #end of string | ||||||||||
| 30 | }xsm or return; | ||||||||||
| 31 | |||||||||||
| 32 | 4 | return $self->violation( q{Do not use 'use lib' statements}, $EXPL, | |||||||||
| 33 | $child ); | ||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 3 | 1; | |||||||||
| 37 | |||||||||||
| 38 | __END__ | ||||||||||