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
25
votes
6 answers

Is it better to croak() or to die() when something bad happens in Perl?

perlcritic complaints that the following code, some boilerplate DBI stuff that works perfectly fine, should croak instead of die: # Connect to database my $db_handle = DBI->connect( $url, $user, $password ) or die $DBI::errstr; All this, while die…
GeneQ
  • 7,485
  • 6
  • 37
  • 53
18
votes
4 answers

Perl::Critic: Life after Moose?

I've started a conversion of a project to Moose and the first thing I noticed was that my critic/tidy tests go to hell. Moose, Tidy and Critic don't seem to like each other as much as they used to. Are there docs anywhere on how to make critic/tidy…
claco
  • 739
  • 1
  • 8
  • 18
16
votes
5 answers

Why does Perl::Critic dislike using shift to populate subroutine variables?

Lately, I've decided to start using Perl::Critic more often on my code. After programming in Perl for close to 7 years now, I've been settled in with most of the Perl best practices for a long while, but I know that there is always room for…
Weegee
  • 2,225
  • 1
  • 17
  • 16
11
votes
1 answer

Perl::Critic "Don't use this method"-type rule

We have been using Perl::Critic here at work to enforce our code conventions. Recently we ran into issues with /tmp directory getting filled up due to the Temp::File::tempdir function. tempdir cleans up when the Perl process terminates, but since…
Alexander Tsepkov
  • 3,946
  • 3
  • 35
  • 59
10
votes
1 answer

Module ends in "1;", perlcritic complains that it doesn't

Have a simple module package Rrr; use 5.014; use warnings; use namespace::sweep; use Moo; use Method::Signatures::Simple; BEGIN { our $VERSION = '0.0.1'; } has 'root' => ( is => 'rw', default => 'root' ); method func { say 'This…
kobame
  • 5,766
  • 3
  • 31
  • 62
9
votes
5 answers

Is there a better way to write Perl regexes with /x so the code is still easy to read?

I ran Perl::Critic on one of my scripts, and got this message: Regular expression without "/x" flag at line 21, column 26. See page 236 of PBP. I looked up the policy information here, and I understand that writing regular expressions in extended…
BrianH
  • 7,932
  • 10
  • 50
  • 71
9
votes
4 answers

Is there anything like PPI or Perl::Critic for C?

PPI and Perl::Critic allow programmers to detect certain things in the syntax of their Perl programs. Is there anything like it that will tokenize/parse C and give you a chance to write a script to do something with that information?
Jake
  • 211
  • 3
  • 5
8
votes
4 answers

What is the correct way to exclude RequireRcsKeywords from Perl Critic?

I'm trying to exclude checks of Perl Critic's RequireRcsKeywords in a single Perl script. I don't want to change my default policy in .perlcriticrc so I added a "no critic" line to the top of the source. Despite that change, Perl Critic still…
Starfish
  • 1,083
  • 10
  • 23
8
votes
1 answer

Perl Critic: Comma used to separate statements

Follow code is not accepted by Critic, severity 4: return { 'debug' => $debug, 'identifier' => $identifier }; I get this error: # Perl::Critic found these violations in "filename.pl": # Comma used to separate statements at line 356, column…
Konerak
  • 39,272
  • 12
  • 98
  • 118
8
votes
7 answers

Are there any good automated frameworks for applying coding standards in Perl?

One I am aware of is Perl::Critic And my googling has resulted in no results on multiple attempts so far. :-( Does anyone have any recommendations here? Any resources to configure Perl::Critic as per our coding standards and run it on code base…
Jagmal
  • 5,726
  • 9
  • 35
  • 35
8
votes
2 answers

How to detect unreachable code in Perl conditional which always evaluates to false?

I'm new to Perl, and am currently tasked with tidying and maintaining a large and pretty messy Perl project. I'm using perl-critic to help me detect issues in the code (and also to teach me best practices). The existing code has places where the…
Josh Greifer
  • 3,151
  • 24
  • 25
7
votes
2 answers

perlcritic: eval "require $module";

While digging in some old source code I saw the following: my $module = $some{module}; eval "require $module"; die "Bad module\n$@" if $@; while I understand what the code does, it tries "require" a module and die when it is unsuccessful - the…
kobame
  • 5,766
  • 3
  • 31
  • 62
6
votes
1 answer

Perl::Critic 'Code before strictures' when using Modern::Perl

I understand that it is best practice to use Modern::Perl rather than use strict and warnings. With default options, Perl::Critic v1.121 complains about code before strict, even when 'use Modern::Perl' comes before code. QUESTION: Is the best…
null
  • 889
  • 1
  • 13
  • 24
6
votes
4 answers

How do I enable PerlCritic support in Komodo IDE 5.1 on Windows?

I'm trying to enable PerlCritic support in Komodo. The official word from ActiveState, the makers of Komodo IDE 5.1 (Win 32) is: "To enable PerlCritic support, please install the 'Perl-Critic' and 'criticism' modules." Well, installing Perl-Critic…
GeneQ
  • 7,485
  • 6
  • 37
  • 53
5
votes
2 answers

Perlcritic - Two argument "open" error

I have a script and I am trying to elimate bad practices using perlcritic. One line I have is as follows: open(my($FREESPCHK), $cmdline ) || &zdie($MSG_PASSTHRU,"Error checking free space of file system."); This gives this error: Two-argument…
En-Motion
  • 899
  • 6
  • 21
  • 34
1
2 3 4 5