« lib/Perl/Critic/UserProfile.pm
↑ Summary
lib/Perl/Critic/Policy/InputOutput/RequireCheckedSyscalls.pm »
| 1 | package Perl::Critic::Policy::Subroutines::ProhibitNestedSubs; | ||||||||||||||||||||||||||||
| 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{Nested named subroutine}; | |||||||||||||||||||||||||||
| 16 | 40 | Readonly::Scalar my $EXPL => | |||||||||||||||||||||||||||
| 17 | q{Declaring a named sub inside another named sub does not prevent the } | ||||||||||||||||||||||||||||
| 18 | . q{inner sub from being global}; | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 90 | ▶ | sub supported_parameters { return () } | ||||||||||||||||||||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 74 | ▶ | sub default_severity { return $SEVERITY_HIGHEST } | ||||||||||||||||||||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 73 | ▶ | sub default_themes { return qw(core bugs) } | ||||||||||||||||||||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 37 | ▶ | sub applies_to { return 'PPI::Statement::Sub' } | ||||||||||||||||||||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 5 | ▶ | sub violates { | ||||||||||||||||||||||||||
|
Subroutine
violates: called CC=7 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 5 | my ($self, $elem, undef) = @_; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 5 | ▶ | return if $elem->isa('PPI::Statement::Scheduled') || defined $elem->type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$elem->isa("PPI::Statement::Scheduled") or defined $elem->type
MC/DC0%0/2
$elem->isa("PPI::Statement::Scheduled") or defined $elem->type
$elem->isa("PPI::Statement::Scheduled")
defined $elem->type
Truth table33%1/3
A or B
A= $elem->isa("PPI::Statement::Scheduled")B= defined $elem->type
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 5 | my $outer = $elem; | |||||||||||||||||||||||||||
| 35 | 5 | ▶ | while ($outer = $outer->parent) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 5 | ▶ | last if $outer->isa('PPI::Statement::Sub') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$outer->isa("PPI::Statement::Sub") and not $outer->isa("PPI::Statement::Scheduled")
MC/DC0%0/2
$outer->isa("PPI::Statement::Sub") and not $outer->isa("PPI::Statement::Scheduled")
$outer->isa("PPI::Statement::Sub")
not $outer->isa("PPI::Statement::Scheduled")
Truth table33%1/3
A and not(B)
A= $outer->isa("PPI::Statement::Sub")B= not $outer->isa("PPI::Statement::Scheduled")
| |||||||||||||||||||||||||||||
| 37 | && ! $outer->isa('PPI::Statement::Scheduled'); | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 5 | ▶ | return if not $outer; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # Must be a violation... | ||||||||||||||||||||||||||||
| 42 | 0 | return $self->violation($DESC, $EXPL, $elem); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 40 | 1; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | __END__ | ||||||||||||||||||||||||||||