line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect; |
2
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
25980
|
use 5.010001; |
|
40
|
|
|
|
|
181
|
|
4
|
40
|
|
|
40
|
|
261
|
use strict; |
|
40
|
|
|
|
|
118
|
|
|
40
|
|
|
|
|
830
|
|
5
|
40
|
|
|
40
|
|
209
|
use warnings; |
|
40
|
|
|
|
|
109
|
|
|
40
|
|
|
|
|
1033
|
|
6
|
40
|
|
|
40
|
|
225
|
use Readonly; |
|
40
|
|
|
|
|
154
|
|
|
40
|
|
|
|
|
2141
|
|
7
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
294
|
use Perl::Critic::Utils qw{ :severities :classification :ppi }; |
|
40
|
|
|
|
|
121
|
|
|
40
|
|
|
|
|
2118
|
|
9
|
40
|
|
|
40
|
|
15470
|
use parent 'Perl::Critic::Policy'; |
|
40
|
|
|
|
|
113
|
|
|
40
|
|
|
|
|
251
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.150'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{One-argument "select" used}; |
16
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => [ 224 ]; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
|
20
|
89
|
|
|
89
|
0
|
1577
|
sub supported_parameters { return () } |
21
|
74
|
|
|
74
|
1
|
288
|
sub default_severity { return $SEVERITY_HIGH } |
22
|
92
|
|
|
92
|
1
|
389
|
sub default_themes { return qw( core bugs pbp certrule ) } |
23
|
32
|
|
|
32
|
1
|
108
|
sub applies_to { return 'PPI::Token::Word' } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub violates { |
28
|
346
|
|
|
346
|
1
|
586
|
my ($self, $elem, undef) = @_; |
29
|
|
|
|
|
|
|
|
30
|
346
|
50
|
|
|
|
561
|
return if $elem->content() ne 'select'; |
31
|
0
|
0
|
|
|
|
|
return if ! is_function_call($elem); |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my @arguments = parse_arg_list($elem); |
34
|
0
|
0
|
|
|
|
|
if( 1 == @arguments ) { |
35
|
0
|
|
|
|
|
|
return $self->violation( $DESC, $EXPL, $elem ); |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
return; #ok! |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect - Never write C<select($fh)>. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 AFFILIATION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This Policy is part of the core L<Perl::Critic|Perl::Critic> |
55
|
|
|
|
|
|
|
distribution. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Conway discourages the use of a raw C<select()> when setting |
61
|
|
|
|
|
|
|
autoflushes. We'll extend that further by simply prohibiting the |
62
|
|
|
|
|
|
|
one-argument form of C<select()> entirely; if you really need it you |
63
|
|
|
|
|
|
|
should know when/where/why that is. For performing autoflushes, |
64
|
|
|
|
|
|
|
Conway recommends the use of C<IO::Handle> instead. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
select((select($fh), $|=1)[0]); # not ok |
67
|
|
|
|
|
|
|
select $fh; # not ok |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use IO::Handle; |
70
|
|
|
|
|
|
|
$fh->autoflush(); # ok |
71
|
|
|
|
|
|
|
*STDOUT->autoflush(); # ok |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 CONFIGURATION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This Policy is not configurable except for the standard options. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 SEE ALSO |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
L<IO::Handle|IO::Handle>. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Graham TerMarsch <graham@howlingfrog.com> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 COPYRIGHT |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Copyright (c) 2005-2011 Graham TerMarsch. All rights reserved. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
92
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Local Variables: |
97
|
|
|
|
|
|
|
# mode: cperl |
98
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
99
|
|
|
|
|
|
|
# fill-column: 78 |
100
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
101
|
|
|
|
|
|
|
# c-indentation-style: bsd |
102
|
|
|
|
|
|
|
# End: |
103
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |