lib/Perl/Critic/Policy/InputOutput/ProhibitReadlineInForLoop.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 80.0% 4 / 5 totaltotal 93.2% 55 / 59 CC 4 SCAR 5.9
CC
4
Cov
93%
violates
4.2
__ANON__
1.0
BEGIN
1.0
CRAP 1.8
« lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitUniversalIsa.pm ↑ Summary lib/Perl/Critic/ProfilePrototype.pm »
1 package Perl::Critic::Policy::InputOutput::ProhibitReadlineInForLoop;
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 List::Util qw< first >;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 40 ▶use Perl::Critic::Utils qw{ :severities };
Subroutine BEGIN: called CC=1 SCAR=0.0
11 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 40 our $VERSION = '1.156';
14  
15 #-----------------------------------------------------------------------------
16  
17 40 Readonly::Scalar my $DESC => q{Readline inside "for" loop};
18 40 Readonly::Scalar my $EXPL => [ 211 ];
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_HIGH }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
24 91 ▶sub default_themes { return qw< core bugs pbp > }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
25 33 ▶sub applies_to { return qw< PPI::Statement::Compound > }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
26  
27 #-----------------------------------------------------------------------------
28  
29 11 ▶sub violates {
Subroutine violates: called CC=4 SCAR=14.3
Pod documented
30 11 my ( $self, $elem, undef ) = @_;
31  
32 11 ▶ return if $elem->type() ne 'foreach';
Branch: 1 branch
BranchTrueFalseTotal
if $elem->type ne "foreach" 5 6 11
33  
34 6 ▶ my $list = first { $_->isa('PPI::Structure::List') } $elem->schildren()
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
my $list = &first(sub { $_->isa("PPI::Structure::List"); } , $elem->schildren) or return 6 0 6
35 or return;
36  
37 6 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (my $readline = $list->find_first("PPI::Token::QuoteLike::Readline")) 0 6 6
38 my $readline = $list->find_first('PPI::Token::QuoteLike::Readline')
39 ) {
40 0 return $self->violation( $DESC, $EXPL, $readline );
41 }
42  
43 6 return; #ok!
44 }
45  
46 40 1;
47  
48 __END__
« lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitUniversalIsa.pm ↑ Summary lib/Perl/Critic/ProfilePrototype.pm »