Just before christmas I received a bug report for my Perl::Critic policy: Perl::Critic::Policy::logicLAB::ProhibitShellDispatch.
The policy was motivated and implemented to avoid calls to platform specific utilities etc. At a certain point I was involved in migrating a rather large code base from Solaris to Linux and then we really got bitten by this.
The recommendation is to use pure-perl tools where available. An example of this I had observed earlier was calls to hostname like so:
my $hostname = qx/hostname/;
my $hostname = `hostname`;
These can easily be exchanged by use of the CPAN distribution Net::Domain and you can possibly find other such examples (please let me know of these, since I am always on the lookout for more examples).
A pretty basic problem area and a very simple implementation.
Now back to the bug report.
The initial policy was one of my first and the code was pretty basic and I did expect it to hold some issues, but since the problem area was so basic I did not know what to expect.
The issue reported was a false-positive for Net::OpenSSH‘s system method. The issue demonstrated that the code was way too simple and I had to rewrite the internals. The policy simply evaluated PPI::Token::Word‘s (and some others), but I had to extend the policy to evaluate the context of the words and hence look at the involved statement as a whole.
So all in all a somewhat hard to fix bug, since the policy was perhaps broken by design. But at the same time, the policy is better now and I think it addresses some other cases I do not know about, with the improved implementation.
Considering the value provided by the bug report and can only welcome bug reports and emphasize the importance of reporting bug and requesting features etc. and if I was afraid of bug reports, the policy would never have been released in the first place.
The distribution is now on Github, but this does not mean you have to fork and create a pull request – you can always just contact me, but you are most welcome to use the open repository.
jonasbn, Copenhagen
(cross-posted from logicLAB.jira.com)