public inbox for [email protected]  
help / color / mirror / Atom feed
From: Andres Freund <[email protected]>
To: [email protected]
Subject: pgindent vs variable declaration across multiple lines
Date: Thu, 19 Jan 2023 17:31:37 -0800
Message-ID: <[email protected]> (raw)

Hi,

There's a few places in the code that try to format a variable definition like this

    ReorderBufferChange *next_change =
        dlist_container(ReorderBufferChange, node, next);

but pgindent turns that into

    ReorderBufferChange *next_change =
    dlist_container(ReorderBufferChange, node, next);

even though the same pattern works, and is used fairly widely for assignments

	amroutine->amparallelvacuumoptions =
		VACUUM_OPTION_PARALLEL_BULKDEL;

Particularly when variable and/or types names are longer, it's sometimes hard
to fit enough into one line to use a different style. E.g., the code I'm
currently hacking on has

            RWConflict  possibleUnsafeConflict = dlist_container(RWConflictData, inLink, iter.cur);

There's simply no way to make break that across lines that doesn't either
violate the line length limit or makes pgindent do odd things:

too long line:
            RWConflict  possibleUnsafeConflict = dlist_container(RWConflictData,
                                                                 inLink,
                                                                 iter.cur);

pgindent will move start of second line:
            RWConflict  possibleUnsafeConflict =
                dlist_container(RWConflictData, inLink, iter.cur);

I know I can leave the variable initially uninitialized and then do a separate
assignment, but that's not a great fix. And sometimes other initializations
want to access the variable alrady.


Do others dislike this as well?

I assume we'd again have to dive into pg_bsd_indent's code to fix it :(

And even if we were to figure out how, would it be worth the
reindent-all-branches pain? I'd say yes, but...

Greetings,

Andres Freund






view thread (7+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: pgindent vs variable declaration across multiple lines
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox