-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
style guide: Stop aligning parameters at =
and/or $
#322
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for this, though I will note that we shouldn't make it mandatory to refactor a whole module for this when a single parameter is added. Consistency within the file is probably more important.
Adding a new paramter should not cause a refactor. But I think we should enforce the new style for new parameters and ignore the existing style in a file. What do you think about that? |
If we are changing this for a class/define variable list, are we planning to change this for a resource definition's => which has the same "feature." I agree with the change, but I might agree less with the resource definition change (because the => alignment makes it easier to read) |
this is only about the parameter list in classes/defined resources. not about resource declaration. We've a puppet-lint plugin that enforces the alignment there and I think we should keep it. The diff for resources is usually way way smaller. |
Personally, I find it easier to read code when things are all vertically aligned. Also As long as there's a way to tell the linter to accept the old format (or to ignore whitespace between tokens entirely), I have no objections. |
There's a slight typo... "Sometimes were was an additional alignment". I believe this should be "Sometimes there was an additional alignment". |
I would agree that the downside of having to refactor when adding a parameter is not good. However I am not so sure about the longterm readability. |
Just like other people here, my preference go to aligned types / names / default value because it is ways more comfortable for me to work with these lines when items are vertically aligned. For sure, rebasing commits that change types can be a PITA, but only when we change the column where alignment take place. When using a syntax that use tabs, it's easy to use say "2 tabs" in general and if a line overflow, just put a single space and not align this line; but because puppet files don't use tabs (and 2 spaces soft-tabs), when I have a little overflow I trend to "fix" it by re-aligning all members… leading to these conflicts. But I am ready to pay this rebase conflict risk when dealing with such changes 🤷. Having a rule that says that we should align fields is probably an annoyance. Maybe we can just remove this line? If people have to deal with aligned fields and it's annoying, they can remove the extra spacing and be happy. If people have to deal with unaligned fields and it's annoying, they can add extra spacing and be happy. I don't think that happen so often that we will have to deal with issues where a module go back and forth from a form to the other; and since people trend to contribute to some modules and not all, the module they contribute to the most are likely to use the alignment that fit them best in the end? |
I would still bias to the alignment of = making it easier to read for me but I feel the frustration it creates when a new parameter knocks everything about. |
I understand that. But should the parameters be readable? That's the whole purpose of the REFERENCE.md. Provide the readable list of all parameters, their datatypes and the default values. |
I find it easier to read if I have some space between things, for syntax and code for itself it is not required i know, but to get an overview and read and compare things I very much like this alignment. It is not nice to rebase, but I think it is worth the work to keep things aligned to better understand/read/view them. |
My preference:
First we have paramaters without defaults, odered alphabetical.
All parameter groups (see above) should align at $ and = |
I do agree that alignment increases readability, but personally, I don't think it's worthwhile, given the documented annoyances for modification. I stopped aligning parameter sections shortly after I started declaring the data types, since the lines were getting way too long. The use of |
Couldn't agree more with what @bugfood wrote. Data types made alignment impractical. For complex data types (or just long names) it breaks readability by making the lines so long that you can no longer easily see what the lines are. So you may mistake the data type from the line below with the default value from the line you're reading. |
if data-types get to long, it breaks everything, right. but this is a sign for me to shorten this thing again by writing my own data-type. not really related, but a thing i do often when i stumble upon long data-types 😄 |
Also a fair point about custom data types, though if you introduce a custom data type and only use it once that's not a good experience for the module consumers. Perhaps a separate discussion. I think @bugfood said it best: we have the word
My suggestion is to keep it consistent at the file level. I love consistency, but I usually don't care beyond a single file. |
I think the 'old' style of aligning parameter is quite bad and we should stop doing this.