Questions tagged [perl-critic]

Perl::Critic is an extensible framework for creating and applying coding standards to Perl source code. Essentially, it is a static source code analysis engine. Perl::Critic is distributed with a number of Perl::Critic::Policy modules that attempt to enforce various coding guidelines.

Perl module on CPAN: Perl::Critic

perlcritic: Command-line interface to critique Perl source.

Wikipedia link

61 questions
2
votes
1 answer

Static code analysis module in Perl

Is there any static code analysis module in Perl except B::Lint and Perl::Critic? How effective is Module::Checkstyle?
mypearl
  • 61
  • 5
1
vote
3 answers

perlcritic: "require" statement with library name as string Use a bareword instead

Perlcritic complains about the following line of code: require "bin/menu.pl"; "require" statement with library name as string Use a bareword instead. However if I change it to a bare word: require bin/menu.pl I get an illegal division by zero…
turtle
  • 417
  • 3
  • 11
1
vote
1 answer

Prevent compiler execution of BEGIN / UNITCHECK / CHECK / INIT blocks

I want to detect grammar errors in my perl code. I've found that perlcritic misses many of them, (eg a random else inserted before any if, so trying to compile with perl -cw looks like the only viable option. However, I don't want to open myself up…
Tom Hale
  • 40,825
  • 36
  • 187
  • 242
1
vote
1 answer

PerlCritic flags ProhibitMagicNumbers violation 10 times only

I ran PerlCritic on the following code: my…
Saqib Shamsi
  • 522
  • 6
  • 15
1
vote
2 answers

Perl + PerlCritic | loop iterator is not lexical

I have this code ... my $line = ''; foreach $line ( split( /\n/x, $raw ) ) { chomp $line; my ( $key, $val ) = split( /=/x, $line ); $param{$key} = $val; } ... After perlcritic checking, i get…
Anton Shevtsov
  • 1,279
  • 4
  • 16
  • 34
1
vote
3 answers

Avoid PerlCritic when interpolating variables with eval

perlcritic is complaining with Expression form of "eval" [BuiltinFunctions::ProhibitStringyEval] on the first eval line from the code below: use strict; use warnings; use feature qw/say/; my $hasTwitter = 1; my $validEmail = 0; my $rule =…
Albert
  • 57
  • 3
1
vote
3 answers

How to run perl critic from a script with ProhibitExcessComplexity enabled?

How do I run Perl critic from a script with Subroutines::ProhibitExcessComplexity enabled ? I tried the following but it wasn't flagging complex 500+ line subroutines. I do not have a .perlcriticrc(Neither do I want one to be there) use…
Jean
  • 21,665
  • 24
  • 69
  • 119
1
vote
1 answer

Install Perl-Critic-1.119 on centos 6.4 with perl v5.8.8

Is there a way to install Perl-Critic-1.119 on centos 6.4 with perl v5.8.8, when i try with cpanm i get error: sudo cpanm Perl::Critic [sudo] password for kahmed: --> Working on Perl::Critic Fetching…
kamal
  • 9,637
  • 30
  • 101
  • 168
0
votes
1 answer

perlcritic message: map used in void context

There is a Perl code line below where I get the message from perlcritic: map { $total_ids += scalar @{$ids->{$_}} } @brands; The message is: "map" used in void context near 'map { $total_ids += scalar @{$ids->{$_}} } @brands;' Can anyone help me…
Saash Tech
  • 35
  • 1
  • 3
0
votes
2 answers

Install of Pod::Spell failing on Strawberry Portable 5.20.2

When I try to cpanm Pod::Spell on Strawberry 5.20.2 (64bit PortableZIP edition), it flags I18N::Langinfo as a dependency. When it tries to download the distribution for I18N::Langinfo it locates it in R/RJ/RJBS/perl-520.0.tar.gz and, wisely, thinks…
tjd
  • 4,064
  • 1
  • 24
  • 34
0
votes
1 answer

Perl::Critic: "Code before warnings are enabled" when using -w

Im getting "Code before warnings are enabled" from Perl::Critic, even though I have -w specified in the shebang #!/usr/bin/perl -w I really don't want to go through and replace all instances. Is there anything I can do? Additionally, I do want…
ldgorman
  • 1,553
  • 1
  • 14
  • 39
-1
votes
1 answer

Perl critic policy violation in checking index of substring in a string

for my $item (@array) { if (index($item, '$n') != -1) { print "HELLO\n"; } } Problem is: Perl critic gives below policy violation. String may require interpolation at line 168, near '$item, '$n''. (Severity: 1) Please advise how…
zubug55
  • 729
  • 7
  • 27
-1
votes
2 answers

Perl critic error on splitting string into array using regexp

sub func { my ($n) = @_; return unless ($n); my @array; push @array, $1 while $n =~ / ((?: [^(),]+ | ( \( (?: [^()]+ | (?2) )* \) ) )+) (?:…
zubug55
  • 729
  • 7
  • 27
-1
votes
2 answers

Why does Try::Tiny's "try {}" seem different from "eval {}" for objects created inside the try block?

I have the following initialisation code in a system tray applet: use Gtk3 -init; use Glib::Object::Introspection; eval { Glib::Object::Introspection->setup( basename => 'Notify', version => '0.7', package =>…
Axel Beckert
  • 6,814
  • 1
  • 22
  • 23
-1
votes
1 answer

how to modify rules in perlcritic

Hie , Perl critic (Source Code Analyser). I am new to this . Although I have studied the documentation and know how to run it (That's not enough!). I want to modify the rules (i.e include,exclude or add my own rules to it). I know .perlcriticrc file…
kanishka
  • 156
  • 1
  • 10