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 .perlcriticrc file I've added the following rule with the path to .perltidyrc file.
[CodeLayout::RequireTidyCode]
perltidyrc = /path/to/.perltidyrc
I'm running perlcritic like this:
perlcritic --profile .perlcriticrc file.pm
I'm sure that perlcritic is using the rc file as I'm able to turn rules on and off by ammending the file content. I'm also sure that perltidy is using the correct rc file in the same way.
How can I prevent this error without disabling the RequireTidyCode rule?
I've added an example to recreate the problem by cutting the actual files down to the minimum where I'm still getting the error. This is how I'm running it:
cd /tmp
perltidy -b -nst TestCritic.pm
perlcritic --profile /tmp/.perlcriticrc /tmp/TestCritic.pm
The first line of the critic output is:
Code is not tidy at line 1, near 'package TestCritic;'.
These are the files:
TestCritic.pm
package TestCritic;
sub startup {
my $self = shift;
my $config;
my $service_name;
if ( defined $ENV{MYVAR} ) {
if ( $ENV{MYVAR} eq 'TESTVAL' ) {
$config = { Config => { file => '/tmp/tmp.txt' } };
$service_name = 'TestCritic.' . $$;
}
}
}
1;
.perltidyrc
-pbp
-lp
-bar
-l=120
-nolc
-vmll
-cti=1
-pt=0
-vt=0
-vtc=0
.perlcriticrc
# Show all errors
severity = 1
verbose = 11
theme = core + pbp + bugs + maintenance + cosmetic + complexity + security + tests
exclude = Subroutines::ProhibitCallsToUndeclaredSubs
Versions are: perlcritic v1.132 perltidy v20181120
Thanks,