I want my, I want my Kwa-li-tee

If you publish code to CPAN, you've probably noticed the steady improvement in its entire ecosystem over the last couple of years. ++Neil Bowers and ++the meta::cpan core hackers in particular have laboured tirelessly to improve the release process for authors and the user experience for consumers of CPAN code.

One of the things that's most useful as an author is the CPANTS Kwalitee ratings generated for any release to CPAN. The Kwalitee ranking markers are continuously being improved and added to, and I recently updated my build config to follow some recommendations the system gave me.

I use Dist::Zilla for publishing to CPAN, and I was able to address all the recommendations using Dist::Zilla plugins. Here are the newly added configs in my dist.ini:

  • [MinimumPerl]
    It's polite to tell compilers that a minimum version of Perl is required to build your module. This will include it in Makefile.PL as well as the CPAN META files. I was aware of the plugin but hadn't used it since my modules run on 5.006, but it's better to include it in any case.
  • [MetaProvides::Package]
    While meta::cpan itself was already extracting and printing (on the module's page) a section titled "Provides" that shows the modules in the repo, formal specs call for the information to be in the META files as well. This plugin adds it there.
  • [GitHub::Meta]
    You've probably seen the bitchin' contextual menu on a meta::cpan module page, with links to the Kwalitee, CPAN testers matrix, and so on. Perhaps you've noticed that some distros have a link to the source code repository, and/or the issues page for the project. If you keep your code on GitHub, this plugin will insert the information including URLs into the META files.
  • [Prereqs / TestRequires]
    Include Test::More. I had not been including this module since it is in Core Perl, but the meta::cpan spec calls for all build dependencies to be listed in the META files. Including it in your [Prereqs] section will take care of the requirement.

With these measures all in place, my latest distribution of Dancer2::Logger::LogAny regains a 100 "core Kwalitee" score (it had dropped from 100 to 96.77 between the penultimate and ante-penultimate releases, as Kwalitee introduced new markers), satisfies all the Kwalitee recommendations (even the experimental ones), and garners an overall score of 145.16.

That ain't working ... that's the way you do it ... you let the dzil boost your kwa-li-tee :-)

2 Comments

All good suggestions. As a note [MinimumPerl] isn't strictly necessary, it will attempt to autodetect the minimum version of perl required, but if you want to explicitly declare a minimum version that you support, you can add a runtime prerequisite on perl (such as via [Prereqs]); this will also be reflected in Makefile.PL. My general rule for CPAN is to declare a minimum of 5.008001 (5.8.1) unless the module is for an ecosystem like Mojolicious or Dist::Zilla that requires a higher version anyway, or someone contributes a patch to make it work on 5.6. I also recommend setting up Travis CI for your github repos, it can automatically test back to 5.8 in the standard configuration, on each commit and pull request, so you can make sure compatibility is maintained.

In case, one really wants to have Kwalitee approved stats, I would recommend [MinimumPerlFast]. I have recently started using it instead of [MinimumPerl].

Leave a comment

About 1nickt

user-pic I read blogs about Perl.