« lib/Perl/Critic/Theme.pm
↑ Summary
lib/Perl/Critic/Policy/Miscellanea/ProhibitUselessNoCritic.pm »
| 1 | package Perl::Critic::Policy::Variables::RequireInitializationForLocalVars; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 40 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 40 | ▶ | use Perl::Critic::Utils qw{ :severities }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 40 | ▶ | use parent 'Perl::Critic::Policy'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 40 | our $VERSION = '1.156'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 40 | Readonly::Scalar my $DESC => q{"local" variable not initialized}; | |||||||||||||||||||||||||||
| 16 | 40 | Readonly::Scalar my $EXPL => [ 78 ]; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 90 | ▶ | sub supported_parameters { return () } | ||||||||||||||||||||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 74 | ▶ | sub default_severity { return $SEVERITY_MEDIUM } | ||||||||||||||||||||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | 91 | ▶ | sub default_themes { return qw(core pbp bugs certrec ) } | ||||||||||||||||||||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 31 | ▶ | sub applies_to { return 'PPI::Statement::Variable' } | ||||||||||||||||||||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 85 | ▶ | sub violates { | ||||||||||||||||||||||||||
|
Subroutine
violates: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 85 | my ( $self, $elem, undef ) = @_; | |||||||||||||||||||||||||||
| 29 | 85 | ▶ | if ( $elem->type() eq 'local' && !_is_initialized($elem) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$elem->type eq "local" and not _is_initialized($elem)
MC/DC0%0/2
$elem->type eq "local" and not _is_initialized($elem)
$elem->type eq "local"
not _is_initialized($elem)
Truth table33%1/3
A and not(B)
A= $elem->type eq "local"B= not _is_initialized($elem)
| |||||||||||||||||||||||||||||
| 30 | 0 | return $self->violation( $DESC, $EXPL, $elem ); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 85 | return; #ok! | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub _is_initialized { | ||||||||||||||||||||||||||
|
Subroutine
_is_initialized: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 38 | 0 | my $elem = shift; | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | my $wanted = sub { $_[1]->isa('PPI::Token::Operator') && $_[1] eq q{=} }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | return $elem->find( $wanted ) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 40 | 1; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||||||||||