Perl::...stants(3pm)
π NAME π
Perl::Critic::Policy::Compatibility::Gtk2Constants β bestie, this one checks that you've got a new enough Gtk2 version for the constants you're out here using π
(this page lives in the User Contributed Perl Documentation section, section 3pm, iykyk)
β¨ DESCRIPTION β¨
Okay so this policy is part of the Perl::Critic::Pulp add-on. The vibe check it runs is: if you're using certain constant subs from Gtk2 and Glib, then you must explicitly have a use of a high enough version of those modules. No cap.
use Gtk2 1.160;
... return Gtk2::EVENT_PROPAGATE; # bad
use Gtk2 1.200 ':constants';
... return GDK_CURRENT_TIME; # good
The following Gtk2 constants get checked, and pls note the version numbers exactly:
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 also these Glib constants:
SOURCE_CONTINUE # new in Glib 1.220 (devel 1.210)
SOURCE_REMOVE
The whole 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, fr fr.
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]
periodt. π
π¦ 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. Iconic behaviour honestly:
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 that latter form there's no check for :constants or explicit import in the use β it's just assumed that if you've used Gtk2 then EVENT_PROPAGATE means that one, no matter how the imports might be arranged. We don't ask questions, we just vibe check. π
π SEE ALSO π
Perl::Critic::Pulp, Perl::Critic, Gtk2, Glib
π HOME PAGE π
<http://user42.tuxfamily.org/perl-critic-pulp/index.html>
Β©οΈ COPYRIGHT Β©οΈ
Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 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/>.
okay bestie that's the whole page, ily, go update your Gtk2 π This was perl v5.40.1 dated 2025-10-21, and the manual is Perl::...stants(3pm) in case you were wondering where you even were. slay β¨π¦π
π¦ where this page comes from
- ubuntu resolute: libperl-critic-pulp-perl 100-1 Β· GPL-3.0-or-later
- ubuntu stonking: libperl-critic-pulp-perl 100-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms