… where I get out my virtual broom and sweep up cruft in my assigned distribution for this month’s edition of the CPAN Pull Request Challenge.
This month’s module: BackPAN::Index
BackPAN::Index provides an index of BACKPAN.
In this section I try to get a feeling for the state of the module, how up to date it is, how often people are contributing to it, how many other distributions are depending on it, how many bugs/issues it currently has, what the CPANTS kwalitee is, etc.
- last commit 10 Dec 2014 (https://github.com/book/BackPAN-Index)
- latest release 30 Dec 2012 (https://metacpan.org/pod/BackPAN::Index)
- 13 open issues in GitHub
- 4 open pull requests
- 1 open issue on RT (2 years old) (https://rt.cpan.org/Public/Dist/Display.html?Name=BackPAN-Index)
- 3 reverse dependencies via metacpan
- some test failures on cpantesters (mostly on (Free/Open)BSD): http://matrix.cpantesters.org/?dist=BackPAN-Index+0.42
- CPANTS report (http://cpants.cpanauthors.org/dist/BackPAN-Index)
- core metrics: all ok
- extra metrics
- experimental metrics
- experimental metrics no longer seem to be shown on CPANTS
Initial inspection of the source code
After forking the repo and cloning a local copy, let’s have a look at the project to see what build system it uses, if the test suite works and the tests pass, if it could do with a Travis-CI config file (or if present, if it can be updated).
- README is simple text; and created as part of build process.
- minor grammar-os in README, will need to read all POD, since README is autogenerated from docs.
- no information about how to build and test the dist, since the README is build from API documentation.
- no Travis-CI config; add a .travis.yml?
Mouse; convert to Moo?
cpanm --installdeps .works as expected
perl Build.PLruns without a problem
./Buildruns without problems
./Build testruns without problems (perl 5.18.4, Linux x64, Debian Jessie)
t/00setup.talways downloads and rebuilds the BackPAN index. Hard on data usage when tethering to a mobile phone for internet.
AUTHOR_TESTING=1 ./Build testbarfs on POD coverage tests
Looking at the code coverage can give an indication of code quality. If the project is well covered, this means most changes made in pull requests can be made with some confidence that any problems will be caught by the test suite. If the code coverage is low, then this is something that one could address as a pull request (or set of pull requests).
In EUMM and
Build::Module projects, one simply needs to install
Devel::Cover and run
Dist::Zilla projects, one needs to install the
Dist::Zilla::App::Command::cover plugin, after which the code coverage can
be checked via:
In this distribution, the coverage is:
90.2% statement coverage; 84.6% total coverage
Which is pretty good. Maybe one could push it a bit higher, but that’s probably not a big priority.
podchecker searches through Perl source code for POD which
might not conform to the POD standard, and thus not necessarily be parseable
by all POD parsers. Fixing any issues found by
podchecker has the
positive effect of also removing any warnings noted in the project’s
documentation displayed on MetaCPAN.
podchecker gives the following errors and warnings:
Check for trailing whitespace
Some projects consider this a must, and will disallow commits to be submitted which contain trailing whitespace (the Linux kernel is an example project where trailing whitespace isn’t permitted). Other projects see whitespace cleanup as simply nit-picking. Either way one sees it personally, this could be a useful pull request to a project, so it’s worthwhile fixing and submitting; the worst that can happen is that the pull request is closed unmerged.
To look for files with trailing whitespace, run
git grep ' $'. It can be
helpful to load the files found directly into
Found 4 files to fix and submitted a fix in PR#40.
Perl::Critic will show up many
potential issues for Perl code. By simply running
perlcritic on the
t directories, one can get a further handle on the code’s quality.
- two argument “open”
- expression form of eval
- code before strictures
Fixes submitted in PR #42.
Links to websites can go out of date, so it’s a good idea to see if they need updating or removing. A quick grep finds all the links. After which, we just need to see which links need fixing, if any.
All ok except for those fixed in PR #37.
This probably also sits in the nit-picking category for some people, however, copyright dates (theoretically) need to be kept up to date. The appropriate copyright year is usually the year of the last release. However, if a release looks imminent, then the current year is likely to be the right candidate. Some distributions put the author’s email address on the same line as the copyright date, hence this needs to be checked as well.
Files missing current year in copyright
Here we do a case-insensitive grep over the source for the word “copyright”,
the line of which we check for the existence of a year (i.e. 4 digits), look
for the appropriate year and then clean up the grep results to get something
we can pass directly to
Copyright year updated in PR#39.
Files missing an email address in copyright
Spell check POD
Good documentation can be a wonder to read. Not everyone’s docs are awesome, however we can keep the error rate to a minimum. A quick spell check will pick up most typos that don’t need to be there and fixing them can help improve the quality of a project.
In general, we want to find all files containing POD and run a spell checker
aspell) over all files, fixing typos we come across as we go. Not
all projects require this much effort, however here’s a general-ish way to
look for and check all POD in a project:
Now look for
.bak file and check differences between it and the output
.txt file, the process looks roughly like this:
Then update the appropriate
.pod files as necessary.
Issues fixed in PR #38.
Although CPANTS is the main kwalitee
reference, one can also run the kwalitee tests locally. One can use the
t/kwalitee.t test script from
http://codeaffe.de/cpan-pull-request-challenge/ for this purpose.
However, the script only uses
Test::Kwalitee which doesn’t cover as many
metrics as CPANTS.
set of metrics closer to that used on CPANTS, so replace the
call with simply
use Test::Kwalitee::Extra. More information about the
many options to
Test::Kwalitee::Extra can be found on the MetaCPAN page.
Run the kwalitee tests in an
distribution like so:
or, if the distribution uses
Basic kwalitee tests pass.
The only open issue (https://rt.cpan.org/Public/Bug/Display.html?id=86265) is documented as “patched”. The issue is thus actually resolved; the issue merely needs to be closed.
- issue #30 would be resolved by PR #41.
Overview of the pull requests made
- update GitHub and RT URLs (https://github.com/book/BackPAN-Index/pull/37)
- minor POD fixes (https://github.com/book/BackPAN-Index/pull/38)
- update copyright year (https://github.com/book/BackPAN-Index/pull/39)
- remove trailing whitespace (https://github.com/book/BackPAN-Index/pull/40)
- add initial Travis-CI config (https://github.com/book/BackPAN-Index/pull/41)
- fix perlcritic errors (https://github.com/book/BackPAN-Index/pull/42)
Unfortunately there hasn’t been any reaction from the author or current maintainer concerning the pull requests submitted. It’s been a couple of years since the last commit and four years since the last release, so maybe there’s not much interest in this module anymore.
There were a couple of issues I’d have liked to have addressed but didn’t get around to:
- declare minimum Perl version (
perlverreports 5.12.0 as min version)
- document development installation instructions
Adding the installation instructions would require changing the README which could be controversial, depending upon how the authors view READMEs in dists versus the function of READMEs on GitHub. Perhaps this could be something for someone to do in a future Pull Request Challenge?