« lib/Perl/Critic/Policy/Variables/RequireInitializationForLocalVars.pm
↑ Summary
lib/Perl/Critic/Policy/Documentation/RequirePodAtEnd.pm »
| 1 | package Perl::Critic::Policy::Miscellanea::ProhibitUselessNoCritic; | ||||||||||||||||||||
| 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 | |||||||||||||||||||||
| 7 | 40 | ▶ | use Readonly; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 40 | ▶ | use List::SomeUtils qw( none ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 40 | ▶ | use Perl::Critic::Utils qw{ :severities :classification }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 40 | ▶ | use parent 'Perl::Critic::Policy'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 40 | our $VERSION = '1.156'; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | #----------------------------------------------------------------------------- | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 40 | Readonly::Scalar my $DESC => q{Useless '## no critic' annotation}; | |||||||||||||||||||
| 19 | 40 | Readonly::Scalar my $EXPL => q{This annotation can be removed}; | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | #----------------------------------------------------------------------------- | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 90 | ▶ | sub supported_parameters { return () } | ||||||||||||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 24 | 74 | ▶ | sub default_severity { return $SEVERITY_LOW } | ||||||||||||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 25 | 73 | ▶ | sub default_themes { return qw(core maintenance) } | ||||||||||||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 26 | 2 | ▶ | sub applies_to { return 'PPI::Document' } | ||||||||||||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | #----------------------------------------------------------------------------- | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 2 | ▶ | sub violates { | ||||||||||||||||||
|
Subroutine
violates: called CC=4 SCAR=17.2
Pod
documented
| |||||||||||||||||||||
| 31 | 2 | my ( $self, undef, $doc ) = @_; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | # If for some reason $doc is not a P::C::Document, then all bets are off | ||||||||||||||||||||
| 34 | 2 | ▶ | return if not $doc->isa('Perl::Critic::Document'); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 2 | my @violations; | |||||||||||||||||||
| 37 | 2 | my @suppressed_viols = $doc->suppressed_violations(); | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 2 | for my $ann ( $doc->annotations() ) { | |||||||||||||||||||
| 40 | 0 | ▶ | if ( none { _annotation_suppresses_violation($ann, $_) } @suppressed_viols ) { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||
| 41 | 0 | push @violations, $self->violation($DESC, $EXPL, $ann->element()); | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 2 | return @violations; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | #----------------------------------------------------------------------------- | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | ▶ | sub _annotation_suppresses_violation { | ||||||||||||||||||
|
Subroutine
_annotation_suppresses_violation: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 51 | 0 | my ($annotation, $violation) = @_; | |||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | my $policy_name = $violation->policy(); | |||||||||||||||||||
| 54 | 0 | my $line = $violation->location()->[0]; | |||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | ▶ | return $annotation->disables_line($line) | ||||||||||||||||||
|
Condition0%0/3
$annotation->disables_line($line) && $annotation->disables_policy($policy_name)
MC/DC0%0/2
$annotation->disables_line($line) && $annotation->disables_policy($policy_name)
$annotation->disables_line($line)
$annotation->disables_policy($policy_name)
Truth table0%0/3
A && B
A= $annotation->disables_line($line)B= $annotation->disables_policy($policy_name)
| |||||||||||||||||||||
| 57 | && $annotation->disables_policy($policy_name); | ||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | #----------------------------------------------------------------------------- | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 40 | 1; | |||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||