Perl/Lint/Policy/ControlStructures/ProhibitUntilBlocks.pm

filter: Statementstmt 70.9% 22 / 31 Branchbran 18.7% 3 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 57.4% 31 / 54 CC 9 SCAR 32.1
CC
9
Cov
53%
evaluate
38.0
BEGIN
1.0
BEGIN
1.0
CRAP 24.8
« Perl/Lint/Policy/ControlStructures/ProhibitUnlessBlocks.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/RequireBlockGrep.pm »
1 package Perl::Lint::Policy::ControlStructures::ProhibitUntilBlocks;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 DESC => '"until" block used',
9 EXPL => [97],
10 3 };
11  
12 2 ▶sub evaluate {
Subroutine evaluate: called CC=9 SCAR=36.4
Pod undocumented
13 2 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 2 my @violations;
16 2 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 51 2 53
17 51 my $token_type = $token->{type};
18  
19 51 ▶ if ($token_type == UNTIL_STATEMENT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 100) 0 51 51
20 0 ▶ if ($tokens->[++$i]->{type} == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$tokens[++$i]{"type"} == 107) 0 0 0
21 0 my $left_paren_num = 1;
22 0 ▶ for ($i++; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
23 0 my $token_type = $token->{type};
24 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 107) { } 0 0 0
elsif ($token_type == 108) { } 0 0 0
25 0 $left_paren_num++;
26 }
27 elsif ($token_type == RIGHT_PAREN) {
28 0 ▶ last if --$left_paren_num <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$left_paren_num <= 0 0 0 0
29 }
30 }
31 0 ▶ if ($tokens->[++$i]->{type} == LEFT_BRACE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$tokens[++$i]{"type"} == 109) 0 0 0
32 push @violations, {
33 filename => $file,
34 line => $token->{line},
35 0 description => DESC,
36 explanation => EXPL,
37 policy => __PACKAGE__,
38 };
39 }
40 }
41 }
42 }
43  
44 2 return \@violations;
45 }
46  
47 3 1;
48  
« Perl/Lint/Policy/ControlStructures/ProhibitUnlessBlocks.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/RequireBlockGrep.pm »