Perl/Lint/Policy/Objects/IndirectSyntax.pm

filter: Statementstmt 83.3% 30 / 36 Branchbran 50.0% 4 / 8 Conditioncond 13.3% 2 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 1 totaltotal 56.5% 43 / 76 CC 10 SCAR 28.6
CC
10
Cov
61%
evaluate
29.0
__ANON__
1.2
BEGIN
1.0
CRAP 17.5
« Perl/Lint/Policy/InputOutput/ProhibitBarewordFileHandles.pm ↑ Summary Perl/Lint/Policy/ClassHierarchies/ProhibitExplicitISA.pm »
1 package Perl::Lint::Policy::Objects::IndirectSyntax;
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 List::Util 1.38 qw/any/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 DESC => 'Subroutine "%s" called using indirect syntax',
10 EXPL => [349],
11 3 };
12  
13 2 ▶sub evaluate {
Subroutine evaluate: called CC=10 SCAR=33.7
Pod undocumented
14 2 my ($class, $file, $tokens, $src, $args) = @_;
15  
16 2 my @forbidden = ('new');
17 2 my $forbid_arg = $args->{indirect_syntax}->{forbid};
18 2 ▶ if ($forbid_arg && ref $forbid_arg eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($forbid_arg and ref $forbid_arg eq "ARRAY") 0 2 2
Condition33%1/3
$forbid_arg and ref $forbid_arg eq "ARRAY"
!ll&&!rl&&r
200
MC/DC0%0/2
$forbid_arg and ref $forbid_arg eq "ARRAY"
$forbid_arg ref $forbid_arg eq "ARRAY"
Truth table33%1/3
A and B
A= $forbid_argB= ref $forbid_arg eq "ARRAY"
ABresult
0X0
100
111
19 0 push @forbidden, @{$forbid_arg};
20 }
21  
22 2 my @violations;
23 2 my $token_num = scalar @$tokens;
24 2 ▶ for (my $i = 0; $i < $token_num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $token_num) 51 2 53
25 51 my $token = $tokens->[$i];
26 51 my $token_data = $token->{data};
27 0 ▶ if ($token->{type} == KEY && any { $token_data eq $_ } @forbidden) {
Subroutine __ANON__: not called CC=1 SCAR=1.7
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 122 and &any(sub { $token_data eq $_; } , @forbidden)) 0 51 51
Condition33%1/3
$token->{"type"} == 122 and &any(sub { $token_data eq $_; } , @forbidden)
!ll&&!rl&&r
5100
MC/DC0%0/2
$token->{"type"} == 122 and &any(sub { $token_data eq $_; } , @forbidden)
$token->{"type"} == 122 &any(sub { $token_data eq $_; } , @forbidden)
Truth table33%1/3
A and B
A= $token->{"type"} == 122B= &any(sub { $token_data eq $_; } , @forbidden)
ABresult
0X0
100
111
28 0 my $token_type = $tokens->[++$i]->{type};
29 0 ▶ if ($token_type == KEY ||
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 122 or $token_type == 194 or $token_type == 166 or $token_type == 109) 0 0 0
Condition0%0/9
$token_type == 122 or $token_type == 194 or $token_type == 166 or $token_type == 109
l!l&&r!l&&!r
000
$token_type == 122 or $token_type == 194 or $token_type == 166
l!l&&r!l&&!r
000
$token_type == 122 or $token_type == 194
l!l&&r!l&&!r
000
MC/DC0%0/4
$token_type == 122 or $token_type == 194 or $token_type == 166 or $token_type == 109
$token_type == 122 $token_type == 194 $token_type == 166 $token_type == 109
Truth table0%0/5
A or B or C or D
A= $token_type == 122B= $token_type == 194C= $token_type == 166D= $token_type == 109
ABCDresult
1XXX1
01XX1
001X1
00011
00000
30 $token_type == GLOBAL_VAR ||
31 $token_type == VAR ||
32 $token_type == LEFT_BRACE
33 ) {
34 push @violations, {
35 filename => $file,
36 line => $token->{line},
37 0 description => sprintf(DESC, $token_data),
38 explanation => sprintf(EXPL, $token_data),
39 policy => __PACKAGE__,
40 };
41 }
42 }
43 }
44  
45 2 return \@violations;
46 }
47  
48 3 1;
49  
« Perl/Lint/Policy/InputOutput/ProhibitBarewordFileHandles.pm ↑ Summary Perl/Lint/Policy/ClassHierarchies/ProhibitExplicitISA.pm »