Search code examples
perlperl-critic

Can't get the policy Perl::Critic::Policy::Tics::ProhibitLongLines to work


I have:

  • Ubuntu 10.04
  • Perlbrew 0.39
  • Switched to Perl 5.12.3. with perlbrew
  • Installed Perl::Critic and Perl::Critic::Tics with cpanm

My .perlcriticrc file:

severity = 1
only= 1

[CodeLayout::ProhibitHardTabs]
allow_leading_tabs = 0

[Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines]

[Perl::Critic::Policy::Tics::ProhibitLongLines]
base_max = 120
hard_max = 130
pct_allowed = 5

[Perl::Critic::Policy::OTRS::RequireCamelCase]

The other policies function as expected, but whenever a line is over the length defined by hard_max, I get the warning messages:

Use of uninitialized value $min_width in numeric gt (>) at /home/birdy/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/String/Format.pm line 51.
Use of uninitialized value $replength in numeric gt (>) at /home/birdy/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/String/Format.pm line 51.
Use of uninitialized value $max_width in numeric gt (>) at /home/birdy/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/String/Format.pm line 56.
Use of uninitialized value $replength in numeric gt (>) at /home/birdy/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/String/Format.pm line 56.
Use of uninitialized value $replength in subtraction (-) at /home/birdy/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/String/Format.pm line 67.
Use of uninitialized value $min_width in subtraction (-) at /home/birdy/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/String/Format.pm line 67.
Use of uninitialized value $replacement in concatenation (.) or string at /home/birdy/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/String/Format.pm line 67.

Solution

  • This seems like a bug to me. I get the same warnings even if I completely ignore my .perlcriticrc file:

    perlcritic -1 --noprofile mycode.pl
    

    I am on perl 5.12.2.

    You should submit a bug report against Perl::Critic::Tics. I have checked the Changes files for both Tics and Perl::Critic, but I did not find anything relevant to String::Format. Make sure you have recent versions of Critic and Tics. I have the current Tics (0.006), but my Critic is a little outdated (1.111).