New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gflohr opened this Issue Nov 6, 2017 · 6 comments

Comments

Projects
None yet
3 participants
@gflohr

gflohr commented Nov 6, 2017

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.

gflohr added a commit to gflohr/File-Globstar that referenced this issue Nov 6, 2017

@karenetheridge

This comment has been minimized.

Contributor

karenetheridge commented Nov 6, 2017

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

This comment has been minimized.

Contributor

karenetheridge commented Nov 6, 2017

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

This comment has been minimized.

gflohr commented Nov 6, 2017

That's also an option.

@karenetheridge

This comment has been minimized.

Contributor

karenetheridge commented Nov 6, 2017

see #168 and #588.

@dboehmer

This comment has been minimized.

dboehmer commented Jan 9, 2018

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

  • (+) automatic versioning
  • (+) Perl::Critic is satisfied if you place # VERSION below use strict
  • (-) you need to add that comment to all source files
@gflohr

This comment has been minimized.

gflohr commented Jan 9, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment