logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Perl::Critic::Policy::Community::ArrayAssignAref - Don't assign an anonymous arrayref to an array

Affiliation

       This policy is part of Perl::Critic::Community.

Author

       Dan Book, "dbook@cpan.org"

Configuration

       This policy is not configurable except for the standard options.

Description

       A common mistake is to assign values to an array but use arrayref brackets "[]" rather than parentheses
       "()". This results in the array containing one element, an arrayref, which is usually unintended. If
       intended, the arrayref brackets can be wrapped in parentheses for clarity.

        @array = [];          # not ok
        @array = [1, 2, 3];   # not ok
        @array = ([1, 2, 3]); # ok

       This policy is a subclass of Perl::Critic::Policy::Plicease::ProhibitArrayAssignAref, which is a fork of
       the Perl::Critic::Pulp policy Perl::Critic::Policy::ValuesAndExpressions::ProhibitArrayAssignAref, and
       performs the same function but in the "community" theme.

Name

       Perl::Critic::Policy::Community::ArrayAssignAref - Don't assign an anonymous arrayref to an array

See Also

       Perl::Critic, Perl::Critic::Pulp

perl v5.40.1                                       2025-03-22             Perl::Critic::P...ArrayAssignAref(3pm)

See Also