line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
####################################################################### |
2
|
|
|
|
|
|
|
# $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/Perl-Critic-More/lib/Perl/Critic/Policy/CodeLayout/RequireASCII.pm $ |
3
|
|
|
|
|
|
|
# $Date: 2013-10-29 09:39:11 -0700 (Tue, 29 Oct 2013) $ |
4
|
|
|
|
|
|
|
# $Author: thaljef $ |
5
|
|
|
|
|
|
|
# $Revision: 4222 $ |
6
|
|
|
|
|
|
|
######################################################################## |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Perl::Critic::Policy::CodeLayout::RequireASCII; |
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
2383779
|
use 5.006001; |
|
6
|
|
|
|
|
25
|
|
|
6
|
|
|
|
|
228
|
|
11
|
|
|
|
|
|
|
|
12
|
6
|
|
|
6
|
|
30
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
173
|
|
13
|
6
|
|
|
6
|
|
36
|
use warnings; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
166
|
|
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
34
|
use Readonly; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
378
|
|
16
|
|
|
|
|
|
|
|
17
|
6
|
|
|
6
|
|
39
|
use List::MoreUtils qw(none any); |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
414
|
|
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
6
|
|
33
|
use Perl::Critic::Utils qw{ :severities }; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
476
|
|
20
|
6
|
|
|
6
|
|
1047
|
use base 'Perl::Critic::Policy'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
6949
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '1.003'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Readonly::Scalar my $MAX_ASCII_VALUE => 127; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => 'Use only ASCII code'; |
29
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => 'Put any non-ASCII in separate files'; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
4
|
1
|
2278
|
sub default_severity { return $SEVERITY_LOWEST } |
34
|
1
|
|
|
1
|
1
|
107
|
sub default_themes { return qw< more notrecommended > } |
35
|
5
|
|
|
5
|
1
|
36792
|
sub applies_to { return 'PPI::Token' } |
36
|
6
|
|
|
6
|
0
|
3107859
|
sub supported_parameters { return () } |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub violates { |
41
|
39
|
|
|
39
|
1
|
1187
|
my ( $self, $elem, $doc ) = @_; |
42
|
|
|
|
|
|
|
|
43
|
39
|
100
|
|
176
|
|
171
|
if ( any { $_ > $MAX_ASCII_VALUE } unpack 'C*', "$elem" ) { |
|
176
|
|
|
|
|
401
|
|
44
|
1
|
|
|
|
|
14
|
return $self->violation( $DESC, $EXPL, $elem ); |
45
|
|
|
|
|
|
|
} |
46
|
38
|
100
|
|
|
|
248
|
if ( $elem->isa('PPI::Token::HereDoc') ) { |
47
|
3
|
|
|
|
|
12
|
for my $line ( $elem->heredoc ) { |
48
|
9
|
100
|
|
122
|
|
74
|
if ( any { $_ > $MAX_ASCII_VALUE } unpack 'C*', $line ) { |
|
122
|
|
|
|
|
149
|
|
49
|
2
|
|
|
|
|
11
|
return $self->violation( $DESC, $EXPL, $elem ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
36
|
|
|
|
|
95
|
return; #ok |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=for stopwords EBCDIC |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Perl::Critic::Policy::CodeLayout::RequireASCII - Disallow high-bit characters. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AFFILIATION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This policy is part of L<Perl::Critic::More|Perl::Critic::More>, a bleeding |
74
|
|
|
|
|
|
|
edge supplement to L<Perl::Critic|Perl::Critic>. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
ASCII is a text encoding first introduced in 1963. It represents 128 |
79
|
|
|
|
|
|
|
characters in seven-bit bytes, reserving the eighth bit for error detection. |
80
|
|
|
|
|
|
|
Perl supports a large number of encodings. However, if you really want the |
81
|
|
|
|
|
|
|
ultimate in backward compatibility, ASCII is it! (We won't even talk about |
82
|
|
|
|
|
|
|
EBCDIC and the like...) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This policy is B<not> recommended for everyone. Instead, |
85
|
|
|
|
|
|
|
most of you should probably strive for one of the Unicode encodings for |
86
|
|
|
|
|
|
|
maximum forward compatibility. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SEE ALSO |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
L<http://en.wikipedia.org/wiki/Ascii> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L<http://en.wikipedia.org/wiki/EBCDIC> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L<http://en.wikipedia.org/wiki/Unicode> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Chris Dolan <cdolan@cpan.org> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright (c) 2006-2008 Chris Dolan |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
105
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
106
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Local Variables: |
111
|
|
|
|
|
|
|
# mode: cperl |
112
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
113
|
|
|
|
|
|
|
# fill-column: 78 |
114
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
115
|
|
|
|
|
|
|
# c-indentation-style: bsd |
116
|
|
|
|
|
|
|
# End: |
117
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |