File Coverage

blib/lib/Perl/Critic/Policy/Documentation/RequirePod.pm
Criterion Covered Total %
statement 26 27 96.3
branch 3 4 75.0
condition n/a
subroutine 10 11 90.9
pod 4 5 80.0
total 43 47 91.4


line stmt bran cond sub pod time code
1             package Perl::Critic::Policy::Documentation::RequirePod;
2             # ABSTRACT: file requires POD
3             $Perl::Critic::Policy::Documentation::RequirePod::VERSION = '0.005';
4 1     1   129700 use utf8;
  1         8  
  1         5  
5 1     1   22 use strict;
  1         2  
  1         14  
6 1     1   2 use warnings;
  1         1  
  1         17  
7              
8 1     1   3 use Readonly;
  1         0  
  1         39  
9              
10 1     1   3 use Perl::Critic::Utils qw{ :severities };
  1         1  
  1         47  
11 1     1   86 use parent qw(Perl::Critic::Policy);
  1         1  
  1         6  
12              
13             Readonly::Scalar my $DESC => q{file requires POD};
14             Readonly::Scalar my $EXPL =>
15             q{Missing POD in the current file};
16              
17             #-----------------------------------------------------------------------------
18              
19 4     4 0 25200 sub supported_parameters { return () }
20 1     1 1 18 sub default_severity { return $SEVERITY_LOW }
21 0     0 1 0 sub default_themes { return qw(core pbp maintenance) }
22 4     4 1 20417 sub applies_to { return qw(PPI::Document) }
23              
24             #-----------------------------------------------------------------------------
25              
26             sub violates {
27 4     4 1 53 my ( $self, $elem, $doc ) = @_;
28              
29             # This policy does not apply unless there is some real code in the
30             # file. For example, if this file is just pure POD, then
31             # presumably this file is ancillary documentation and you can use
32             # whatever headings you want.
33 4 50       35 return if ! $doc->schild(0);
34              
35 4         147 my $pods_ref = $doc->find('PPI::Token::Pod');
36              
37 4 100       67 return if $pods_ref;
38              
39 1         15 return $self->violation( $DESC, $EXPL, $elem );
40              
41             }
42              
43             1;
44              
45             __END__
46              
47             =pod
48              
49             =encoding UTF-8
50              
51             =head1 NAME
52              
53             Perl::Critic::Policy::Documentation::RequirePod - file requires POD
54              
55             =head1 VERSION
56              
57             version 0.005
58              
59             =head1 DESCRIPTION
60              
61             This policy requires your code to contain POD.
62              
63             =head1 AUTHOR
64              
65             Andreas Schröter <andreas.schroeter@autinity.de>
66              
67             =head1 COPYRIGHT AND LICENSE
68              
69             This software is copyright (c) 2016 by afr-consulting GmbH.
70              
71             This is free software; you can redistribute it and/or modify it under
72             the same terms as the Perl 5 programming language system itself.
73              
74             =cut