Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Format unicode_common #13
Format unicode_common #13
Changes from 7 commits
ae25652
bcafc3b
e6d9692
871169a
415d12a
fdded5c
09dbc0c
3e22b6a
2c9cfc4
3f7cd36
b55f059
408ec5f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I know this is proper, but I hate it because of the readability (lack thereof)
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.
(Assuming you're referring to the
case
indentation) I actually disagree 😄 In QMK's case we have 2-space indents, but in projects where indentation is the standard 4 spaces or a tab, the extra indentation from cases (which bears no semantic meaning, as cases are just jump labels) can harm readability by adding another indentation level and shifting code horizontally.To quote Linus Torvalds: “If you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.”
And I'd rather not waste one of those levels on
case
labels 😄But regardless of what we agree to go with, we should make sure we're consistent with it across all Unicode files:
process_unicode_common.c
,process_unicode.c
,process_unicodemap.c
,process_ucis.c
.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.
The reason why I prefer preprocessor ifs (and preprocessor directives in general) to have their own separate indentation levels is that they aren't part of the program logic. They just pick & choose which parts of the code get compiled and which don't; they aren't runtime checks. Therefore, they shouldn't affect the indentation of the actual code.
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.
Yeah, I definitely understand that. However, .... I think we need a clear and concise rule about this, because you can see three different formats throughout the code.
Also, this looks cleaner.
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.
Right now the tally for preprocessor directives before code in core QMK is:
1209 matches across 154 files
for directives at start of line (grepped for^#.+\n +[^#]
);651 matches across 45 files
for indented directives (grepped for^ +#.+\n +[^#]
).I agree that there should be a hard rule for it for any new code, as well as for the
case
indentation stuff (that's also done both ways in the codebase).