File Coverage

blib/lib/Perl/Critic/Policy/Documentation/RequirePODUseEncodingUTF8.pm
Criterion Covered Total %
statement 34 35 97.1
branch 4 4 100.0
condition n/a
subroutine 13 14 92.8
pod 4 5 80.0
total 55 58 94.8


line stmt bran cond sub pod time code
1             package Perl::Critic::Policy::Documentation::RequirePODUseEncodingUTF8;
2              
3 2     2   3240 use utf8;
  2         4  
  2         17  
4 2     2   143 use 5.006;
  2         9  
  2         78  
5 2     2   12 use strict;
  2         4  
  2         73  
6 2     2   10 use warnings;
  2         4  
  2         319  
7              
8 2     2   15 use version; our $VERSION = qv('v1.0.3');
  2         6  
  2         19  
9              
10 2     2   436 use List::MoreUtils qw{ any };
  2         3  
  2         252  
11              
12 2     2   14 use Perl::Critic::Utils qw{ :severities };
  2         4  
  2         187  
13 2     2   390 use base 'Perl::Critic::Policy';
  2         3  
  2         940  
14              
15             my $ENCODING_REGEX = qr/ ^ =encoding \s+ utf8 /xms;
16             my $DESCRIPTION = 'POD does not include "=encoding utf8" declaration';
17             ## no critic (ValuesAndExpressions::RestrictLongStrings)
18             my $EXPLANATION =
19             'Need to ensure that POD processors understand that the documentation may contain Unicode';
20             ## use critic
21              
22 5     5 0 42033 sub supported_parameters { return (); }
23 2     2 1 52 sub default_severity { return $SEVERITY_MEDIUM; }
24 0     0 1 0 sub default_themes { return qw( swift unicode ); }
25 5     5 1 62438 sub applies_to { return 'PPI::Document'; }
26              
27             sub violates {
28 5     5 1 65 my ( $self, undef, $document ) = @_;
29              
30 5         20 my $pod_sections_ref = $document->find('PPI::Token::Pod');
31 5 100       923 return if not $pod_sections_ref;
32              
33 4 100   4   25 return if any { m/$ENCODING_REGEX/xms } @{ $pod_sections_ref };
  4         34  
  4         20  
34              
35 2         396 return $self->violation( $DESCRIPTION, $EXPLANATION, $document );
36             } # end violates()
37              
38             1;
39              
40             __END__
41              
42             =pod
43              
44             =encoding utf8
45              
46             =head1 NAME
47              
48             Perl::Critic::Policy::Documentation::RequirePODUseEncodingUTF8 - Require that all modules that contain POD have a C<=encoding utf8> declaration.
49              
50             =head1 AFFILIATION
51              
52             This policy is part of L<Perl::Critic::Swift>.
53              
54              
55             =head1 VERSION
56              
57             This document describes
58             Perl::Critic::Policy::Documentation::RequirePODUseEncodingUTF8 version 1.0.3.
59              
60              
61             =head1 SYNOPSIS
62              
63             Require that all modules that contain POD have a C<=encoding utf8>
64             declaration.
65              
66              
67             =head1 DESCRIPTION
68              
69             POD parsers need to be told if they are going to be dealing with anything that
70             isn't ASCII. This policy ensures that they are notified that the
71             documentation may contain Unicode characters.
72              
73             English speakers need to be brought into the 21st century and note that not
74             every character fits into 7 bits.
75              
76              
77             =head1 INTERFACE
78              
79             Standard for a L<Perl::Critic::Policy>.
80              
81              
82             =head1 DIAGNOSTICS
83              
84             None.
85              
86              
87             =head1 CONFIGURATION AND ENVIRONMENT
88              
89             This policy has no configuration options beyond the standard ones.
90              
91              
92             =head1 DEPENDENCIES
93              
94             L<Perl::Critic>
95              
96              
97             =head1 INCOMPATIBILITIES
98              
99             None reported.
100              
101              
102             =head1 BUGS AND LIMITATIONS
103              
104             No bugs have been reported.
105              
106             Please report any bugs or feature requests to
107             C<bug-perl-critic-swift@rt.cpan.org>, or through the web interface at
108             L<http://rt.cpan.org>.
109              
110              
111             =head1 AUTHOR
112              
113             Elliot Shank C<< <perl@galumph.com> >>
114              
115              
116             =head1 LICENSE AND COPYRIGHT
117              
118             Copyright ©2007-2008, Elliot Shank C<< <perl@galumph.com> >>. All rights
119             reserved.
120              
121             This module is free software; you can redistribute it and/or modify it under
122             the same terms as Perl itself. See L<perlartistic>.
123              
124              
125             =head1 DISCLAIMER OF WARRANTY
126              
127             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE
128             SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
129             STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
130             SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
131             INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
132             FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
133             PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE,
134             YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
135              
136             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
137             COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
138             SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES,
139             INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
140             OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO
141             LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR
142             THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER
143             SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
144             POSSIBILITY OF SUCH DAMAGES.
145              
146              
147             =cut
148              
149             # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab :
150             # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent :
151             # setup vim: set foldmethod=indent foldlevel=0 :