Subject: | uninitialized values on particular sample file |
Date: | Fri, 4 Jan 2013 22:23:43 +0100 |
To: | bug-Perl-Critic [...] rt.cpan.org |
From: | Salvatore Bonaccorso <carnil [...] debian.org> |
Hi
I'm forwarding the bugreport reported in Debian by Guillem Jover:
http://bugs.debian.org/697329
----cut---------cut---------cut---------cut---------cut---------cut-----
Hi!
While running perlcritic over the dpkg code base I've found a file
perlcritic trips over. As I'm fixing issues, the file might not show
those when it gets looked at so here's a reference to a specific git
blob object:
<http://anonscm.debian.org/gitweb/?p=dpkg/dpkg.git;a=blob;f=scripts/dpkg-genchanges.pl;h=082664140fec005917d58e7aa9866de63dfc0330;hb=HEAD>
I seem to have tracked the issue down to being triggered by the '%r'
verbose format. To reproduce, with an empty .perlcriticrc, run:
$ perlcritic -1 --verbose "%l:%c near '%r'\n" dpkg-genchanges.pl
Notice the empty '%r' expansions.
Thanks,
Guillem
----cut---------cut---------cut---------cut---------cut---------cut-----
Attached sample.pl is a reduced example, where the uninitialized
values warning are appearing too:
perlcritic -3 --verbose "line %l, column %c near '%r'.\n" sample.pl
Use of uninitialized value $min_width in numeric gt (>) at /usr/share/perl5/String/Format.pm line 51.
Use of uninitialized value $replength in numeric gt (>) at /usr/share/perl5/String/Format.pm line 51.
Use of uninitialized value $max_width in numeric gt (>) at /usr/share/perl5/String/Format.pm line 56.
Use of uninitialized value $replength in numeric gt (>) at /usr/share/perl5/String/Format.pm line 56.
Use of uninitialized value $replength in subtraction (-) at /usr/share/perl5/String/Format.pm line 67.
Use of uninitialized value $min_width in subtraction (-) at /usr/share/perl5/String/Format.pm line 67.
Use of uninitialized value $replacement in concatenation (.) or string at /usr/share/perl5/String/Format.pm line 67.
line 11, column 9 near 'warn '$bar defined';'.
line 14, column 25 near ''.
line 16, column 5 near 'warn 'undefined value for $foo';'.
where the sample.pl is
----cut---------cut---------cut---------cut---------cut---------cut-----
#!/usr/bin/perl
use strict;
use warnings;
my $foo = '1:2';
my $bar;
if (defined $foo) {
if (defined $bar) {
warn '$bar defined';
}
(my $baz = $foo) =~ s/^\d+://;
} else {
warn 'undefined value for $foo';
}
----cut---------cut---------cut---------cut---------cut---------cut-----
(p.s.: know might be shown better)
Regards,
Salvatore
Message body is not shown because sender requested not to inline it.
Message body not shown because it is not plain text.