| 1 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | package Perl::Critic::Policy::Tics::ProhibitUseBase 0.010; | ||||||||||
| 4 | # ABSTRACT: do not use base.pm | ||||||||||
| 5 | |||||||||||
| 6 | #pod =head1 DESCRIPTION | ||||||||||
| 7 | #pod | ||||||||||
| 8 | #pod use base qw(Baseclass); | ||||||||||
| 9 | #pod | ||||||||||
| 10 | #pod You've seen that a hundred times, right? That doesn't mean that it's a good | ||||||||||
| 11 | #pod idea. It screws with C<$VERSION>, it alters (for the worse) the exceptions | ||||||||||
| 12 | #pod reported by failure-to-require, it doesn't let you call the base class's | ||||||||||
| 13 | #pod C<import> method, it pushes to C<@INC> rather than replacing it, and it uses | ||||||||||
| 14 | #pod and documents interactions with L<fields|fields>, which can lead one to believe | ||||||||||
| 15 | #pod that fields are even remotely relevant to modern (or any!) development of Perl | ||||||||||
| 16 | #pod classes. | ||||||||||
| 17 | #pod | ||||||||||
| 18 | #pod There are a lot of ways around using C<base>. Pick one. | ||||||||||
| 19 | #pod | ||||||||||
| 20 | #pod =head1 WARNING | ||||||||||
| 21 | #pod | ||||||||||
| 22 | #pod This policy caused a bit of controversy, largely in this form: | ||||||||||
| 23 | #pod | ||||||||||
| 24 | #pod These behaviors are either correct or can be worked around, and using base.pm | ||||||||||
| 25 | #pod protects you from the problem of remembering to load prereqs and from | ||||||||||
| 26 | #pod setting @INC at runtime. | ||||||||||
| 27 | #pod | ||||||||||
| 28 | #pod These are true statements. My chosen workaround for all these problems is to | ||||||||||
| 29 | #pod I<not use base.pm>. That doesn't mean it's a good idea for you, or anyone | ||||||||||
| 30 | #pod else. Heck, it doesn't mean it's a good idea for me, either. It's just my | ||||||||||
| 31 | #pod preference. As with all Perl::Critic policies, you should decide whether it's | ||||||||||
| 32 | #pod right for you. | ||||||||||
| 33 | #pod | ||||||||||
| 34 | #pod =cut | ||||||||||
| 35 | |||||||||||
| 36 | 5 | ▶ | use Perl::Critic::Utils; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 37 | 5 | ▶ | use parent qw(Perl::Critic::Policy); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | |||||||||||
| 39 | 5 | my $DESCRIPTION = q{Use of "base" pragma}; | |||||||||
| 40 | 5 | my $EXPLANATION = q{Don't use base, set @INC or use a base.pm alternative.}; | |||||||||
| 41 | |||||||||||
| 42 | 2 | ▶ | sub default_severity { $SEVERITY_LOW } | ||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 43 | 0 | ▶ | sub default_themes { qw(tics) } | ||||||||
|
Subroutine
default_themes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 44 | 3 | ▶ | sub applies_to { 'PPI::Statement::Include' } | ||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 45 | |||||||||||
| 46 | 3 | ▶ | sub violates { | ||||||||
|
Subroutine
violates: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 47 | 3 | my ($self, $elem, $doc) = @_; | |||||||||
| 48 | |||||||||||
| 49 | 3 | ▶ | return unless $elem->module eq 'base'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | # Must be a violation... | ||||||||||
| 52 | 2 | return $self->violation($DESCRIPTION, $EXPLANATION, $elem); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 5 | 1; | |||||||||
| 56 | |||||||||||
| 57 | __END__ | ||||||||||