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
[docs]Update code guidelines for readability of setting table-like structures #16924
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.
Table like structures are one example of where vertical alignment is acceptable. What are the others? SQL blocks for instance would be another case.
I think this section should be explicit on where this is permitted.
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.
In general vertical alignment isn't allowed to prevent having to realign a whole block, because a longer value is added. What should be done in that case for such sections? Should the block be realigned if the longest value is removed?
The lines in the example are longer then the current maximum line length of 100 characters and I see no exception about the line length in the new section.
Actually reading the new section only tells one can add // clang-format off
and // clang-format on
, but the nothing tells that all the code guidelines (including maximum line length and no vertical alignment) do not apply for that section.
If a longer value is added, realign - no way around it. And in this special case, I think that the benefit of having this code be readable in general beats having to do one or two more
It doesn't hurt to have some examples, but I don't think it has to be exhaustive. |
981d684
to
33e5556
Compare
Fair point @Rechi I have re-drafted as a separate section and added guidance on the points you raised. @phunkyfish I could not find any SQL I would apply this to as an example, but not saying that there isn't some somewhere. I really don't think we need to be too prescriptive in these guidelines, or try to cover everything explicitly. Since we are going to apply our guidelines via Clang script, and at some point automatically update all the code base to a common standard, we need to be practical and allow for those rare situations where the code would be made less readable by such automatic formatting. Sometimes the human knows best! |
It was just the other example I could think of where you want to keep specific formatting. Example: Lines 86 to 105 in 647327b
SQL can be hard enough to decipher if complex so it's another case where vertical alignment can make it easier to read. |
Ah, SQL tastes vary @phunkyfish as does how you view that SQL. In the RDBMS itself and in debug the SQL is a single string again and the whitespace does not help at all.
But I don't know if some other whitespace checker would get upset. |
Hah, you know I didn’t even check it. I just assumed clang-format would do something funny with it! |
You know I think we should let Clang formatter lose on the codebase as a test, and carefully inspect the end results for areas that need "protection" or changes to the format (if possible). I am totaly for having an automated tool that helps maintain a common code standard, just hesitant about when we apply such a change across the codebase, and believe we need to do it intelligently. |
@DaveTBlake code guidelines are also generated from doxygen (using the same .md file). Can you compile the docs and check if the change doesn't break anything? |
…ctures to be vertical aligned and exceed line limits for readability
33e5556
to
5b8d7bd
Compare
@enen92 I don't know how to do that? |
@Rechi I have reworded again, I hope this is now sufficiently explicit. |
You just need to install doxygen and run |
@enen92 I can confirm that this change works correctly in the Doxygen generated docs, thanks for pointing out this extra check. Anyone else want to comment, otherwise I will merge this tomorrow. |
[docs]Update code guidelines for readability of setting table-like structures
Propose an update to code guidelines to allow for initialization of table-like strutures to be vertical aligned using whitespace and exceed line limits for readability. Thus option to skip Clang formating on these rare ocassions.
In the end human judgement on what is readable can be better than any set of Clang format rules.
For example
xbmc/xbmc/dialogs/GUIDialogMediaFilter.cpp
Lines 45 to 79 in 669f1b2
is more reable than after reformatting with Clang
Hence permit the use of use
// clang format off
...// clang format on
in these situations.