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::Pulp::Utils - shared helper code for the Pulp perlcritic add-on

Description

       This is a bit of a grab bag, but works as far as it goes.

Exports

       Nothing is exported by default, but the functions can be requested in usual "Exporter" style,

           use Perl::Critic::Pulp::Utils 'elem_in_BEGIN';
           if (elem_in_BEGIN($elem)) {
             # ...
           }

       There's  no ":all" tag since this module is meant as a grab-bag of functions and importing as-yet unknown
       things would be asking for name clashes.

Functions

ElementFunctions
       "$pkgelem = Perl::Critic::Pulp::Utils::elem_package ($elem)"
           $elem  is  a  "PPI::Element".   Return  the "PPI::Statement::Package" containing $elem, or "undef" if
           $elem is not in the scope of any package statement.

           The  search  upwards  begins  with  the  element  preceding  $elem,  so  if   $elem   itself   is   a
           "PPI::Statement::Package" then that's not the one returned, instead its containing package.

       "$bool = Perl::Critic::Pulp::Utils::elem_in_BEGIN ($elem)"
           Return  true if $elem (a "PPI::Element") is within a "BEGIN" block (ie. a "PPI::Statement::Scheduled"
           of type "BEGIN").

       "$bool = Perl::Critic::Pulp::Utils::elem_is_comma_operator ($elem)"
           Return true if $elem (a "PPI::Element") is a comma operator ("PPI::Token::Operator"), either  ","  or
           "=>'.

   PolicyParameterFunctions
       "Perl::Critic::Pulp::Utils::parameter_parse_version ($self, $parameter, $str)"
           This  is  designed  for  use  as  the "parser" field of a policy's "supported_parameters" entry for a
           parameter which is a version number.

               { name        => 'above_version',
                 description => 'Check only above this version of Perl.',
                 behavior    => 'string',
                 parser      => \&Perl::Critic::Pulp::Utils::parameter_parse_version,
               }

           $str  is  parsed  with  the  "version.pm"  module.   If  valid  then  the  parameter  is   set   with
           "$self->__set_parameter_value"   to   the   resulting   "version"   object   (so  for  example  field
           $self->{'_above_version'}).     If    invalid     then     an     exception     is     thrown     per
           "$self->throw_parameter_value_exception".

Home Page

Name

       Perl::Critic::Pulp::Utils - shared helper code for the Pulp perlcritic add-on

See Also

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

Synopsis

        use Perl::Critic::Pulp::Utils;

See Also