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
5
votes
2 answers

How do I make Perl::Critic show the offending policy in its output?

I've been told it's possible to have Perl::Critic show the policy name that is offending in its output. But I can't recall what I have to do to turn this on. How can this be enabled in a perlcritic.rc?
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
5
votes
1 answer

Forcing Ale to display Perl::Critic violations as warnings rather than errors

I'm using vim with the Ale plugin. By default, perlcritic violations show up as errors. I'd like to see them displayed as warnings. According to :help g:ale_type_map I should be able to do this, but it isn't clear to me exactly how. let…
oalders
  • 5,239
  • 2
  • 23
  • 34
5
votes
2 answers

Why should I use or <> instead of in Perl?

Quoting from Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin Perl has a useful magic filehandle called *ARGV that checks the command line and if there are any arguments, opens and reads those as files. If there are no arguments, *ARGV…
Lazer
  • 90,700
  • 113
  • 281
  • 364
5
votes
3 answers

Use IPC::Open3 with perlcritic

I want to supress output in child process and read only stderr. perlfaq8 advises to do following: # To capture a program's STDERR, but discard its STDOUT: use IPC::Open3; use File::Spec; use Symbol qw(gensym); open(NULL, ">",…
Andrey Starodubtsev
  • 5,139
  • 3
  • 32
  • 46
5
votes
3 answers

Why doesn't 'opendir' have the same policy as 'open' in Perl Best Practices?

Is there a reason why opendir doesn't have the same policy than open in Perl Best Practices? I'm thinking about at least these 2…
sebthebert
  • 12,196
  • 2
  • 26
  • 37
5
votes
4 answers

How can we catch side comments using Perl::Tidy or Perl::Critic?

My department is currently settling on some general code best practices, which we would like to somewhat enforce, providing developers with Perl::Tidy and Perl::Critic configurations. Now we are having problems with side comments. The side comment…
Nikolai Prokoschenko
  • 8,465
  • 11
  • 58
  • 97
4
votes
6 answers

Perlcritic config - finding the names of the policies that generate an error?

I'm trying to get started using Perlcritic, and I'm working on refining my own configuration, leaving out all the rules I don't agree with or don't think are appropriate for me. I know that I can do this using a .perlcrirticrc file, and that I can…
Bart B
  • 661
  • 8
  • 18
4
votes
1 answer

Perlcritic not recognising code that has been tidied

I'm using perlcritic with perltidy and while the other rules are applied, I'm, getting the following error message: Code is not tidy at line 1, near 'package MyPackage;'. I've run perltidy to tidy the code but I am still getting the problem. In the…
Geraint Anderson
  • 3,234
  • 4
  • 28
  • 49
4
votes
1 answer

Disable critic for an entire file - Parse::RecDescent precompiled parser & PerlCritic/Tidyall

I'm trying to remove an error from my sanity-checking [when I push code to my git repo, there's a hook that checks the code with perltidy & critic... using tidyall as the handler.] The specific issue I have is with a pre-compiled Grammar Parser....…
CodeGorilla
  • 811
  • 1
  • 6
  • 21
4
votes
3 answers

how to install perl critic on osx?

I tried to download, unpack, follow instructions: tar -zxf Perl-Critic-1.107_001.tar.gz cd Perl-Critic-1.107_001 perl Makefile.PL make make test make install When I get to the make step I get: /usr/bin/perl "-Iblib/arch"…
Joelio
  • 4,621
  • 6
  • 44
  • 80
4
votes
2 answers

How can I run Test::Perl::Critic in parallel?

I've written a simple test case based on Test::Perl::Critic which runs critic on every single source file in the repository (all_critic_ok). However, this test takes a long time, especially since I also use a Perl::Tidy policy. Normally,…
Nikolai Prokoschenko
  • 8,465
  • 11
  • 58
  • 97
4
votes
1 answer

Perl Regex To convert String to Hex Warns of uninitialized value or to use /x

I am using regex in perl to convert string to hex, however, when I do this, I get a warning from either perl critic or perl: #$test is defined, i just put the regex code snippet here... #this will trigger a warning from perl critic #warning: use of…
Bostwick
  • 696
  • 1
  • 12
  • 24
3
votes
1 answer

Cant 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 =…
Birdy
  • 79
  • 5
3
votes
3 answers

Perl::Critic in Brutal Mode

So I've recently started using Perl::Critic to check the quality of the code I've written. I'm running it in brutal mode and have one suggestion it is making which I don't understand as being an issue. The output is: Return value of flagged function…
Mario T.
  • 55
  • 3
3
votes
5 answers

Where is $_ being modified in this perl code?

The following perl code generates a warning in PerlCritic (by Activestate): sub natural_sort { my @sorted; @sorted = grep {s/(^|\D)0+(\d)/$1$2/g,1} sort grep {s/(\d+)/sprintf"%06.6d",$1/ge,1} @_; } The warning generated is: Don't modify $_…
Craig
  • 991
  • 1
  • 13
  • 28