Perl::Critic::Policy::Compatibility::Gtk2Constants - new enough Gtk2 version for its constants
This policy is part of the
It requires that if you use certain constant subs from
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
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
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
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),
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.
Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014 Kevin Ryde
Perl-Critic-Pulp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Perl-Critic-Pulp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>.