Post without Account — your post will be reviewed, and if appropriate, posted under Anonymous. You can also use this link to report any problems registering.

use strict; and use warnings; in all modules?

  • 0 Replies
  • 398 Views
*

Offline Phil

  • Global Moderator
  • Sr. Member
  • *****
  • 365
    • View Profile
use strict; and use warnings; in all modules?
« December 25, 2017, 02:17:58 PM »
(from PDF::API2 pull request)

paultcochrane commented on Sep 29, 2016

Using the warnings pragma is considered best practice. By adding the warnings pragma to all files did not cause new warnings to appear in the test output. This change fixes the use_warnings kwalitee test on CPANTS. This PR is submitted in the hope that it is helpful. If it can be improved upon in any way, please simply let me know and I'll update and resubmit it.

<Request is to make sure all .pm files include use warnings;, even if they already have a no warnings list statement. Also, all .pm files should have use strict; to ensure full language compliance. -- Mod.>

ssimms commented on Oct 7, 2016

This one makes me nervous since the test coverage is pretty low. A previous maintainer took the approach of adding "no warnings" to every file, which I've been gradually undoing as I've been updating the code.

Maybe the best way forward is to do a dev release with "use warnings" throughout and see what it does to my production servers. :-)

paultcochrane commented on Oct 8, 2016

Yes, you're right. Either I'd switched off my brain while making this PR or it was late and I was tired... use strict picks things up at compile time, hence the all-usable test will show up those issues, however use warnings only has an effect if the code is run, and hence needs test coverage. If this change is too risky, I don't have a problem if you decide to close it unmerged.

<So, it sounds like use strict; and use warnings; should be inserted into code and run for a while before releasing to the general public? -- Mod.>