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

People
Owner: thaljef [...] cpan.org
Requestors: kclark [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.07
Fixed in: 0.07



Subject: Integer with leading zeros
I'm getting an error of "Integer with leading zeros" on the following: chmod 0755, $path; Do I really have to use "oct" here? The Perl manpage on "chmod" shows using the leading zero, so it would be nice not to complain about it at least in this one context. Other than seconding a few other bugs already posted ($1 seen as punctuation var, 1900 seen as a long number), and my other bug, this is a TOTALLY ROCKIN' MODULE. Thank you so much for writing it! ky
From: kclark [...] cpan.org
[guest - Fri Sep 30 16:26:19 2005]: Show quoted text
> I'm getting an error of "Integer with leading zeros" on the following: > > chmod 0755, $path; > > Do I really have to use "oct" here? The Perl manpage on "chmod" shows > using the leading zero, so it would be nice not to complain about > it at least in this one context. > > Other than seconding a few other bugs already posted ($1 seen as > punctuation var, 1900 seen as a long number), and my other bug, > this is a TOTALLY ROCKIN' MODULE. Thank you so much for writing > it! > > ky
This seems to fix my problems: $ diff -c ProhibitLeadingZeros.pm.orig ProhibitLeadingZeros.pm *** ProhibitLeadingZeros.pm.orig 2005-09-30 18:04:28.000000000 -0400 --- ProhibitLeadingZeros.pm 2005-09-30 18:04:41.000000000 -0400 *************** *** 13,19 **** my $expl = [55]; my $desc = q{Integer with leading zeros}; my $nodes_ref = $doc->find('PPI::Token::Number') || return; ! my @matches = grep { $_ =~ m{\A -? 0+ \d+ \z }x } @{$nodes_ref}; return map { Perl::Critic::Violation->new( $desc, $expl, $_->location() ) } @matches; --- 13,23 ---- my $expl = [55]; my $desc = q{Integer with leading zeros}; my $nodes_ref = $doc->find('PPI::Token::Number') || return; ! my @matches = grep { ! $_ =~ m{\A -? 0+ \d+ \z }x ! && ! $_->statement !~ m{ \A chmod }x ! } @{$nodes_ref}; return map { Perl::Critic::Violation->new( $desc, $expl, $_->location() ) } @matches; ky
K- I appreciate your thinking, but I fear that is a slippery slope. If other developers have the same complaint, I'll reconsider making an exception for C<chmod>. But in general, things that appear in the Perl documentation are not automatically qualified as Best Practices. In fact, a lot of the code samples in the perldoc, "Programming Perl", "The Perl Cookbook" and other texts are directly responsible for the unmaintainable code that Perl-Critic is trying to discourage. Thanks for all your patches! If you have any ideas for enhancements or new Policies, please send them a long. Have a great weekend. -Jeff