use strict in all Perl programs

Started by Peter Eisentrautover 9 years ago5 messageshackers
Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

Here is a patch to add 'use strict' to all Perl programs (that I could
find), or move it to the right place where it was already there. I
think that is a pretty standard thing to do nowadays.

I tried testing the changes in pgcheckdefines, but it just spits out
nonsense before and after.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

0001-Use-use-strict-in-all-Perl-programs.patchtext/x-patch; name=0001-Use-use-strict-in-all-Perl-programs.patchDownload+87-58
#2Michael Paquier
michael@paquier.xyz
In reply to: Peter Eisentraut (#1)
Re: use strict in all Perl programs

On Sat, Dec 31, 2016 at 3:07 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

Here is a patch to add 'use strict' to all Perl programs (that I could
find), or move it to the right place where it was already there. I
think that is a pretty standard thing to do nowadays.

I tried testing the changes in pgcheckdefines, but it just spits out
nonsense before and after.

What about adding as well "use warnings"? That's standard in all the TAP tests.
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Michael Paquier (#2)
Re: use strict in all Perl programs

On 12/31/16 1:34 AM, Michael Paquier wrote:

On Sat, Dec 31, 2016 at 3:07 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

Here is a patch to add 'use strict' to all Perl programs (that I could
find), or move it to the right place where it was already there. I
think that is a pretty standard thing to do nowadays.

committed that

What about adding as well "use warnings"? That's standard in all the TAP tests.

'use strict' can be statically checked using perl -c, but 'use warnings'
is run-time behavior, so one would have to extensively test the involved
programs. Some cursory checking already reveals that this is going to
need to more investigation. So in principle yes, but maybe later.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4David Steele
david@pgmasters.net
In reply to: Peter Eisentraut (#3)
Re: use strict in all Perl programs

On 1/5/17 12:37 PM, Peter Eisentraut wrote:

On 12/31/16 1:34 AM, Michael Paquier wrote:

On Sat, Dec 31, 2016 at 3:07 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

Here is a patch to add 'use strict' to all Perl programs (that I could
find), or move it to the right place where it was already there. I
think that is a pretty standard thing to do nowadays.

committed that

What about adding as well "use warnings"? That's standard in all the TAP tests.

'use strict' can be statically checked using perl -c, but 'use warnings'
is run-time behavior, so one would have to extensively test the involved
programs. Some cursory checking already reveals that this is going to
need to more investigation. So in principle yes, but maybe later.

With regard to warnings, I prefer to use:

use warnings FATAL => qw(all);

This transforms all warnings into errors rather than just printing a
message to stderr, which is very easy to miss among the other output.

--
-David
david@pgmasters.net

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Michael Paquier
michael@paquier.xyz
In reply to: David Steele (#4)
Re: use strict in all Perl programs

On Fri, Jan 6, 2017 at 11:13 PM, David Steele <david@pgmasters.net> wrote:

With regard to warnings, I prefer to use:

use warnings FATAL => qw(all);

This transforms all warnings into errors rather than just printing a message
to stderr, which is very easy to miss among the other output.

Interesting. A couple of warnings have slipped a couple of times in
some TAP tests like those of pg_rewind, so it could be useful to
switch to that at least for the tests by detault.
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers