lib/Perl/Critic/Policy/RegularExpressions/RequireExtendedFormatting.pm

filter: Statementstmt 90.6% 29 / 32 Branchbran 25.0% 2 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 80.0% 4 / 5 totaltotal 77.0% 47 / 61 CC 6 SCAR 17.8
CC
6
Cov
74%
violates
14.2
BEGIN
1.0
BEGIN
1.0
CRAP 6.0
« lib/Perl/Critic/Policy/TestingAndDebugging/RequireUseWarnings.pm ↑ Summary lib/Perl/Critic/Policy/Variables/ProhibitConditionalDeclarations.pm »
1 package Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting;
2  
3 40 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 40 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 ▶use Perl::Critic::Utils qw{ :severities };
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 40 our $VERSION = '1.156';
13  
14 #-----------------------------------------------------------------------------
15  
16 40 Readonly::Scalar my $DESC => q{Regular expression without "/x" flag};
17 40 Readonly::Scalar my $EXPL => [ 236 ];
18  
19 #-----------------------------------------------------------------------------
20  
21 92 ▶sub supported_parameters {
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
22 return (
23 {
24 92 name => 'minimum_regex_length_to_complain_about',
25 description =>
26 q<The number of characters that a regular expression must contain before this policy will complain.>,
27 behavior => 'integer',
28 default_string => '0',
29 integer_minimum => 0,
30 },
31 {
32 name => 'strict',
33 description =>
34 q<Should regexes that only contain whitespace and word characters be complained about?>,
35 behavior => 'boolean',
36 default_string => '0',
37 },
38 );
39 }
40  
41 73 ▶sub default_severity { return $SEVERITY_MEDIUM }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
42 85 ▶sub default_themes { return qw< core pbp maintenance > }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
43 31 ▶sub applies_to {
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
44 31 return qw<
45 PPI::Token::Regexp::Match
46 PPI::Token::Regexp::Substitute
47 PPI::Token::QuoteLike::Regexp
48 >;
49 }
50  
51 #-----------------------------------------------------------------------------
52  
53 1 ▶sub violates {
Subroutine violates: called CC=6 SCAR=26.5
Pod documented
54 1 my ( $self, $elem, $doc ) = @_;
55  
56 1 my $match = $elem->get_match_string();
57 1 ▶ return if length $match <= $self->{_minimum_regex_length_to_complain_about};
Branch: 1 branch
BranchTrueFalseTotal
if length $match <= $self->{"_minimum_regex_length_to_complain_about"} 0 1 1
58 1 ▶ return if not $self->{_strict} and $match =~ m< \A [\s\w]* \z >xms;
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"_strict"} and $match =~ / \A [\s\w]* \z /msx 1 0 1
Condition33%1/3
not $self->{"_strict"} and $match =~ / \A [\s\w]* \z /msx
!ll&&!rl&&r
001
MC/DC0%0/2
not $self->{"_strict"} and $match =~ / \A [\s\w]* \z /msx
not $self->{"_strict"} $match =~ / \A [\s\w]* \z /msx
Truth table33%1/3
not(A) and B
A= not $self->{"_strict"}B= $match =~ / \A [\s\w]* \z /msx
ABresult
0X0
100
111
59  
60 0 ▶ my $re = $doc->ppix_regexp_from_element( $elem )
Branch: 1 branch
BranchTrueFalseTotal
my $re = $doc->ppix_regexp_from_element($elem) or return 0 0 0
61 or return;
62 0 ▶ $re->modifier_asserted( 'x' )
Branch: 1 branch
BranchTrueFalseTotal
$re->modifier_asserted("x") or return $self->violation($DESC, $EXPL, $elem) 0 0 0
63 or return $self->violation( $DESC, $EXPL, $elem );
64  
65 0 return; # ok!;
66 }
67  
68 40 1;
69  
70 __END__
« lib/Perl/Critic/Policy/TestingAndDebugging/RequireUseWarnings.pm ↑ Summary lib/Perl/Critic/Policy/Variables/ProhibitConditionalDeclarations.pm »