ssimms / pdfapi2

Create, modify, and examine PDF files in Perl
Other
15 stars 21 forks source link

Fix IO-related perlcritic warnings #10

Closed paultcochrane closed 8 years ago

paultcochrane commented 8 years ago

This PR updates the code to use the three argument form of open and replaces bareword filehandles with scoped lexical variables. These issues were found by perlcritic running at the default severity level. The reason why both issues are handled in the one PR is that the changes often affect the same lines of code, hence if put into separate PRs they would cause conflicts.

This PR is submitted in the hope that it is helpful. If it can be improved upon or needs to be updated, please just let me know and I'll update as required and resubmit.

I noticed a potential issue in lib/PDF/API2/Resource/Font/Postscript.pm at line 118 while preparing this PR: the filehandle is closed on this line, however it is also used in the following elsif block. Unfortunately, I'm not that familiar with the code, so I'm not 100% sure what the correct code would be, however it looks like it would be best to close the filehandle outside the if-elsif-else blocks so that seeks and reads being called in the elsif block run on an opened filehandle. Just thought you'd like to know!

ssimms commented 8 years ago

It looks like the if/elsif is parsing two different types of file. In the first case, the file will get closed, but in the second, it doesn't. Moving the close outside of the if seems like the right step, so I'll do that after merging this PR. Thanks for bringing it up.