Automated code formatter #32
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi#32
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've already seen some places where it's "tab 4x space tab", so some automated code formatter would be good.
I'm using clang-format for my own projects, which is very configurable; but something like astyle is also not bad :)
I've come up with the following
.clang-formatfile that keeps changes relatively small:AfterExternBlockwould indent after theextern "C"blocks which would match with the code inhidapi.hbut not the code in the implementations, so I would disable that wrapping. (Also, if we don't want AfterExternBlock, we can setBreakBeforeBracesto some preset that matches our style instead of defining it manually)For
IndentPPDirectives(indent preprocessor directives), there'sBeforeHashbut only in clang 9 (which should be released about September 2019) which matches the style in hidapi.For
AlignAfterOpenBracketit's also a mixed case, we can really consider changing that (so setting it toAlign= leaving the directive out)I also didn't find a clang-format option to do this (so making a preprecessor block indent the code in it):
But still with that, a bunch of formatting (especially comments it seems) has to be done manually.
I think this is something we can consider/apply for v1.0