Modified source files and compiled any and armel versions of packages
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / lib / Perl / Critic / Policy / InputOutput / ProhibitOneArgSelect.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/InputOutput/ProhibitOneArgSelect.pm $
3 #     $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
4 #   $Author: clonezone $
5 # $Revision: 2489 $
6 ##############################################################################
7
8 package Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect;
9
10 use 5.006001;
11 use strict;
12 use warnings;
13 use Readonly;
14
15 use Perl::Critic::Utils qw{ :severities :classification :ppi };
16 use base 'Perl::Critic::Policy';
17
18 our $VERSION = '1.088';
19
20 #-----------------------------------------------------------------------------
21
22 Readonly::Scalar my $DESC => q{One-argument "select" used};
23 Readonly::Scalar my $EXPL => [ 224 ];
24
25 #-----------------------------------------------------------------------------
26
27 sub supported_parameters { return ()                  }
28 sub default_severity     { return $SEVERITY_HIGH      }
29 sub default_themes       { return qw( core bugs pbp ) }
30 sub applies_to           { return 'PPI::Token::Word'  }
31
32 #-----------------------------------------------------------------------------
33
34 sub violates {
35     my ($self, $elem, undef) = @_;
36
37     return if $elem ne 'select';
38     return if ! is_function_call($elem);
39
40     if( scalar parse_arg_list($elem) == 1 ) {
41         return $self->violation( $DESC, $EXPL, $elem );
42     }
43     return; #ok!
44 }
45
46 1;
47
48 __END__
49
50 #-----------------------------------------------------------------------------
51
52 =pod
53
54 =head1 NAME
55
56 Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect - Never write C<select($fh)>.
57
58 =head1 AFFILIATION
59
60 This Policy is part of the core L<Perl::Critic> distribution.
61
62
63 =head1 DESCRIPTION
64
65 Conway discourages the use of a raw C<select()> when setting
66 autoflushes.  We'll extend that further by simply prohibiting the
67 one-argument form of C<select()> entirely; if you really need it you
68 should know when/where/why that is.  For performing autoflushes,
69 Conway recommends the use of C<IO::Handle> instead.
70
71   select((select($fh), $|=1)[0]);     # not ok
72   select $fh;                         # not ok
73
74    use IO::Handle;
75    $fh->autoflush();                   # ok
76    *STDOUT->autoflush();               # ok
77
78
79 =head1 CONFIGURATION
80
81 This Policy is not configurable except for the standard options.
82
83
84 =head1 SEE ALSO
85
86 L<IO::Handle>.
87
88 =head1 AUTHOR
89
90 Graham TerMarsch <graham@howlingfrog.com>
91
92 =head1 COPYRIGHT
93
94 Copyright (C) 2005-2007 Graham TerMarsch.  All rights reserved.
95
96 This program is free software; you can redistribute it and/or modify
97 it under the same terms as Perl itself.
98
99 =cut
100
101 # Local Variables:
102 #   mode: cperl
103 #   cperl-indent-level: 4
104 #   fill-column: 78
105 #   indent-tabs-mode: nil
106 #   c-indentation-style: bsd
107 # End:
108 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :