Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProhibitMagicNumbers false positive with capture variables #455

Closed
thaljef opened this issue Nov 1, 2013 · 4 comments
Closed

ProhibitMagicNumbers false positive with capture variables #455

thaljef opened this issue Nov 1, 2013 · 4 comments

Comments

@thaljef
Copy link
Member

thaljef commented Nov 1, 2013

RT Ticket: http://rt.cpan.org/Ticket/Display.html?id=72980
Requested On: Mon Dec 05 11:03:37 2011
Requested By: EDAVIS@cpan.org


Test program:

$_ = 'xxxxxxxxxxxxxxxxxxxx';
/(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)/;
my $x = $13;
print $x;

Checking with --single-policy ValuesAndExpressions::ProhibitMagicNumbers
gives the message

3 is not one of the allowed literal values (0, 1, 2).

@thaljef
Copy link
Member Author

thaljef commented Nov 1, 2013

RT Ticket: http://rt.cpan.org/Ticket/Display.html?id=72980
Comment On: 2011-12-06 02:17:48
Comment By: clonezone@cpan.org


PPI bug:

ppidump 'my $x = $13;'
PPI::Document
PPI::Statement::Variable
[ 1, 1, 1 ] PPI::Token::Word 'my'
[ 1, 4, 4 ] PPI::Token::Symbol '$x'
[ 1, 7, 7 ] PPI::Token::Operator '='
[ 1, 9, 9 ] PPI::Token::Magic '$1'
[ 1, 11, 11 ] PPI::Token::Number '3'
[ 1, 12, 12 ] PPI::Token::Structure ';'

@wchristian
Copy link
Member

A fix for this has been released as a dev version to CPAN. Please test and give feedback here:

Perl-Critic/PPI#92

thaljef added a commit that referenced this issue Nov 3, 2014
This bug has been fixed via Perl-Critic/PPI#92
thaljef added a commit that referenced this issue Nov 3, 2014
This bug has been fixed via Perl-Critic/PPI#92
@thaljef
Copy link
Member Author

thaljef commented Nov 11, 2014

This is fixed in Perl-Critic-1.123 via PPI-1.220

@thaljef thaljef closed this as completed Nov 11, 2014
@epa
Copy link

epa commented Dec 31, 2014

Thanks perlcritic and PPI developers for fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants