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

People
Owner: thaljef [...] cpan.org
Requestors: bzm [...] 2bz.de
Cc: kclark [...] cpan.org
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.06
Fixed in: 0.10



Subject: Long number limit is to low
Hi, I noticed that the 'Long number' limit is far to low. ie: return sprintf( '%02d.%02d.%04d %02d:%02d:%02d', $d, $m + 1, $y + 1900, $h, $mm, $s ); gives: Long number not separated with underscores a ... I never write 1_900 for that. I suggest a configure option for the limit.
[BORISZ - Sat Sep 24 10:32:57 2005]: Show quoted text
> Hi, > I noticed that the 'Long number' limit is far to low. ie: > > return sprintf( '%02d.%02d.%04d %02d:%02d:%02d', > $d, $m + 1, $y + 1900, $h, $mm, $s ); > > gives: > Long number not separated with underscores a ... > > I never write 1_900 for that. I suggest a configure option for the > limit. >
This patch ups the number length to 7 (e.g., 1_000_000), which seems reasonable: $ diff -c RequireNumberSeparators.pm.orig RequireNumberSeparators.pm *** RequireNumberSeparators.pm.orig 2005-09-30 17:53:24.000000000 -0400 --- RequireNumberSeparators.pm 2005-09-30 17:53:34.000000000 -0400 *************** *** 13,19 **** my $expl = [55]; my $desc = q{Long number not separated with underscores}; my $nodes_ref = $doc->find('PPI::Token::Number') || return; ! my @matches = grep { $_ =~ m{ \d{4,} }x } @{$nodes_ref}; return map { Perl::Critic::Violation->new( $desc, $expl, $_->location() ) } @matches; } --- 13,19 ---- my $expl = [55]; my $desc = q{Long number not separated with underscores}; my $nodes_ref = $doc->find('PPI::Token::Number') || return; ! my @matches = grep { $_ =~ m{ \d{7,} }x } @{$nodes_ref}; return map { Perl::Critic::Violation->new( $desc, $expl, $_->location() ) } @matches; } ky
Thanks for the suggestion. I don't think it will do quite what you mean. If I understand it correctly, it just forces every seventh digit to be separated, like this: 1234567_1234567.1234567_1234 I think the correct solution is to test the actual magnitude of the number, like this: my $min = 10_000; my @matches = grep { $_ >= $min && $_ =~ m{ \d{4,} }x } @{$nodes_ref}; I intend to make $min configurable. Does 10,000 seem like a good default to you? -Jeff [guest - Fri Sep 30 17:55:09 2005]: Show quoted text
> [BORISZ - Sat Sep 24 10:32:57 2005]: >
> > Hi, > > I noticed that the 'Long number' limit is far to low. ie: > > > > return sprintf( '%02d.%02d.%04d %02d:%02d:%02d', > > $d, $m + 1, $y + 1900, $h, $mm, $s ); > > > > gives: > > Long number not separated with underscores a ... > > > > I never write 1_900 for that. I suggest a configure option for the > > limit. > >
> > This patch ups the number length to 7 (e.g., 1_000_000), which seems > reasonable: > > $ diff -c RequireNumberSeparators.pm.orig RequireNumberSeparators.pm > *** RequireNumberSeparators.pm.orig 2005-09-30 17:53:24.000000000 > -0400 > --- RequireNumberSeparators.pm 2005-09-30 17:53:34.000000000 -0400 > *************** > *** 13,19 **** > my $expl = [55]; > my $desc = q{Long number not separated with underscores}; > my $nodes_ref = $doc->find('PPI::Token::Number') || return; > ! my @matches = grep { $_ =~ m{ \d{4,} }x } @{$nodes_ref}; > return map { Perl::Critic::Violation->new( $desc, $expl, > $_->location() ) } > @matches; > } > --- 13,19 ---- > my $expl = [55]; > my $desc = q{Long number not separated with underscores}; > my $nodes_ref = $doc->find('PPI::Token::Number') || return; > ! my @matches = grep { $_ =~ m{ \d{7,} }x } @{$nodes_ref}; > return map { Perl::Critic::Violation->new( $desc, $expl, > $_->location() ) } > @matches; > } > > ky >
Done in version 0.10. See POD in RequireNumberSeparators for details.