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: 62562
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: DOUGDUDE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in:
  • 1.109
  • 1.111
Fixed in:
  • 1.110_001
  • 1.112_001
  • 1.112_002
  • 1.113



Subject: ValuesAndExpressions::ProhibitMagicNumbers should be able to give a Readonly equivalent
Currently ValuesAndExpressions::ProhibitMagicNumbers will allow numbers to be defined using "use constant" or the Readonly module. It would be nice to be able to provide an option for it to say what I think should be what makes a variable constant (like "const" when I use Const::Fast). Currently I can do this by adding "const" to %READONLY_SUBROUTINES, but I cannot do this a run time since it is readonly. But an actual configuration option would be better.
On Fri Oct 29 14:35:43 2010, DOUGDUDE wrote: Show quoted text
> Currently ValuesAndExpressions::ProhibitMagicNumbers will allow numbers > to be defined using "use constant" or the Readonly module. It would be > nice to be able to provide an option for it to say what I think should > be what makes a variable constant (like "const" when I use Const::Fast). > Currently I can do this by adding "const" to %READONLY_SUBROUTINES, but > I cannot do this a run time since it is readonly. But an actual > configuration option would be better.
Not only is %READONLY_SUBROUTINES readonly, it is lexically scoped. I suspect that the only way to get your desired result in the short term is to mung the .pm file. That said, SVN revision 3982 has been committed to the Perl::Critic repository, to add a configuration parameter to allow additional constant-manufacturing subroutines to be recognized. I can't promise that it will be in the next release though. Tom
Thank you for making this wishlist item come true in 1.113 :)!