http://qs321.pair.com?node_id=617529

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.