Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 44987
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.104



Subject: NamingConventions::Capitalization vs multi-constant
Date: Mon, 13 Apr 2009 08:53:49 +1000
To: bug-Perl-Critic [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
With the current cvs I noticed with an input use constant { ONE => 1, TWO => 2 }; reports Constant "{ ONE => 1, TWO => 2 }" is not all upper case at line 1, column 5. See pages 45,46 of PBP. (Severity: 1) where I hoped it would recognise "ONE" and "TWO" as ok (or failing that recognise it's an expression rather than a bareword or string constant and therefore can't be directly interpreted).
Index: Capitalization.run.PL =================================================================== --- Capitalization.run.PL (revision 3219) +++ Capitalization.run.PL (working copy) @@ -164,6 +164,15 @@ my $foo = $condition ? $objection->method : $alternative; my $foo = $condition ? undef : 1; +#----------------------------------------------------------------------------- + +## name "use constant" multi-constant hash +## failures 0 +## cut + +use constant { ONE => 1, + TWO => 2 }; + END_SIMPLE_TESTS return;
Proposed fix committed as SVN revision 3291. The only change to P::C::Utils:PPI is to document that get_constant_name_element_from_declaring_statement() returns a PPI::Structure::Constructor or PPI::Structure::Block when it encounters something like 'use constant { FOO => 1, BAR => 2 };' so it does not change out from under the code added to handle this case. Tom Wyant