Skip to content
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

Code formatting with clang-format #3130

Open
ghost opened this issue Apr 13, 2022 · 1 comment
Open

Code formatting with clang-format #3130

ghost opened this issue Apr 13, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 13, 2022

Is your feature request related to a problem? Please describe.

We are all aware of how hercules source code doesn't follow a consistent code style format, because it is old and lots of people already contributed to it. But now we are already in 2022 and we have plenty of tools to make formatting easier, so my suggestion is that we add clang-format to hercules source, or at very least apply it once.

You can get an idea of how the changes will look like here in this commit:
5a39285#diff-883d0abbee797807e33ccba4fe4d012fe04c286b2c231270e212116b07276ac9

Describe the solution you'd like

clang-format

Suggested configuration

(most similar of what our code already looks like)

# Format Style Options - Created with Clang Power Tools
---
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignEscapedNewlines: DontAlign
AllowShortCaseLabelsOnASingleLine: true
BreakBeforeBraces: Mozilla
BreakConstructorInitializers: AfterColon
BreakStringLiterals: false
ColumnLimit: 120
IndentWidth: 4
TabWidth: 4
UseTab: ForIndentation
...

Of course it needs to be fine tuned, for example:

  • add clang-format to github workflows
  • ignoring 3rdparty folder
  • review #define and #pragma changes (they are 99% likely to be wrong and break compilation)

but yeah, code looks fine after all these changes

@ghost
Copy link
Author

ghost commented Apr 15, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants