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::BuiltinFunctions::RequireBlockMap - Write "map { /$pattern/ } @list" instead of

Affiliation

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

Author

       Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>

Configuration

       This Policy is not configurable except for the standard options.

Description

       The expression forms of "grep" and "map" are awkward and hard to read.  Use the block forms instead.

           @matches = grep   /pattern/,   @list;        #not ok
           @matches = grep { /pattern/ }  @list;        #ok

           @mapped = map   transform($_),   @list;      #not ok
           @mapped = map { transform($_) }  @list;      #ok

Name

       Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap - Write "map { /$pattern/ } @list" instead of
       "map /$pattern/, @list".

See Also

       Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval

       Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep

See Also