January CPAN Pull Request Challenge

I'm taking part in NeilB's CPAN Pull Request challenge and received String::Random for my January task.  I quickly forked the repo on Github, cloned it into my local server, took a look at it, and felt immediately overwhelmed.  This is a well-written module that does exactly what the documentation asks for, so I wasn't sure where I could contribute.  After dithering for a few days, I asked on the pr-challenge mailing list and got very good advice from Neil and the author of String::Random, Shlomi Fish, himself.  I should definitely have introduced myself to Shlomi first thing after getting the assignment.  He was very approachable and helpful while I worked on his module.

I set myself two tasks:
  • Clean up output of perlcritic -1
  • Add a rand_gen parameter to the new method allowing the user to specify their own random number generator
Cleaning up perlcritic was mostly a matter of implementing most of the suggestions and ignoring, via a module-wide .perlcriticrc file, the policies I and/or Shlomi disagreed with.  Shlomi asked for small commits, so I worked down from perlcritic -5 to perlcritic -1, cleaning up all the instances of a policy at once and committing those changes.  This worked well and led to a series of discrete commits.

Adding the rand_gen functionality was straightforward.  I modified the new method to check for the parameter, save the subroutine in the String::Random object, then replaced all calls to rand with the saved subroutine.  I built tests using one of the existing test files as a template, added documentation, and committed the changes to my fork of String::Random.

I submitted my changes as two pull requests on Github, with the rand_gen PR depending on the perlcritic cleanup PR.  I'm not sure what the best way to handle that as these should have been orthogonal, but the formatting changes from the perlcritic PR made it difficult to get a clean PR for rand_gen.

Shlomi quickly accepted my PRs and the new version of String::Random is available.  I'd like to thank Shlomi Fish for his assistance and Neil for his advice helping me get started.

No comments:

Post a Comment