in reply to How Critical is Critic?
I was surprised it didn't like this use of eval:
our $VERSION = '0.1_1'; $VERSION = eval $VERSION;
As far as I remember, this is standard boilerplate introduced to ensure PAUSE will index the distribution with correct module versions. At one time, at least, PAUSE would scan the code for a version number in a fairly simplistic manner (specifically not running any code, for security concerns), so this ensured that it will see the string value as the version to index the code under while any actual code will see the eval'd value. I do not know if PAUSE still does that: I would expect by now that there would be ways to provide the version information more robustly by means of metadata.
For the rest of it: perlcritic by default is an implementation of PBP, and PBP was written with two goals in mind - for people who don't care, to provide a ready-made set of coding standards to use within an organization; for people who do care, to provide a starting point to think about how to assemble a set of coding standards.
Since Damian expected that organizations with the least Perl skills would be most likely to simply adopt PBP wholesale, the ready-made set is optimized for that group. The idea that every regexp should be written with //xms flags is an example of this: you can for example teach your developers that /./ means "match any character" without having to deal in complexities, and filling their head with edge cases. As kcott says, this is cargo-cult programming - but intentionally so.
The prescriptions in PBP were never intended to be a straitjacket for people who do care, and are prepared to put any time into thinking about how they want their code to look. I recommend reading it (or re-reading it) with that in mind before attempting to use them - even in second-hand form, as via perlcritic.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How Critical is Critic?
by Bod (Parson) on May 29, 2023 at 18:08 UTC |