lib/Perl/Critic/Policy/Miscellanea/ProhibitUselessNoCritic.pm

filter: Statementstmt 82.9% 34 / 41 Branchbran 25.0% 1 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 12 / 14 Podpod 80.0% 4 / 5 totaltotal 73.9% 51 / 69 CC 5 SCAR 9.7
CC
5
Cov
73%
_annotation_suppresses_violation
6.0
violates
5.6
__ANON__
2.0
CRAP 2.6
« 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
BranchTrueFalseTotal
unless $doc->isa("Perl::Critic::Document") 0 2 2
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
BranchTrueFalseTotal
if (&none(sub { _annotation_suppresses_violation($ann, $_); } , @suppressed_viols)) 0 0 0
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)
!ll&&!rl&&r
000
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)
ABresult
0X0
100
111
57 && $annotation->disables_policy($policy_name);
58 }
59  
60 #-----------------------------------------------------------------------------
61  
62 40 1;
63  
64 __END__
« lib/Perl/Critic/Policy/Variables/RequireInitializationForLocalVars.pm ↑ Summary lib/Perl/Critic/Policy/Documentation/RequirePodAtEnd.pm »