Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Perl::Critic and Perl::Tidy

by InfiniteLoop (Hermit)
on May 25, 2007 at 16:15 UTC ( #617529=perlquestion: print w/replies, xml ) Need Help??

InfiniteLoop has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks,
 Recently I have setup a subversion per-commit hook to check perl source code for certain coding standards, via Perl::Critic. One of the option is to check if the code has been run thru Perl::Tidy (Perl::Critic::Policy::CodeLayout::RequireTidyCode). Im using Perl::Critic thusly ...

#internal method to get file content of this commit my $content = read_file_content($file_name); my @violations = critique({-profile => 'perlcritic.conf'} , \$content); # report violations foreach my $crit (@violations){ print STDERR "[$file_name] " . $crit->to_string . "\tsource: " . $crit->source . "\n"; }

and the perlcritic.conf:
[CodeLayout::RequireTidyCode] perltidyrc = /svn/hooks/perltidy.conf

and the perltidy.conf
-bl # braces on new lines -l=80 #80 col width -i=4 #4 char per indent -ce # cuddled else

and one of the test commits had the following code:
.... if(1) { print "1"; } else { print "2"; } ...
among other violations, such as unindented code and code crossing 80 columns etc.
I have read the perldocs and was sure this case would be reported as an violation, however it didn't. How do I configure the Perl::Critic's profile to report violations on code that fail Perl::Tidy ?
update: changed the title

Replies are listed 'Best First'.
Re: Perl::Critic and Perl::Tidy
by chotchki (Novice) on May 25, 2007 at 19:51 UTC
    Have you tried turning up perlcritic's strictness level? I tend to use it with the -brutal flag for maximum error checking. However be careful it does complain about thing that may not apply to you (RCS tags for example).
      got it !! The issue was that I was running with severity at "gentle" and Perl::Critic would apply the Tidy check only at severity "brutal", I fixed it by using this conf:
      [CodeLayout::RequireTidyCode] perltidyrc = /svn/hooks/perltidy.conf severity = 5
      with a higher strictness, it does detect violations, but none related to code overflowing 80 col or such coding styles.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://617529]
Approved by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2020-10-30 17:44 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (282 votes). Check out past polls.