sfodje / perlcritic

MIT License
5 stars 4 forks source link

Modules::RequireFilenameMatchesPackage rule is not enforced #25

Open dseynhae opened 3 years ago

dseynhae commented 3 years ago

I want to make sure that my module or script name matches the file name. A typo is too easy to sneak in, and sometimes I actually use a template, and forget to update the package name.

PerlCritic quickly identifies those mistakes through the [Modules::RequireFilenameMatchesPackage] rule.

However, a couple of mistakes snuck in, and were never flagged!

This is because:

This can quickly be verified with an experiment, take any Perl file, where the package name does not match the file name:

perlcritic <file>
perlcritic --program-extensions .pl <file>
cat file | perlcritic

The first check will flag the name mismatch. The second and last check will not flag the problem!

The fix is to present perlcritic with a file, rather than a string: