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) $
6 ##############################################################################
8 package Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect;
15 use Perl::Critic::Utils qw{ :severities :classification :ppi };
16 use base 'Perl::Critic::Policy';
18 our $VERSION = '1.088';
20 #-----------------------------------------------------------------------------
22 Readonly::Scalar my $DESC => q{One-argument "select" used};
23 Readonly::Scalar my $EXPL => [ 224 ];
25 #-----------------------------------------------------------------------------
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' }
32 #-----------------------------------------------------------------------------
35 my ($self, $elem, undef) = @_;
37 return if $elem ne 'select';
38 return if ! is_function_call($elem);
40 if( scalar parse_arg_list($elem) == 1 ) {
41 return $self->violation( $DESC, $EXPL, $elem );
50 #-----------------------------------------------------------------------------
56 Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect - Never write C<select($fh)>.
60 This Policy is part of the core L<Perl::Critic> distribution.
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.
71 select((select($fh), $|=1)[0]); # not ok
75 $fh->autoflush(); # ok
76 *STDOUT->autoflush(); # ok
81 This Policy is not configurable except for the standard options.
90 Graham TerMarsch <graham@howlingfrog.com>
94 Copyright (C) 2005-2007 Graham TerMarsch. All rights reserved.
96 This program is free software; you can redistribute it and/or modify
97 it under the same terms as Perl itself.
103 # cperl-indent-level: 4
105 # indent-tabs-mode: nil
106 # c-indentation-style: bsd
108 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :