Re: Cleaning up perl code

Alexander Law <exclusion@gmail.com>

From: Alexander Lakhin <exclusion@gmail.com>
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-05-21T03:00:00Z
Lists: pgsql-hackers
Hello Dagfinn,

Thank you for paying attention to it and improving the possible fix!

20.05.2024 23:39, Dagfinn Ilmari Mannsåker wrote:
> Nice cleanup!  Did you use some static analysis tool, or did look for
> them manually?

I reviewed my collection of unica I gathered for several months, but had
found some of them too minor/requiring more analysis.
Then I added more with perlcritic's policy UnusedVariables, and also
checked for unused subs with a script from blogs.perl.org (and it confirmed
my only previous find of that kind).

>   If I add [Variables::ProhibitUnusedVariables] to
> src/tools/perlcheck/perlcriticrc, it finds a few more, see the attached
> patch.

Yes, I saw unused $sqlstates, but decided that they are meaningful enough
to stay. Though maybe enabling ProhibitUnusedVariables justifies fixing
them too.

> The scripts parsing errcodes.txt really should be refactored into using
> a common module, but that's a patch for another day.

Agree, and I would leave 005_negotiate_encryption.pl (with $node_conf,
$server_config unused since d39a49c1e) aside for another day too.

Best regards,
Alexander



Commits

  1. Clean up more unused variables in perl code

  2. Cleanup perl code from unused variables and routines

  3. Fix comment in 024_add_drop_pub.pl