rjbs / Dist-Zilla

scary tools for building CPAN distributions
http://dzil.org/
186 stars 153 forks source link

PkgVersion conflicts with Test::Perl::Critic #602

Open gflohr opened 7 years ago

gflohr commented 7 years ago

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.

karenetheridge commented 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.

karenetheridge commented 7 years ago

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.

gflohr commented 7 years ago

That's also an option.

karenetheridge commented 7 years ago

see #168 and #588.

dboehmer commented 6 years ago

@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.

gflohr commented 6 years ago

@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.

andrewjmaguire commented 5 years ago

Another alternative is to use OurPkgVersion instead. You can then control where the VERSION variable is placed.