Perl::Critic::Policy::Compatibility::Gtk2Constants - new enough Gtk2 version for its constants


Perl-Critic-Pulp documentation  | view source Contained in the Perl-Critic-Pulp distribution.

Index


NAME

Top

Perl::Critic::Policy::Compatibility::Gtk2Constants - new enough Gtk2 version for its constants

DESCRIPTION

Top

This policy is part of the Perl::Critic::Pulp|Perl::Critic::Pulp addon. It requires that if you use certain constant subs from Gtk2|Gtk2 and Glib|Glib then you must explicitly have a use of a high enough version of those modules.

    use Gtk2 1.160;
    ... return Gtk2::EVENT_PROPAGATE;  # bad

    use Gtk2 1.200 ':constants';
    ... return GDK_CURRENT_TIME;       # good

The following Gtk2 constants are checked,

    GTK_PRIORITY_RESIZE       # new in Gtk2 1.200 (devel 1.190)
    GDK_PRIORITY_EVENTS
    GDK_PRIORITY_REDRAW
    GDK_CURRENT_TIME

    EVENT_PROPAGATE           # new in Gtk2 1.220 (devel 1.210)
    EVENT_STOP

    GTK_PATH_PRIO_LOWEST      # new in Gtk2 1.220 (devel 1.211)
    GTK_PATH_PRIO_GTK
    GTK_PATH_PRIO_APPLICATION
    GTK_PATH_PRIO_THEME
    GTK_PATH_PRIO_RC
    GTK_PATH_PRIO_HIGHEST

and the following Glib constants

    SOURCE_CONTINUE           # new in Glib 1.220 (devel 1.210)
    SOURCE_REMOVE

The idea is to keep you from using the constants without a new enough Gtk2 or Glib. Of course there's a huge number of other things you might do that also require a new enough version, but these constants tripped me up a few times.

The exact version numbers above and demanded are development versions. You're probably best off rounding up to a "stable" one like 1.200 or 1.220.

As always if you don't care about this and in particular if for instance you only ever use Gtk2 1.220 or higher anyway then you can disable Gtk2Constants from your .perlcriticrc in the usual way (see CONFIGURATION in Perl::Critic),

    [-Compatibility::Gtk2Constants]

Constant Forms

Constants are recognised as any of for instance

    EVENT_PROPAGATE
    Gtk2::EVENT_PROPAGATE
    Gtk2->EVENT_PROPAGATE
    &EVENT_PROPAGATE
    &Gtk2::EVENT_PROPAGATE

When there's a class name given it's checked, so that other uses of say EVENT_PROPAGATE aren't picked up.

    Some::Other::Thing::EVENT_PROPAGATE      # ok
    Some::Other::Thing->EVENT_PROPAGATE      # ok
    &Some::Other::Thing::EVENT_PROPAGATE     # ok

When there's no class name, then it's only assumed to be Gtk2 or Glib when the respective module has been included.

    use Something::Else;
    EVENT_PROPAGATE           # ok

    use Gtk2 ':constants';
    EVENT_PROPAGATE           # bad

In the latter form there's no check for :constants or explicit import in the use, it's assumed that if you've used Gtk2 then EVENT_PROPAGATE means that one no matter how the imports might be arranged.

SEE ALSO

Top

Perl::Critic::Pulp, Perl::Critic, Gtk2, Glib

HOME PAGE

Top

http://user42.tuxfamily.org/perl-critic-pulp/index.html

COPYRIGHT

Top


Perl-Critic-Pulp documentation  | view source Contained in the Perl-Critic-Pulp distribution.