thestr4ng3r / chiaki

Moved to https://git.sr.ht/~thestr4ng3r/chiaki - Free and Open Source PS4 Remote Play Client
https://git.sr.ht/~thestr4ng3r/chiaki
2.19k stars 370 forks source link

[Proposal] Use clang-format to control or enforce the coding style rules #410

Open H0neyBadger opened 3 years ago

H0neyBadger commented 3 years ago

What platform does your feature request apply to? all (except android maybe)

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

Describe the solution you'd like use automated tools to fix or control PR

Describe alternatives you've considered N/A

Additional context Hello, Please find bellow a possible .clang-format daft for chiaki

# https://clang.llvm.org/docs/ClangFormat.html
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
UseTab: Always
IndentWidth: 4
TabWidth: 4
# to be determined
AlignAfterOpenBracket: Align
# offset of private:, public: ... in class
# AccessModifierOffset: 0 is not very well
# integrated with tab indent (to be determined)
AccessModifierOffset: 0
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
# to be determined (0 = unlimited)
ColumnLimit: 80
# int * example;
PointerAlignment: Middle
# 'include' reordering might break the code
IncludeCategories:
  - Regex: '^<chiaki/.*\.h>'
    Priority: 2
  - Regex: '^<.*\.h>'
    Priority: 1
  - Regex: '^<.*'
    Priority: 2
  - Regex: '.*'
    Priority: 3
SortIncludes: 'true'
Standard: Cpp11
H0neyBadger commented 3 years ago

just a quick update : I added the SpaceBeforeParens: Never , AlignAfterOpenBracket: DontAlign and ColumnLimit: 0 to better match the current style. I'm currently testing the vim extension and the clang-format-diff.py from (clang-tools-extra-11.0.0-2.fc33.x86_64).

git diff -U0 --no-color HEAD^ | python3 /usr/share/clang/clang-format-diff.py -i -p1

I will check possible integration with the github actions.

---
# https://clang.llvm.org/docs/ClangFormat.html
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
UseTab: Always
IndentWidth: 4
TabWidth: 4
SpaceBeforeParens: Never
AlignAfterOpenBracket: DontAlign
# offset of private:, public: ... in class
# AccessModifierOffset: 0 is not very well
# integreted with tab indent
AccessModifierOffset: 0
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
# to be determined
ColumnLimit: 0
# int * example;
PointerAlignment: Middle
IncludeCategories:
  - Regex: '^<chiaki/.*\.h>'
    Priority: 2
  - Regex: '^<.*\.h>'
    Priority: 1
  - Regex: '^<.*'
    Priority: 2
  - Regex: '.*'
    Priority: 3
SortIncludes: 'true'
Standard: Cpp11
...