Perl/Lint/Policy/RegularExpressions/ProhibitSingleCharAlternation.pm

filter: Statementstmt 68.5% 24 / 35 Branchbran 35.7% 5 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 62.5% 35 / 56 CC 10 SCAR 30.8
CC
10
Cov
59%
evaluate
32.3
BEGIN
1.0
BEGIN
1.0
CRAP 21.8
« Perl/Lint/Policy/Modules/RequireFilenameMatchesPackage.pm ↑ Summary Perl/Lint/Policy/InputOutput/ProhibitBarewordFileHandles.pm »
1 package Perl::Lint::Policy::RegularExpressions::ProhibitSingleCharAlternation;
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 => 'Use [%s] instead of %s',
9 EXPL => [265],
10 3 };
11  
12 2 ▶sub evaluate {
Subroutine evaluate: called CC=10 SCAR=34.7
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_data; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 51 2 53
17 51 $token_type = $token->{type};
18 51 $token_data = $token->{data};
19  
20 51 ▶ if ($token_type == REG_EXP) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 187) 2 49 51
21 2 ▶ if (my @groups = $token_data =~ /\( \?\: \s* (.+?) \s* \)/gx) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@groups) = $token_data =~ /\( \?\: \s* (.+?) \s* \)/gx) 0 2 2
22 0 TRAVERSE_REGEX: for my $group (@groups) {
23 0 ▶ if ($group =~ /\A \w \Z/x) {
Branch: 1 branch
BranchTrueFalseTotal
if ($group =~ /\A \w \Z/x) 0 0 0
24 0 last;
25 }
26  
27 0 my @singles;
28 0 for my $part (split /\s* \| \s*/x, $group) {
29 0 ▶ if ($part !~ /\A \w+ \Z/x) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($part =~ /\A \w+ \Z/x) 0 0 0
30 0 last TRAVERSE_REGEX;
31 }
32  
33 0 ▶ if (length $part == 1) { # if single char
Branch: 1 branch
BranchTrueFalseTotal
if (length $part == 1) 0 0 0
34 0 push @singles, $part;
35 }
36 }
37  
38 0 ▶ if (scalar @singles > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singles > 1) 0 0 0
39 push @violations, {
40 filename => $file,
41 line => $token->{line},
42 0 description => sprintf(
43 DESC,
44 join('', @singles),
45 join('|', @singles),
46 ),
47 explanation => EXPL,
48 policy => __PACKAGE__,
49 };
50 }
51 }
52 }
53 }
54 }
55  
56 2 return \@violations;
57 }
58  
59 3 1;
60  
« Perl/Lint/Policy/Modules/RequireFilenameMatchesPackage.pm ↑ Summary Perl/Lint/Policy/InputOutput/ProhibitBarewordFileHandles.pm »