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

Format code with clang-format and clang-tidy #1730

Open
t43rr7 opened this issue Oct 20, 2023 · 1 comment
Open

Format code with clang-format and clang-tidy #1730

t43rr7 opened this issue Oct 20, 2023 · 1 comment

Comments

@t43rr7
Copy link

t43rr7 commented Oct 20, 2023

Introduce clang-format necessity

I want to propose using clang-format instead of (or with) astyle code formatter due astyle seems rather dead than alive. Moreover lots of IDEs has built-in clang-format, while CLion, for example has no even pluggable support of astyle. One another argument is that clang-format works better. I've tested astyle config with different styles and seems like it's not working as strictly as clang-format. For examle it ignores (T foo) and ( T foo ), same for loops indention inside brackets, allows unaligned/aligned declarations and definitions combined and so on.

I've prepared .clang-format config file which match to current astyle as pretty as possible. I believe in that this is very useful code-quality improvements that will make further development easier and more comfortable.

Here's .clang-format config:

BasedOnStyle: Microsoft
IndentCaseLabels: true
PointerAlignment: Left
IndentWidth: 4
UseTab: Never
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Left
ColumnLimit: 140
BreakBeforeTernaryOperators: true
AccessModifierOffset: -4
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveAssignments: Consecutive
LambdaBodyIndentation: Signature
BreakBeforeBraces: Allman
IndentWrappedFunctionNames: false

Introduce clang-tidy necessity

One another option to improve code quality is using naming conventions described and code quality warnings in some general config file. There's tool from clang for this purpose - clang-tidy. Maybe it could be good idea to use one.

For example, naming conventions can described with readability-identifier-naming.

More about other configurations can be found here

@tklengyel
Copy link
Owner

Sure, we can switch to clang-format. Just open a PR with the CI switching to that and the required fixes to address any of the issues it spots on the current codebase.

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

2 participants