1Perl::Critic::Pulp::UtiUlsse(r3)Contributed Perl DocumenPteartli:o:nCritic::Pulp::Utils(3)
2
3
4

NAME

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

SYNOPSIS

10        use Perl::Critic::Pulp::Utils;
11

DESCRIPTION

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

FUNCTIONS

16   Element Functions
17       "$pkgelem = Perl::Critic::Pulp::Utils::elem_package ($elem)"
18           $elem is a "PPI::Element".  Return the "PPI::Statement::Package"
19           containing $elem, or "undef" if $elem is not in the scope of any
20           package statement.
21
22           The search upwards begins with the element preceding $elem, so if
23           $elem itself is a "PPI::Statement::Package" then that's not the one
24           returned, instead its containing package.
25
26       "$bool = Perl::Critic::Pulp::Utils::elem_in_BEGIN ($elem)"
27           Return true if $elem (a "PPI::Element") is within a "BEGIN" block
28           (ie. a "PPI::Statement::Scheduled" of type "BEGIN").
29
30       "$bool = Perl::Critic::Pulp::Utils::elem_is_comma_operator ($elem)"
31           Return true if $elem (a "PPI::Element") is a comma operator
32           ("PPI::Token::Operator"), either "," or "=>'.
33
34   Policy Parameter Functions
35       "Perl::Critic::Pulp::Utils::parameter_parse_version ($self, $parameter,
36       $str)"
37           This is designed for use as the "parser" field of a policy's
38           "supported_parameters" entry for a parameter which is a version
39           number.
40
41               { name        => 'above_version',
42                 description => 'Check only above this version of Perl.',
43                 behavior    => 'string',
44                 parser      => \&Perl::Critic::Pulp::Utils::parameter_parse_version,
45               }
46
47           $str is parsed with the "version.pm" module.  If valid then the
48           parameter is set with "$self->__set_parameter_value" to the
49           resulting "version" object (so for example field
50           $self->{'_above_version'}).  If invalid then an exception is thrown
51           per "$self->throw_parameter_value_exception".
52

EXPORTS

54       Nothing is exported by default, but the functions can be requested in
55       usual "Exporter" style,
56
57           use Perl::Critic::Pulp::Utils 'elem_in_BEGIN';
58           if (elem_in_BEGIN($elem)) {
59             # ...
60           }
61
62       There's no ":all" tag since this module is meant as a grab-bag of
63       functions and importing as-yet unknown things would be asking for name
64       clashes.
65

SEE ALSO

67       Perl::Critic::Pulp, Perl::Critic, PPI
68

HOME PAGE

70       <http://user42.tuxfamily.org/perl-critic-pulp/index.html>
71
73       Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
74       Kevin Ryde
75
76       Perl-Critic-Pulp is free software; you can redistribute it and/or
77       modify it under the terms of the GNU General Public License as
78       published by the Free Software Foundation; either version 3, or (at
79       your option) any later version.
80
81       Perl-Critic-Pulp is distributed in the hope that it will be useful, but
82       WITHOUT ANY WARRANTY; without even the implied warranty of
83       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
84       General Public License for more details.
85
86       You should have received a copy of the GNU General Public License along
87       with Perl-Critic-Pulp.  If not, see <http://www.gnu.org/licenses/>.
88
89
90
91perl v5.30.1                      2020-01-30      Perl::Critic::Pulp::Utils(3)
Impressum