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 / RequireCheckedClose.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/InputOutput/RequireCheckedClose.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::RequireCheckedClose;
9
10 use 5.006001;
11 use strict;
12 use warnings;
13 use Readonly;
14
15 use Perl::Critic::Utils qw{ :severities :classification };
16 use base 'Perl::Critic::Policy';
17
18 our $VERSION = '1.088';
19
20 #-----------------------------------------------------------------------------
21
22 Readonly::Scalar my $DESC => q{Return value of "close" ignored};
23 Readonly::Scalar my $EXPL => q{Check the return value of "close" for success};
24
25 #-----------------------------------------------------------------------------
26
27 sub supported_parameters { return ()                     }
28 sub default_severity     { return $SEVERITY_LOW          }
29 sub default_themes       { return qw( core maintenance ) }
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 'close';
38     return if ! is_unchecked_call( $elem );
39
40     return $self->violation( $DESC, $EXPL, $elem );
41
42 }
43
44
45 1;
46
47 __END__
48
49 #-----------------------------------------------------------------------------
50
51 =pod
52
53 =head1 NAME
54
55 Perl::Critic::Policy::InputOutput::RequireCheckedClose - Write C<< my $error = close $fh; >> instead of C<< close $fh; >>.
56
57 =head1 AFFILIATION
58
59 This Policy is part of the core L<Perl::Critic> distribution.
60
61
62 =head1 DESCRIPTION
63
64 The perl builtin I/O function C<close> returns a false value on failure. That
65 value should be checked to ensure that the close was successful.
66
67
68   my $error = close $filehandle;                   # ok
69   close $filehandle or die "unable to close: $!";  # ok
70   close $filehandle;                               # not ok
71
72
73 =head1 CONFIGURATION
74
75 This Policy is not configurable except for the standard options.
76
77
78 =head1 AUTHOR
79
80 Andrew Moore <amoore@mooresystems.com>
81
82 =head1 ACKNOWLEDGMENTS
83
84 This policy module is based heavily on policies written by Jeffrey Ryan
85 Thalhammer <thaljef@cpan.org>.
86
87 =head1 COPYRIGHT
88
89 Copyright (c) 2007-2008 Andrew Moore.  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.  The full text of this license
93 can be found in the LICENSE file included with this module.
94
95 =cut
96
97 ##############################################################################
98 # Local Variables:
99 #   mode: cperl
100 #   cperl-indent-level: 4
101 #   fill-column: 78
102 #   indent-tabs-mode: nil
103 #   c-indentation-style: bsd
104 # End:
105 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :