Open gflohr opened 7 years ago
I believe there is a PR in progress in this queue where someone was working on this problem, but ran into a few issues and then stalled out.
FWIW, I always put my use strict; use warnings
before the package declarations, even though I neither use [PkgVersion] nor perl-critic in most code.
That's also an option.
see #168 and #588.
@gflohr I found this issue from your blog article about Distzillla and TravisCI. Thank you for that.
Would be an alternative for you to use Dist::Zilla::Plugin::OurPkgVersion
? That inserts the $VERSION
where you put # VERSION
in your code files.
Perl::Critic
is satisfied if you place # VERSION
below use strict
@dboehmer Thanks for the hint. Yes, that's a good solution for me.
I won't close the issue but I don't mind if the package owner closes it.
Another alternative is to use OurPkgVersion instead. You can then control where the VERSION variable is placed.
The PkgVersion plug-in inserts the assignment to $VERSION immediately after the
package
keyword but before a possible 'use strict'. That is not an error but Test::Perl::Critic complains about it.A workaround is to specify the option "use_package" for PkgVersion but that means that your module no longer runs on older Perls (for example 5.10). In some situations that can be a high price to pay for the automatic versioning.
Feature suggestion: What about a new option "use_strict" for PkgVersion that inserts the version string immediately after the first "use strict"? That would shut up Perl::Critic. And if it also dies if there is no "use strict", it would be a cheap qa measure.
The problem could, of course, also be fixed inside Perl::Critic but it would probably be harder there.