-
-
Notifications
You must be signed in to change notification settings - Fork 466
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
Thoughts on improving and enforcing coding style #1474
Comments
Agree on everything, except details about clang-format'ing the code: So, now, we have a very permitting mixed code style: since the original code already has mixed
This was done in 2017 with clang-format, but since then a little number of tabs could remain or even be added. It's good to check the code again.
The same. All sources were converted to UTF-8 somewhere in 2017, but it's good to check it again and even enforce that using GitHub workflow. |
@OpenXRay/xray-contributors |
So now the hard part: clang-format We could run clang-format on the entire code base but I don't think this would be a good idea the diff is absolutely massive and a lot of the original code is actually formatted in a nice readable way just in a bit of a different style. Instead I would suggest running the clang-format-diff tool on commits and pull requests which would only check lines that were actually changed. So we would only enforce our formatting rules on new code and leave the old as is. Now for the actually formatting rules there are some which I liked to at least discuss.
swtich (value)
{
case A: {
...
break;
}
} Is this intended? Also
if (x)
return; instead of if (x)
{
return;
} and also consider setting RemoveBracesLLVM which would not allow the second example.
|
Here are some general ideas to improve coding style.
Implementing these would generally be split into 2 steps.
Should be automatically handled by .gitattributes but can't hurt to check and enforce.
Not a big problem but look bad IMO ref
Not required but is kind of the convention with C/C++.
To address one problem immediately. Mass formatting commits tend to mess up the
git blame
. But fortunately for this very problem the--ignore-rev
option was created which allows you to ignore certain commits and even load these from a file.And GitHub supports this commit ignoring out of the box see this.
So all of these mass formatting commits would be added to the
.git-blame-ignore-revs
file and should not show up in the git blame. For local use you might have to set it up manually like this.git config --local blame.ignoreRevsFile ".git-blame-ignore-revs"
What are the community thoughts on this?
I have implemented all of these options in past so it shouldn't be a big problem.
The text was updated successfully, but these errors were encountered: