lib/Perl/Critic/Policy/ControlStructures/ProhibitCStyleForLoops.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 80.0% 4 / 5 totaltotal 92.9% 53 / 57 CC 3 SCAR 2.7
CC
3
Cov
92%
violates
2.1
_is_cstyle
2.0
BEGIN
1.0
CRAP 1.3
« lib/Perl/Critic/Exception/Configuration/Option.pm ↑ Summary lib/Perl/Critic/Exception/Configuration/Option/Global/ExtraParameter.pm »
1 package Perl::Critic::Policy::ControlStructures::ProhibitCStyleForLoops;
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{ :characters :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{C-style "for" loop used};
16 40 Readonly::Scalar my $EXPL => [ 100 ];
17  
18 #-----------------------------------------------------------------------------
19  
20 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
21 76 ▶sub default_severity { return $SEVERITY_LOW }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
22 85 ▶sub default_themes { return qw( core pbp maintenance ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
23 31 ▶sub applies_to { return 'PPI::Structure::For' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
24  
25 #-----------------------------------------------------------------------------
26  
27 2 ▶sub violates {
Subroutine violates: called CC=2 SCAR=7.6
Pod documented
28 2 my ( $self, $elem, undef ) = @_;
29  
30 2 ▶ if ( _is_cstyle($elem) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_cstyle($elem)) 2 0 2
31 2 return $self->violation( $DESC, $EXPL, $elem );
32 }
33 0 return; #ok!
34 }
35  
36 2 ▶sub _is_cstyle {
Subroutine _is_cstyle: called CC=2 SCAR=7.0
37 2 my $elem = shift;
38 2 my $nodes_ref = $elem->find('PPI::Token::Structure');
39 2 ▶ return if !$nodes_ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $nodes_ref 0 2 2
40 2 my @semis = grep { $_ eq $SCOLON } @{$nodes_ref};
41 2 return scalar @semis == 2;
42 }
43  
44 40 1;
45  
46 __END__
« lib/Perl/Critic/Exception/Configuration/Option.pm ↑ Summary lib/Perl/Critic/Exception/Configuration/Option/Global/ExtraParameter.pm »