Re: perlcritic and perltidy

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: perlcritic and perltidy
Дата
Msg-id abe20cb6-357f-1d62-5680-d1974079e7f8@2ndQuadrant.com
обсуждение исходный текст
Ответ на Re: perlcritic and perltidy  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-hackers

On 05/25/2018 03:04 PM, Bruce Momjian wrote:
> On Sun, May  6, 2018 at 11:53:34AM -0400, Tom Lane wrote:
>> What sort of changes do we get if we remove those two flags as you prefer?
>> It'd help to see some examples.
>>
>> Since we just went to a new perltidy version, and made some other
>> policy changes for it, in HEAD, it'd make sense to make any further
>> changes in this same release cycle rather than drip drip drip over
>> multiple cycles.  We just need to get some consensus about what
>> style we like.
> I saw you looking for feedback so I wanted to give mine.  Also, Andrew,
> thanks for working on this --- it is a big help to have limited Perl
> critic reports and good tidiness.
>
> I am using the src/tools/pgindent/perltidyrc setting for my own Perl
> code, but needed to add these two:
>
>     --noblanks-before-comments
>     --break-after-all-operators
>
> The first one fixes odd blank lines when I put comments inside
> conditional tests, e.g.:
>
>          if (!$options{args_supplied}               &&
>                  !$is_debug                             &&
>                  defined($stat_main)                    &&
>                  defined($stat_cache)                   &&
>                  $stat_main->mtime < $stat_cache->mtime &&
>                  # is local time zone?
>                  (!defined($ENV{TZ}) || $ENV{TZ} =~ m/^E.T$/))
>
> Without the first option, I get:
>
>          if (!$options{args_supplied}               &&
>                  !$is_debug                             &&
>                  defined($stat_main)                    &&
>                  defined($stat_cache)                   &&
>                  $stat_main->mtime < $stat_cache->mtime &&
> -->
>                  # is local time zone?
>                  (!defined($ENV{TZ}) || $ENV{TZ} =~ m/^E.T$/))
>
> which just looks odd to me.  Am I the only person who often does this?
>
> The second option, --break-after-all-operators, is more of a personal
> taste, but it does match how our C code works, and people have said I
> write C code in Perl.  ;-)
>



I agree with adding --no-blanks-before-comments. That doesn't remove any 
blank lines, it just stops perltidy from adding them before comments, so 
adding it to the perltidyrc doesn't change anything.

I looked at --break-after-all-operators, but I didn't like the result. I 
tried to refine it by adding --want-break-before='. : ? && || and or'. 
However, it didn't do what it was told in the case of ? operators. That 
seems like a perltidy bug. The bug persists even in the latest version 
of perltidy. So I think we should just leave things as they are in this 
respect.

cheers

andrew

-- 
Andrew Dunstan                https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: Periods
Следующее
От: Douglas Doole
Дата:
Сообщение: Re: Redesigning the executor (async, JIT, memory efficiency)