Subject: | ProhibitMagicNumbers does not recognize octal in allowed_values |
Create test program 'testprog' with content
$x = 020;
Checking this with
% perlcritic --single-policy ValuesAndExpressions::ProhibitMagicNumbers
testprog
gives a warning that 020 is not an allowed literal value. Fine so far.
But create a configuration file 'rc' with content
[ValuesAndExpressions::ProhibitMagicNumbers]
allowed_values = 020
and recheck with
% perlcritic -t rc --single-policy
ValuesAndExpressions::ProhibitMagicNumbers testprog
The same warning appears. On the other hand, '20' instead of '020'
behaves correctly in that adding it to allowed_values stops the warning.
I suggest that to add support for octal (and hexadecimal), each base
should be treated separately. So adding '020' to allowed_values would
not mean that '16' is allowed, nor the other way. (And similar for '0x10'.)