| 1 | package Perl::Critic::Policy::Bangs::ProhibitCommentedOutCode; | ||||||||||
| 2 | |||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 5 | ▶ | use Perl::Critic::Utils; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 5 | ▶ | use base 'Perl::Critic::Policy'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 5 | our $VERSION = '1.14'; | |||||||||
| 9 | |||||||||||
| 10 | #--------------------------------------------------------------------------- | ||||||||||
| 11 | |||||||||||
| 12 | 10 | ▶ | sub supported_parameters { | ||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 13 | return ( | ||||||||||
| 14 | { | ||||||||||
| 15 | 10 | name => 'commentedcoderegex', | |||||||||
| 16 | description => 'Regular expression to use to look for code in comments.', | ||||||||||
| 17 | behavior => 'string', | ||||||||||
| 18 | default_string => '\$[A-Za-z_].*=', ## no critic (RequireInterpolationOfMetachars) | ||||||||||
| 19 | }, | ||||||||||
| 20 | ); | ||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 5 | ▶ | sub default_severity { return $SEVERITY_LOW } | ||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 24 | 0 | ▶ | sub default_themes { return qw( bangs maintenance ) } | ||||||||
|
Subroutine
default_themes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 25 | 6 | ▶ | sub applies_to { return 'PPI::Token::Comment' } | ||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 26 | |||||||||||
| 27 | #--------------------------------------------------------------------------- | ||||||||||
| 28 | |||||||||||
| 29 | 17 | ▶ | sub violates { | ||||||||
|
Subroutine
violates: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 17 | my ( $self, $elem, $doc ) = @_; | |||||||||
| 31 | |||||||||||
| 32 | 17 | ▶ | if ( $elem =~ $self->{_commentedcoderegex} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 5 | my $desc = q(Code found in comment); | |||||||||
| 34 | 5 | my $expl = q(Commented-out code found can be confusing); | |||||||||
| 35 | 5 | return $self->violation( $desc, $expl, $elem ); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 12 | return; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 5 | 1; | |||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||