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

filter: Statementstmt 80.0% 28 / 35 Branchbran 12.5% 1 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 11 / 11 Podpod 80.0% 4 / 5 totaltotal 60.2% 44 / 73 CC 8 SCAR 30.8
CC
8
Cov
56%
violates
47.6
BEGIN
1.0
BEGIN
1.0
CRAP 21.7
« lib/Perl/Critic/Policy/References/ProhibitDoubleSigils.pm ↑ Summary lib/Test/Perl/Critic/Policy.pm »
1 package Perl::Critic::Policy::RegularExpressions::ProhibitUselessTopic;
2  
3 40 ▶use 5.010;
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 :classification :ppi hashify };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 40 our $VERSION = '1.156';
12  
13 ## no critic ( ValuesAndExpressions::RequireInterpolationOfMetachars )
14 ## The numerous $_ variables make false positives.
15 40 Readonly::Scalar my $DESC => q{Useless use of $_};
16 40 Readonly::Scalar my $EXPL => q{$_ should be omitted when matching a regular expression};
17  
18 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
19 74 ▶sub default_severity { return $SEVERITY_LOW }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
20 73 ▶sub default_themes { return qw( core ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
21 31 ▶sub applies_to { return 'PPI::Token::Magic' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
22  
23 15 ▶sub violates {
Subroutine violates: called CC=8 SCAR=38.6
Pod documented
24 15 my ( $self, $elem, undef ) = @_;
25  
26 15 ▶ if ( $elem->content eq q{$_} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->content eq "\$_") 0 15 15
27 # Is there an op following the $_ ?
28 0 my $op_node = $elem->snext_sibling;
29 0 ▶ if ( $op_node && $op_node->isa('PPI::Token::Operator') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op_node and $op_node->isa("PPI::Token::Operator")) 0 0 0
Condition0%0/3
$op_node and $op_node->isa("PPI::Token::Operator")
!ll&&!rl&&r
000
MC/DC0%0/2
$op_node and $op_node->isa("PPI::Token::Operator")
$op_node $op_node->isa("PPI::Token::Operator")
Truth table0%0/3
A and B
A= $op_nodeB= $op_node->isa("PPI::Token::Operator")
ABresult
0X0
100
111
30 # If the op is a regex match, then we have an unnecessary $_ .
31 0 state $is_regex_op = { hashify( qw( =~ !~ ) ) };
32 0 ▶ if ( $is_regex_op->{$op_node->content} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$is_regex_op{$op_node->content}) 0 0 0
33 0 my $target_node = $op_node->snext_sibling;
34 0 ▶ if ( $target_node && ($target_node->isa('PPI::Token::Regexp') || $target_node->isa('PPI::Token::QuoteLike::Regexp')) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target_node and $target_node->isa("PPI::Token::Regexp") || $target_node->isa("PPI::Token::QuoteLike::Regexp")) 0 0 0
Condition0%0/6
$target_node and $target_node->isa("PPI::Token::Regexp") || $target_node->isa("PPI::Token::QuoteLike::Regexp")
!ll&&!rl&&r
000
$target_node->isa("PPI::Token::Regexp") or $target_node->isa("PPI::Token::QuoteLike::Regexp")
l!l&&r!l&&!r
000
MC/DC0%0/3
$target_node and $target_node->isa("PPI::Token::Regexp") || $target_node->isa("PPI::Token::QuoteLike::Regexp")
$target_node $target_node->isa("PPI::Token::Regexp") $target_node->isa("PPI::Token::QuoteLike::Regexp")
Truth table0%0/4
A and B or C
A= $target_nodeB= $target_node->isa("PPI::Token::Regexp")C= $target_node->isa("PPI::Token::QuoteLike::Regexp")
ABCresult
0XX0
1000
11X1
1011
35 0 return $self->violation( $DESC, $EXPL, $elem );
36 }
37 }
38 }
39 }
40  
41 15 return;
42 }
43  
44 40 1;
45  
46 __END__
« lib/Perl/Critic/Policy/References/ProhibitDoubleSigils.pm ↑ Summary lib/Test/Perl/Critic/Policy.pm »