Perl::...yscalls(3pm)
Okay bestie, welcome to Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls(3pm) β aka Perl::...yscalls(3pm) if your terminal is being extra β straight outta User Contributed Perl Documentation β¨ Buckle up, we're checking return values π
πΈ NAME πΈ
Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls β Return value of flagged function ignored. Yep, that's the whole crime: the return value got ignored π
π«Ά AFFILIATION π«Ά
This Policy is part of the core Perl::Critic distribution. She's core, she's iconic, she belongs here π
β¨ DESCRIPTION β¨
Okay so this policy performs identically to InputOutput::RequireCheckedOpen/Close, except the big glow-up is that it's configurable to apply to any function, whether core or user-defined. Any function, bestie. The audacity, the range π
If your module uses Fatal, Fatal::Exception, or autodie, 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
use autodie;
open $filehandle, $mode, $filename; # no violation
Currently, autodie is not properly treated as a pragma; its lexical effects aren't taken into account. So yeah, that's a known little gremlin π
π CONFIGURATION π
This policy watches for a configurable list of function names. By default, it applies to "open", "print", "say" and "close". You can override this to set it to a different list of functions with the "functions" and "exclude_functions" settings. 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). Like, she went digging for those, no cap π§
You can require checking all builtins except "print" by combining the "functions" and "exclude_functions":
[InputOutput::RequireCheckedSyscalls]
functions = :builtins
exclude_functions = print
This is a lot easier to read than the alternative. Highkey true.
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.
If you create a module that exports "autodie" you can tell this policy about it with the "autodie_modules" setting:
[InputOutput::RequireCheckedSyscalls]
autodie_modules = My::Thing
π CREDITS π
Initial development of this policy was supported by a grant from the Perl Foundation. Slay, Perl Foundation π«Ά
This policy module is based heavily on policies written by Andrew Moore <amoore@mooresystems.com>.
π AUTHOR π
Chris Dolan <cdolan@cpan.org>
π COPYRIGHT π
Copyright (c) 2007-2011 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.
That's the whole page, bestie π Signing off from perl v5.42.0, dated 2024-10-23 β go check those return values, periodt! π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Perl-Critic 1.156.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms