lib/Perl/Critic/Policy/Documentation/RequirePodAtEnd.pm

filter: Statementstmt 90.7% 39 / 43 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 80.0% 4 / 5 totaltotal 86.9% 60 / 69 CC 5 SCAR 9.3
CC
5
Cov
84%
violates
6.2
BEGIN
1.0
BEGIN
1.0
CRAP 2.5
« lib/Perl/Critic/Policy/Miscellanea/ProhibitUselessNoCritic.pm ↑ Summary lib/Perl/Critic/Policy/Miscellanea/ProhibitUnrestrictedNoCritic.pm »
1 package Perl::Critic::Policy::Documentation::RequirePodAtEnd;
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 40 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 40 ▶use Perl::Critic::Utils qw{ :severities };
Subroutine BEGIN: called CC=1 SCAR=0.0
11 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 40 our $VERSION = '1.156';
14  
15 #-----------------------------------------------------------------------------
16  
17 40 Readonly::Scalar my $POD_RX => qr{\A = (?: for|begin|end ) }xms;
18 40 Readonly::Scalar my $DESC => q{POD before __END__};
19 40 Readonly::Scalar my $EXPL => [139, 140];
20  
21 #-----------------------------------------------------------------------------
22  
23 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
24 76 ▶sub default_severity { return $SEVERITY_LOWEST }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
25 83 ▶sub default_themes { return qw( core cosmetic pbp ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
26 31 ▶sub applies_to { return 'PPI::Document' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
27  
28 #-----------------------------------------------------------------------------
29  
30 31 ▶sub violates {
Subroutine violates: called CC=5 SCAR=18.2
Pod documented
31 31 my ( $self, undef, $doc ) = @_;
32  
33 # No POD means no violation
34 31 my $pods_ref = $doc->find('PPI::Token::Pod');
35 31 ▶ return if !$pods_ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $pods_ref 29 2 31
36  
37 # Look for first POD tag that isn't =for, =begin, or =end
38 2 ▶ my $pod = first { $_ !~ $POD_RX} @{ $pods_ref };
Subroutine __ANON__: called CC=1 SCAR=0.0
39 2 ▶ return if !$pod;
Branch: 1 branch
BranchTrueFalseTotal
unless $pod 0 2 2
40  
41 2 my $end = $doc->find_first('PPI::Statement::End');
42 2 ▶ if ($end) { # No __END__ means definite violation
Branch: 1 branch
BranchTrueFalseTotal
if ($end) 0 2 2
43 0 my $pod_loc = $pod->location();
44 0 my $end_loc = $end->location();
45 0 ▶ if ( $pod_loc->[0] > $end_loc->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pod_loc->[0] > $end_loc->[0]) 0 0 0
46 # POD is after __END__, or relative position couldn't be determined
47 0 return;
48 }
49 }
50  
51 2 return $self->violation( $DESC, $EXPL, $pod );
52 }
53  
54 40 1;
55  
56 __END__
« lib/Perl/Critic/Policy/Miscellanea/ProhibitUselessNoCritic.pm ↑ Summary lib/Perl/Critic/Policy/Miscellanea/ProhibitUnrestrictedNoCritic.pm »