Bug 41076

Summary: Perltidy config needs to be refined to not cause changes with perltidy 20250105
Product: Koha Reporter: Victor Grousset/tuxayo <victor>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: jonathan.druart, m.de.rooy, martin.renvoize, mtj
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on:    
Bug Blocks: 41077    
Attachments: Bug 41076: Adjust our perl tidiness for v20250105
Bug 41076: Adjust our perl tidiness for v20250105

Description Victor Grousset/tuxayo 2025-10-23 00:06:36 UTC
1. KOHA_IMAGE=main-bookworm ktd up
2. prove xt/perltidy.t
3. leave running for like a minute, it passes, don't bother with full run
4. KOHA_IMAGE=main-trixie ktd up
5. prove xt/perltidy.t
6. failures quickly pile up

D12:
perltidy --version
This is perltidy, v20230309
dpkg -l | grep tidy
20230309-1~koha3 (ours)

D13:
perltidy --version
This is perltidy, v20250105
dpkg -l | grep tidy
20250105-1

So in KTD, the D13 image doesn't ship our perltidy so it uses Debian's which is more recent. And might use some different default that aren't covered by our current config. I guess it would be better to complete the config so that both version of perltidy output the same code, right? Rather than making the D13 image ship an old version of perltidy which would postpone the root issue.
Comment 1 Victor Grousset/tuxayo 2025-10-23 00:09:34 UTC
Also, it makes the qa script fail if working on Debian 13
Comment 2 Jonathan Druart 2025-10-23 10:43:06 UTC
(In reply to Victor Grousset/tuxayo from comment #0)
> So in KTD, the D13 image doesn't ship our perltidy so it uses Debian's which
> is more recent. And might use some different default that aren't covered by
> our current config. I guess it would be better to complete the config so
> that both version of perltidy output the same code, right?

Yes, that is what needs to be done.
Comment 3 Jonathan Druart 2026-01-23 08:54:37 UTC
Actually there are not many changes, and they are actually bugfixes

https://perltidy.sourceforge.net/ChangeLog.html

I would suggest to make v20250105 our default versions for the different OSes.
Comment 4 Jonathan Druart 2026-01-23 08:58:15 UTC
Created attachment 191896 [details] [review]
Bug 41076: Adjust our perl tidiness for v20250105

Generated using
  `perl misc/devel/tidy.pl --perl`
Comment 5 Jonathan Druart 2026-01-23 08:58:22 UTC
It's actually a lot of changes to test files, but they are greatly improving the readability!
Comment 6 Jonathan Druart 2026-01-23 08:58:51 UTC
Do not push if v20230309 is not the default everywhere! See with Mason.
Comment 7 Marcel de Rooy 2026-01-23 09:08:29 UTC
Which rules actually change?
Comment 8 Jonathan Druart 2026-01-23 09:40:35 UTC
(In reply to Marcel de Rooy from comment #7)
> Which rules actually change?
As said there are bug fixes.

I found this one:

https://perltidy.sourceforge.net/ChangeLog.html
2025 01 05

- Space around here doc delimiters follow spacing controls better. For
example, a space is now added before the closing paren here:

   OLD: (without the here doc):
   push( @script, <<'EOT');

   NEW:
   push( @script, <<'EOT' );

Also, any spaces between the '<<' and here target are removed (git #174):

   OLD:
   push( @script, <<  'EOT');

   NEW:
   push( @script, <<'EOT' );


The other changes made sense to me (and felt like bug fixes as well) so it seems better to include the changes than adding options to ignore them.
Comment 9 Martin Renvoize (ashimema) 2026-01-26 13:51:26 UTC
Created attachment 192028 [details] [review]
Bug 41076: Adjust our perl tidiness for v20250105

Generated using
  `perl misc/devel/tidy.pl --perl`

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 10 Martin Renvoize (ashimema) 2026-01-26 13:53:18 UTC
I@m happy with the changes here.. I would have liked to indent params in search calls, but perltidy can't do that consistently.. 

We could add nesting to our code to get around it, but that also feels a bit dirty for little reward.

Certainly need to wait for Mason to get the go ahead before pushing this one though.