3

Assuming a Perl script such:

my @a = (
    1,
    2,
    3
) ;

my @b = qw(
    foo
    bar
    baz
) ;

executing perltidy with options: perltidy -nopro -ci=4 -boc -sts, I get a different closing parens alignment between the array and the qw list:

my @a = (
    1,
    2,
    3
) ;

my @b = qw(
    foo
    bar
    baz
    ) ; # <== misplaced parens, I want it to be at column 1

I want to get the closing parens of the qw list aligned to column 1. What am I doing wrong, or what am I missing?

UPDATE

Thanks to the suggestion of @toolic I disabled my .perltidyrc file (my bad, I missed to do it before) and searched for the rule causing the misformatting of qw lists and found that is the --space-terminal-semicolon that alters the closing parens alignment only for qw lists.

I updated the perltidy options in the above issue description. I don't really understand if it may be a bug of perltidy or not.

Anyway, the issue is now reproducible and seems that I have to choose the lesser evil between having the closing parens of the qw lists misaligned or giving up the space before the semicolon at the end of the statements :-(

Hannibal
  • 445
  • 4
  • 13
  • The version is v20190601 and bump.. Yes, I have it. I missed to comment it during my command line test :'( Lets try whitout .perltidyrc dotfile – Hannibal Oct 10 '21 at 16:58
  • @toolic great!! You saved my day. Commenting all rules in my `.perltidyrc` dotfile the qw list gets well formatted. I have now to search for the wrong rule in my config file. Thansk and post your answer for getting the upvote!! – Hannibal Oct 10 '21 at 17:06
  • Uhhmm.. I found and removed the conflicting rule `-sts` (--space-terminal-semicolon) and the qw list are well formatted now, but I can't get the space before the semicolon at the end of the line. – Hannibal Oct 10 '21 at 17:28
  • Have you tried to use `vim` to reformat perl code? It might be what you looking for. [How can I autoformat/indent C code in vim?](https://stackoverflow.com/questions/2355834/how-can-i-autoformat-indent-c-code-in-vim/2355848), [Fix indentation](https://vim.fandom.com/wiki/Fix_indentation), [7 Vim Tips That Changed My Life With Demo](https://www.freecodecamp.org/news/7-vim-tips-that-changed-my-life/). – Polar Bear Oct 10 '21 at 23:23
  • @Polar Bear, I don't directly call the perltidy linter, but it's called by a code formatter plugin of Sublime Text editor we use in our company. Anyway I'll open an issue to github and meanwhile I can tolerate some misplaced closing parens in qw lists :-) – Hannibal Oct 11 '21 at 18:14

1 Answers1

2

I am unable to reproduce your result. I do not have a .perltidyrc command file, which can have options that are not on your command line.

You can use the perltidy -nopro option to ignore any .perltidyrc command file, if you have one.

toolic
  • 57,801
  • 17
  • 75
  • 117
  • I upvoted your answer but I have updated the issue too because the strange beahaviour still persists, I guess you should now reproduce it. The conflicting option seems to be the --space-terminal-semicolon that alters the closing parens alignment only for the qw lists. – Hannibal Oct 10 '21 at 17:42