Posted on 2008-08-15 21:50:22-07 by gr001032
RCS keyword conundrum

I'm trying to figure out a way to include an RCS Revision keyword that sets a $VERSION value without getting any errors or warnings from perlcritic.

Currently, I use a technique to set $VERSION to the value of Revision that I found in the book Perl Medic by Peter J. Scott. For example, I have:

our $VERSION = (qw$Revision: 1.79 $)[-1];

This works fine, but Miscellanea::RequireRcsKeywords gives me an error because it can't find the Revision keyword. I assume it's just looking in strings or comments. In the documentation for Miscellanea::RequireRcsKeywords, they give an example to do the above using the construction:

our ($VERSION) = '$Revision: 2609 $' =~ m{ \$Revision: \s+ (\S+) }x;

That works fine for me but now ValuesAndExpressions::ProhibitInterpolationOfLiterals gives me a warning that I have string that may require interpolation.

I'd like to try to find a way to do this that makes perlcritic happy. I suppose I could the first method and also stick a Revision keyword in a comment, but I would like to know if there's a way to do it more elegantly.

Direct Responses: 8625 | Write a response
Posted on 2008-08-19 05:58:24-07 by thaljef in response to 8585
Re: RCS keyword conundrum

I'm afraid I don't know of an 'elegant' solution. This is just one of those situations where perlcritic is more hinderance than helpful. I like Scott's suggestion better than the one in our perldoc, so I'd go with that [does perl warn about "$" inside of a qw() ?]. Yes, RequireRcsKeywords only looks for the keywords inside comments. IMHO, adding another $Revision$ inside a comment isn't the worst thing in the world, especially since SVN/CVS do all the work of updating them. And you probably still want to have $Author$, $Source$, and other keywords somewhere too. So adding another $Revision$ doesn't seem so bad.

I'll look to see if we can make either of those policies a little smarter. But for now, all I can give you is a rationalization rather than a solution. Sorry :(

BTW: The best way to get answers to perlcritic questions is to send mail to dev@perlcritic.tigris.org. The team is always happy to help.

Cheers!

-Jeff
Direct Responses: 8641 | Write a response
Posted on 2008-08-20 15:19:27-07 by gr001032 in response to 8625
Re: RCS keyword conundrum
Thanks for the response. I guess I'll just stick in another Revision keyword.
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.