Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statements alignment #234

Open
VladGhitulescu opened this issue Jan 19, 2024 · 5 comments
Open

Statements alignment #234

VladGhitulescu opened this issue Jan 19, 2024 · 5 comments

Comments

@VladGhitulescu
Copy link

Hey,

I still have an issue with the alignment of statements that are NOT separated by an empty line:

CleanShot 2024-01-19 at 16 52 26

I would expect that the = signs should be aligned although the first line belongs to one structure (gs_status) and the last two belongs to another structure (is_adrc_sugg).

What do you think?

Thanks!

Regards,
Vlad

@jmgrassau
Copy link
Member

Hi Vlad,

actually the Styleguide is quite clear on that, saying Align assignments to the same object, but not to different ones, and I have already come across quite a number of hard-to-read real-life cases where only this restriction helped to realize that two different structures are used:

  ls_struc_p_with_long_name-component_a = 1
  ls_struc_p_with_long_name-component_b = 2
  ls_struc_q_with_long_name-any_component   = 3
  ls_struc_q_with_long_name-other_component = 4

This could much more easily be missed if all lines were aligned:

  ls_struc_p_with_long_name-component_a     = 1
  ls_struc_p_with_long_name-component_b     = 2
  ls_struc_q_with_long_name-any_component   = 3
  ls_struc_q_with_long_name-other_component = 4

Kind regards,
Jörg-Michael

@VladGhitulescu
Copy link
Author

Hi Vlad,

actually the Styleguide is quite clear on that, saying Align assignments to the same object, but not to different ones, and I have already come across quite a number of hard-to-read real-life cases where only this restriction helped to realize that two different structures are used:

  ls_struc_p_with_long_name-component_a = 1
  ls_struc_p_with_long_name-component_b = 2
  ls_struc_q_with_long_name-any_component   = 3
  ls_struc_q_with_long_name-other_component = 4

This could much more easily be missed if all lines were aligned:

  ls_struc_p_with_long_name-component_a     = 1
  ls_struc_p_with_long_name-component_b     = 2
  ls_struc_q_with_long_name-any_component   = 3
  ls_struc_q_with_long_name-other_component = 4

Kind regards, Jörg-Michael

Hi JM,

thanks for the reply!

Hmmm... for me your lower alternative is definitely more readable, but again, maybe that's just me: If I would like to differentiate the statements more I would insert an empty row between them (and still align the = ;-)

How do you see this?

Thanks again!

Regards,
Vlad

@mraht
Copy link

mraht commented Mar 12, 2024

In the case Jörg-Michael mentioned it would be possible to control that via line breaks thus the statements mentioned could be aligned like this:

  ls_struc_p_with_long_name-component_a = 1
  ls_struc_p_with_long_name-component_b = 2

  ls_struc_q_with_long_name-any_component   = 3
  ls_struc_q_with_long_name-other_component = 4

The developer decides which statements are to be aligned together.

@VladGhitulescu
Copy link
Author

@mraht On the one hand, this is exactly what I've got initially (without the line break)

ls_struc_p_with_long_name-component_a = 1
ls_struc_p_with_long_name-component_b = 2
ls_struc_q_with_long_name-any_component = 3
ls_struc_q_with_long_name-other_component = 4

On the other hand…

In the case Jörg-Michael mentioned it would be possible to control that via line breaks

… controlling through line breaks will permit something like what I've asked for

>   ls_struc_p_with_long_name-component_a     = 1
>   ls_struc_p_with_long_name-component_b     = 2 
>   ls_struc_q_with_long_name-any_component   = 3
>   ls_struc_q_with_long_name-other_component = 4

(I hope they get aligned in the end :-) by only inserting a line break after the above block of code.

The developer decides which statements are to be aligned together.

This is the idea, yes (a man can dream... ;-)

@mraht
Copy link

mraht commented Mar 12, 2024

… controlling through line breaks will permit something like what I've asked for

Ok, to clarify my idea as I'm not sure I explained it correctly: In case of line break (single ENTER) everything is being aligned together. In case of two line breaks (new paragraph; 2x ENTER) the next lines are aligned together but not the ones of the previous paragraph:

  " two paragraphs
  ls_struc_p_with_long_name-component_a = 1
  ls_struc_p_with_long_name-component_b = 2

  ls_struc_q_with_long_name-any_component   = 3
  ls_struc_q_with_long_name-other_component = 4

  " vs. one paragraph
  ls_struc_p_with_long_name-component_a     = 1
  ls_struc_p_with_long_name-component_b     = 2
  ls_struc_q_with_long_name-any_component   = 3
  ls_struc_q_with_long_name-other_component = 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants