Subject: Re: bug#16996: 24.3.50; [ruby-mode] Incorrect indentation for implicit hash arguments

From: Dmitry Gutov <[email-masked]>
Date: Sun, 18 Jul 2021 04:05:25 +0300

On 30.06.2021 11:25, Bozhidar Batsov wrote:
> Sorry for the slow responses.

Same. :-(

> On Sat, 29 May 2021 at 21:25, Dmitry Gutov <[email-masked] 
> <mailto:[email-masked]>> wrote:
> 
>     On 29.05.2021 11:55, Lars Ingebrigtsen wrote:
>      > The current indentation in Ruby here seems pretty natural to me,
>     so I'm
>      > closing this bug report.
> 
>     We should probably reopen it. It's not very urgent (as the bug creation
>     date will confirm), but I wanted to get around to this someday.
> 
>     Bozhidar, could you confirm it's still needed (or good to have)?
> 
>     I wanted to find some style guide or other solid description of this
>     style, but haven't managed to.
> 
> 
> Perhaps we should first discuss our options there and adjust ruby-mode 
> afterwards? It's always a bit painful to discuss indentation issues over 
> email. :D

I'm happy to do that anywhere. You can ping me on Discord too.

>     Ruby Style Guide strategically avoids this example, and
>     https://www.rubydoc.info/gems/rubocop/0.83.0/RuboCop/Cop/Layout/HashAlignment
>     <https://www.rubydoc.info/gems/rubocop/0.83.0/RuboCop/Cop/Layout/HashAlignment>
> 
>     and
>     https://www.rubydoc.info/gems/rubocop/0.83.0/RuboCop/Cop/Layout/ArgumentAlignment
>     <https://www.rubydoc.info/gems/rubocop/0.83.0/RuboCop/Cop/Layout/ArgumentAlignment>
> 
>     do that too.
> 
> 
> Most likely that's just an oversight. People tend to focus on the most 
> common scenarios.

I was also thinking that perhaps you had been unfortunately biased 
toward not explicitly recommending a style which ruby-mode cannot 
support. :(

>     Despite that, I actually have to deal with this implicit recommendation
>     on a regular basis at work, because when both cops are enabled, Rubocop
>     will frown on
> 
>         top(1, :a => 1,
>           :b => 2
> 
>     and
> 
>         top 1, a: 1,
>             b: 2
> 
> 
> You get those offenses for fixed indentation? For align that seems like 
> an offense indeed, but for fixed it seems quite natural.

What's a "fixed indentation"? In both of the above cases I get 
complaints from the Layout/HashAlignment cop. I think we're using its 
default config.

>     I do remember style like
> 
>         top(1, :a => 1,
>                :b => 2)
> 
>     being popular back in the day, but AFAICT a lot of editors now (like
>     Atom and VS Code) don't support it either.
> 
> 
> I have to admit that I always stick to:
> 
>   top(1,
>         :a => 1,
>         :b => 2)

Likewise, if only out of necessity.

> Still, the second option seems somewhat reasonable if you're into mixing 
> argument types on the same line, although probably aligning on the hash 
> keys would be better for the readability of the code. Probably 
> your example makes even more sense for keyword arguments.

Sure. Depending on the code, or particular invocation, I could see 
either style being more reasonable than the other.