RFC: add 'use warnings' to all Perl scripts and modules

Perl's warnings pragma is the cheapest way to find bugs. We already use the strict pragma; now it's time to add warnings. More importantly, it's time to review the messages produced by the warnings pragma and fix the underlying issues.

To reiterate, this RFC has two goals: turning on warnings, and fixing all warnings thus reported. Doing the first without the second will simply cause Apache logs to overflow.

Ideally, all Perl scripts and modules should have warnings enabled by the time 3.2 is released.

Details

I propose the following steps to implement this:

  1. Update the coding guidelines to require 'use strict' and 'use warnings'.
  2. For any new scripts and modules, require 'use warnings'. Since Koha (per Makefile.PL) requires at least Perl 5.6.1, the 'use warnings' pragma should be used instead of -w.
  3. Systematically go through and turn on warnings for each script and module.
  4. Unsystematically turn on warnings. I.e., whenever you patch a particular script, consider following up with a separate patch to turn on warnings. I suggest a separate patch because turning on warnings is not enough; you should run the script through its paces and fix any problems reported by the warnings pragma. For modules in C4, note that this can be a big commitment: turning on warnings means testing every function and method.
  5. Create a standing blocker bug for 3.2 for adding “use warnings”.
  6. “no warnings” should not be used absent a detailed comment explaining why warnings should be turned off within a block and why it is not possible to change the code to avoid the warning. It might be acceptable for temporary use while turning on warnings in a big module
 
en/development/rfcs3.2/rfc32_turn_on_warnings.txt · Last modified: 2008/08/05 10:01 by gmc
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki