NAME
Perl::Critic::Policy::References::ProhibitRefChecks - Write is_arrayref($var) instead of ref($var) eq 'ARRAY'.
DESCRIPTION
Checking references manually is less efficient that using Ref::Util and prone to typos.
if(ref($var) eq 'ARRYA') # oops!
if(is_arrayref($var))    # ok
if(ref($var) ne 'HASH')  # no
if(!is_hashref($var))    # ok
if(ref($var))            # no
if(is_ref($var))         # ok
CONFIGURATION
Explicit strings may be permitted for checks of the form ref(...) eq 'string', or ref(...) ne 'string'. Entries are case insensitive and can be the core types or custom modules.
[References::ProhibitRefChecks]
eq = code
ne = code my::module
As a special scenario, checks of the form ref(...) eq ref(...) can be permitted with eq = ref. The same works for ne = ref.
Regular expression matches are violations by default. To permit checks of the form ref(...) =~ /pattern/ or !~:
[References::ProhibitRefChecks]
regexp = 1
Since Ref::Util provides is_ref, in the default configuration the bare ref call is rarely needed. To specifically permit using direct ref(...) calls:
[References::ProhibitRefChecks]
bareref = 1
NOTES
Comparisons to stored values or constants are not supported: ref(...) eq $thing and ref(...) eq HASH() are violations.
Lexicographic comparison via ref(...) cmp "string" is a violation.
In/equality checks are not bidirectional: 'HASH' eq ref(...) will not be considered a violation.
BUGS
Named unary functions are not separately considered. A call of lc(ref $x) eq "array" is considered a "bare ref check", whereas lc ref($x) eq "array" is considered an "eq ref check".