Refactor of Perl Critic policy ProhibitUnusedVarsStricter

Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter (whew!) is a Perl Critic policy that attempts to be more stringent about finding unused variables than the core policy of similar name. One of the things that has to be done to make this happen is to figure out which variables are interpolated into double-quotish strings.

The original version of this module had its own string-analysis logic, as do other Perl-Critic policies that have to figure out which variables are really being used. With the mainstreaming of postfix dereferencing, it seemed to me that the recognition of interpolated variables had become complex enough that a separate module to figure this stuff out was justified. Thus was born PPIx::QuoteLike.

PPIx::QuoteLike is a complete rewrite of the logic that was formerly embedded in ProhibitUnusedVarsStricter to discover interpolated variables, and the new version of ProhibitUnusedVarsStricter has been exhaustively regression-tested against the old one (version 0.006). "Exhaustively" is not just hyperbole; both versions were run against CPAN, and all differences resolved. This does not mean there are no known differences between the output of new release and version 0.006, only that the known differences are believed by me to be false positives (usually) or false negatives (occasionally).

Because this release of ProhibitUnusedVarsStricter represents a significant change, I have bumped the version number to 0.099_001, so that the production release will be 0.100. I also intend to allow three or four weeks for people to chew on the new ProhibitUnusedVarsStricter before making the production release, rather than my usual one week.

Earlier, I had tried to bend PPIx::Regexp to work in this application, but I was never happy with the result. It looked to me like a bodge job, probably because it was. This functionality (accessed via the 'parse' argument to new()) has always been documented as experimental, and with the release of PPIx::QuoteLike this part of PPIx::Regexp's functionality is discouraged. Once I think PPIx::QuoteLike is established, the experimental functionality in PPIx::Regexp will be put through a deprecation cycle and removed. PPIx::Regexp will continue to be the module of mine to use to analyze Perl regular expressions.

Leave a comment

About Tom Wyant

user-pic Fine Perl code for over 0.005 centuries.