Perl/Lint/Policy/BuiltinFunctions/RequireSimpleSortBlock.pm

filter: Statementstmt 40.0% 16 / 40 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 30.0% 21 / 70 CC 11 SCAR 45.1
CC
11
Cov
26%
evaluate
132.0
BEGIN
1.0
BEGIN
1.0
CRAP 91.1
« Perl/Lint/Policy/ValuesAndExpressions/RequireInterpolationOfMetachars.pm ↑ Summary Perl/Lint/Policy/Modules/RequireBarewordIncludes.pm »
1 package Perl::Lint::Policy::BuiltinFunctions::RequireSimpleSortBlock;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 DESC => 'Sort blocks should have a single statement',
9 EXPL => [149],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=11 SCAR=48.8
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 my @violations;
16 0 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
17 0 my $token_type = $token->{type};
18 0 my $token_data = $token->{data};
19  
20 0 ▶ if ($token_type == BUILTIN_FUNC && $token_data eq 'sort') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 70 and $token_data eq "sort") 0 0 0
Condition0%0/3
$token_type == 70 and $token_data eq "sort"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 70 and $token_data eq "sort"
$token_type == 70 $token_data eq "sort"
Truth table0%0/3
A and B
A= $token_type == 70B= $token_data eq "sort"
ABresult
0X0
100
111
21 0 $token = $tokens->[++$i];
22 0 ▶ if ($token->{type} == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 107) 0 0 0
23 0 $token = $tokens->[++$i];
24 }
25  
26 0 my $token_type = $token->{type};
27  
28 0 ▶ if ($token_type != LEFT_BRACE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type != 109) 0 0 0
29 0 next;
30 }
31  
32 0 my $left_brace_num = 1;
33 0 my $concat_stmt = ''; # XXX
34 0 ▶ for ($i++; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
35 0 $token_type = $token->{type};
36  
37 0 ▶ if ($token_type == LEFT_BRACE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 109) { } 0 0 0
elsif ($token_type == 110) { } 0 0 0
38 0 $left_brace_num++;
39 }
40 elsif ($token_type == RIGHT_BRACE) {
41 0 ▶ if (--$left_brace_num <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$left_brace_num <= 0) 0 0 0
42 0 ▶ if (scalar(@_ = split /;/, $concat_stmt) > 1) { # XXX
Branch: 1 branch
BranchTrueFalseTotal
if (scalar(@_ = split(/;/, $concat_stmt, 0)) > 1) 0 0 0
43 push @violations, {
44 filename => $file,
45 line => $token->{line},
46 0 description => DESC,
47 explanation => EXPL,
48 policy => __PACKAGE__,
49 };
50 }
51 0 last;
52 }
53 }
54 else {
55 0 $concat_stmt .= $token->{data};
56 }
57 }
58 }
59 }
60  
61 0 return \@violations;
62 }
63  
64 2 1;
65  
« Perl/Lint/Policy/ValuesAndExpressions/RequireInterpolationOfMetachars.pm ↑ Summary Perl/Lint/Policy/Modules/RequireBarewordIncludes.pm »