Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^2: Symbolic reference with strict "refs" (it stinks!)

by tye (Cardinal)
on Aug 17, 2012 at 21:13 UTC ( #988098=note: print w/ replies, xml ) Need Help??

in reply to Re: Symbolic reference with strict "refs"
in thread Symbolic reference with strict "refs"

no strict 'refs'; ## no critic (strict)

Wow. I mean... Wow.

Clearly, what we need now is a Perl::Critic rule that warns you when you turn off Perl::Critic checking in a way that isn't wise.</sarcasm>

I'm actually a fan of tools that can point out my mistakes. There is a reason I choose the word "mistakes" there and not "misdeeds".

In programming, I've found that trying to prevent people from doing something "bad" by accident can often be a valuable effort. Trying to prevent people from purposefully doing something "bad" usually ends up being a worse idea than the original "bad" thing (that is trying to be prevented).

I can see the power of Perl::Critic being quite valuable when used to prevent accidental mis-steps. I can even see value in an automated tool telling me that I forgot to include "use strict;" in some file of Perl code. RequireUseStrict sounds like that.

I despair for whoever felt it was a good idea to even create the ProhibitNoStrict rule.

The only sane solution here is to simply turn off that rule in whatever configuration the original poster is using. If that rule is turned on by default in any cluster of configuration settings for Perl::Critic, then that should be changed as well.

If ProhibitNoStrict is even kept as part of Perl::Critic, then turning it on should write "Either you're an idiot or your boss is a maniacal control freak of limited skill; probably both" somewhere.

Whoever wrote ProhibitNoStrict, if you thought you were helping inexperienced coders learn some kind of best practice, then please read the original question. The only result was to plant FUD and to encourage working around a stupid test by doing something even more dodgy than the practice originally declared somehow undesirable.

At least there was more justification for the state of things with "/*LINTED*/". I thought we learned the folly of that route long ago. I guess the people writing and using the new Perl 'lint' are probably too young to know anything about the old C 'lint'.

I consider inclusion of "## no critic" to be completely unacceptable in a code review. Perhaps I should write a Perl::Critic policy module to enforce that automatically. What we really need is a tool that forces us to make our code ugly so we all have to look at that noise every time we edit or read the code so we can avoid seeing any complaints if we run the tool.

- tye        

Comment on Re^2: Symbolic reference with strict "refs" (it stinks!)
Re^3: Symbolic reference with strict "refs" (it sticks!)
by chromatic (Archbishop) on Aug 17, 2012 at 21:50 UTC

    I skimmed the post once and was ready to disagree with you, but you're completely correct. The intent may have been good ("Hey, you should at least look at code which disables strictures to see if it's sensible!"), but there's no way to implement this in Perl::Critic sensibly. It's not a good rule.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988098]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-09-22 11:19 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (189 votes), past polls