Perl/Lint/Policy/RegularExpressions/ProhibitUselessTopic.pm

filter: Statementstmt 75.8% 22 / 29 Branchbran 25.0% 3 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 53.4% 31 / 58 CC 9 SCAR 32.1
CC
9
Cov
53%
evaluate
38.0
BEGIN
1.0
BEGIN
1.0
CRAP 24.8
« Perl/Lint/Policy/Subroutines/ProhibitAmpersandSigils.pm ↑ Summary Perl/Lint/Policy/ControlStructures/ProhibitUnlessBlocks.pm »
1 package Perl::Lint::Policy::RegularExpressions::ProhibitUselessTopic;
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 => 'Useless use of $_',
9 EXPL => '$_ should be omitted when matching a regular expression',
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_type; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 51 2 53
17 51 $token_type = $token->{type};
18  
19 51 ▶ if ($token_type == SPECIFIC_VALUE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 137) 0 51 51
20 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
21 0 $token_type = $token->{type};
22  
23 0 ▶ if ($token_type == REG_OK || $token_type == REG_NOT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 35 or $token_type == 36) 0 0 0
Condition0%0/3
$token_type == 35 or $token_type == 36
l!l&&r!l&&!r
000
MC/DC0%0/2
$token_type == 35 or $token_type == 36
$token_type == 35 $token_type == 36
Truth table0%0/3
A or B
A= $token_type == 35B= $token_type == 36
ABresult
1X1
011
000
24 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
25 0 $token_type = $token->{type};
26  
27 0 ▶ if ($token_type != VAR && $token_type != GLOBAL_VAR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type != 166 and $token_type != 194) 0 0 0
Condition0%0/3
$token_type != 166 and $token_type != 194
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type != 166 and $token_type != 194
$token_type != 166 $token_type != 194
Truth table0%0/3
A and B
A= $token_type != 166B= $token_type != 194
ABresult
0X0
100
111
28 push @violations, {
29 filename => $file,
30 line => $token->{line},
31 0 description => DESC,
32 explanation => EXPL,
33 policy => __PACKAGE__,
34 };
35 }
36 }
37 }
38  
39 }
40  
41 2 return \@violations;
42 }
43  
44 3 1;
45  
« Perl/Lint/Policy/Subroutines/ProhibitAmpersandSigils.pm ↑ Summary Perl/Lint/Policy/ControlStructures/ProhibitUnlessBlocks.pm »