« 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$op_node and $op_node->isa("PPI::Token::Operator")
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")
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/6
$target_node and $target_node->isa("PPI::Token::Regexp") || $target_node->isa("PPI::Token::QuoteLike::Regexp")
$target_node->isa("PPI::Token::Regexp") or $target_node->isa("PPI::Token::QuoteLike::Regexp")
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")
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | return $self->violation( $DESC, $EXPL, $elem ); | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 15 | return; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 40 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||||||||||||||||||||||