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