Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls.3pm

Langue: en

Version: 2009-02-26 (fedora - 05/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls - Return value of flagged function ignored.

AFFILIATION

This Policy is part of the core Perl::Critic distribution.

DESCRIPTION

This performs identically to InputOutput::RequireCheckedOpen/Close except that this is configurable to apply to any function, whether core or user-defined.

If your module uses Fatal or "Fatal::Exception", then any functions wrapped by those modules will not trigger this policy. For example:

    use Fatal qw(open);
    open my $fh, $filename;  # no violation
    close $fh;               # yes violation
 
 

CONFIGURATION

This policy watches for a configurable list of function names. By default, it applies to "open", "print" and "close". You can override this to set it to a different list of functions with the "functions" setting. To do this, put entries in a .perlcriticrc file like this:
   [InputOutput::RequireCheckedSyscalls]
   functions = open opendir read readline readdir close closedir
 
 

We have defined a few shortcuts for creating this list

   [InputOutput::RequireCheckedSyscalls]
   functions = :defaults opendir readdir closedir
 
   [InputOutput::RequireCheckedSyscalls]
   functions = :builtins
 
   [InputOutput::RequireCheckedSyscalls]
   functions = :all
 
 

The ":builtins" shortcut above represents all of the builtin functions that have error conditions (about 65 of them, many of them rather obscure).

The ":all" is the insane case: you must check the return value of EVERY function call, even "return" and "exit". Yes, this ``feature'' is overkill and is wasting CPU cycles on your computer by just existing. Nyah nyah. I shouldn't code after midnight.

CREDITS

Initial development of this policy was supported by a grant from the Perl Foundation.

This policy module is based heavily on policies written by Andrew Moore <amoore@mooresystems.com>.

AUTHOR

Chris Dolan <cdolan@cpan.org> Copyright (c) 2007-2008 Chris Dolan. Many rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.