Login | Register
My pages Projects Community openCollabNet

Discussions > users > Re: Question about Perl::Critic::Statistics

perlcritic
Discussion topic

Back to topic list

Re: Question about Perl::Critic::Statistics

Author Elliot Shank <perl at galumph dot com>
Full name Elliot Shank <perl at galumph dot com>
Date 2008-10-30 19:03:13 PDT
Message Ben Douglas (bedougla) wrote:
> Hello,
>
> I'm trying to create a static analysis perl script using Perl::Critic
> and was looking to use the new Statistics package, however am getting
> errors when calling 'accumulate'. Here's the code I'm trying to execute:
>
> #!/usr/cisco/bin/perl5.8.8 -w
> use Perl::Critic;
>
> print "Running Perl::Critic $Perl::Critic::VERSION\n\n";
>
> my $file = shift;
> print "Analyzing $file...\n";
> #my $critic = Perl::Critic->new(-theme => 'bugs && maintenance &&
> security && complexity');
> my $critic = Perl::Critic->new();
>
> my @violations = ();
>
> @violations = $critic->critique($file);
>
> print "Gathering statistics...\n";
>
> my $stats = $critic->statistics();
> my $stats = Perl::Critic::Statis​tics->new();
> $stats->accumulate($file, \@violations);
> The accumulate call is throwing the following error:
>
> bedougla@asbo:/ws/be​dougla/earms/scripts​$
> <mailto:bedougla@​asbo:/ws/bedougla/ea​rms/scripts$> ./static_analysis.pl
> runner.pl
> Running Perl::Critic 1.090
>
> Analyzing runner.pl...
> Gathering statistics...
> Can't locate object method "find" via package "runner.pl" (perhaps you
> forgot to load "runner.pl"?) at
> /usr/cisco/packages/​perl/perl-5.8.8/lib/​site_perl/5.8.8/Perl​/Critic/Statistics.p​m
> line 47.
> bedougla@asbo:/ws/be​dougla/earms/scripts​$
> <mailto:bedougla@​asbo:/ws/bedougla/ea​rms/scripts$>
> Do I need 1.0.92 in order to get the statistics module working correctly?

1. Always "use strict;". And while you're at it, use "use warnings;" and not "-w".

2. You don't create the statistics object yourself; just get the one the $critic object created.

Updated program attached.

« Previous message in topic | 1 of 7 | Next message in topic »

Messages

Show all messages in topic

Re: Question about Perl::Critic::Statistics Elliot Shank <perl at galumph dot com> Elliot Shank <perl at galumph dot com> 2008-10-30 19:03:13 PDT
     Re: Question about Perl::Critic::Statistics thaljef Jeffrey Ryan Thalhammer 2008-10-31 00:13:32 PDT
     RE: Question about Perl::Critic::Statistics "Ben Douglas (bedougla)" <bedougla at cisco dot com> "Ben Douglas (bedougla)" <bedougla at cisco dot com> 2008-10-31 06:53:07 PDT
     Re: Question about Perl::Critic::Statistics nadim khemir <nadim at khemir dot net> nadim khemir <nadim at khemir dot net> 2008-11-01 18:20:14 PDT
         Re: Question about Perl::Critic::Statistics Elliot Shank <perl at galumph dot com> Elliot Shank <perl at galumph dot com> 2008-11-02 06:37:29 PST
             Re: Question about Perl::Critic::Statistics nadim khemir <nadim at khemir dot net> nadim khemir <nadim at khemir dot net> 2008-11-02 11:22:45 PST
                 Re: Question about Perl::Critic::Statistics Elliot Shank <perl at galumph dot com> Elliot Shank <perl at galumph dot com> 2008-11-02 12:15:16 PST
Messages per page: