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

Add .clang-format #8113

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ccfd38f
Add .clang-format file
vstumpf Jan 19, 2024
6daf351
Prepare repo for formatting
vstumpf Jan 19, 2024
fb680eb
Add format checker action
vstumpf Jan 19, 2024
22dc728
Apply formatting to common
vstumpf Jan 23, 2024
356d830
Move clang format
vstumpf Jan 25, 2024
28c684e
Applied formatting without changes
Lemongrass3110 Apr 5, 2024
cb56605
Increased ColumnLimit to 200 characters
Lemongrass3110 Apr 5, 2024
1623c51
Added 3rdparty regex to IncludeCategories
Lemongrass3110 Apr 5, 2024
35f2b21
Added AllowShortEnumsOnASingleLine:false
Lemongrass3110 Apr 5, 2024
792eb24
Added documentation for SpacesBeforeTrailingComments
Lemongrass3110 Apr 5, 2024
de45df2
Added AlignEscapedNewlines: DontAlign
Lemongrass3110 Apr 5, 2024
71f9fda
Added InsertBraces: true
Lemongrass3110 Apr 5, 2024
3562da1
Added AfterControlStatements: false
Lemongrass3110 Apr 5, 2024
5f6a40e
Added AfterForeachMacros: false
Lemongrass3110 Apr 5, 2024
4864c88
Added AfterFunctionDeclarationName: false
Lemongrass3110 Apr 5, 2024
6810aea
Added AfterFunctionDefinitionName: false
Lemongrass3110 Apr 5, 2024
f347dc7
Added AfterIfMacros: false
Lemongrass3110 Apr 5, 2024
5654947
Added AfterOverloadedOperator: false
Lemongrass3110 Apr 5, 2024
62bcef4
Added AfterRequiresInClause: false
Lemongrass3110 Apr 5, 2024
b3aa8d2
Added AfterRequiresInExpression: false
Lemongrass3110 Apr 5, 2024
70a3d24
Added BeforeNonEmptyParentheses: false
Lemongrass3110 Apr 5, 2024
2ef7b01
Added SpacesInParens: Custom
Lemongrass3110 Apr 5, 2024
bc9f5c5
Merge branch 'master' of https://github.com/rathena/rathena into clan…
Lemongrass3110 Apr 6, 2024
e812f53
Added version output to CI script
Lemongrass3110 Apr 6, 2024
15f18f7
Removed SpacesInParens
Lemongrass3110 Apr 10, 2024
5ea9b51
Disabled unsupported options
Lemongrass3110 Apr 10, 2024
c8c75ba
Merge branch 'master' of https://github.com/rathena/rathena into clan…
Lemongrass3110 Apr 10, 2024
72d9803
Try to update clang-format in CI
Lemongrass3110 Apr 10, 2024
5ac7c8e
SUDO!
Lemongrass3110 Apr 10, 2024
756ba00
Add spaces after control statements
vstumpf Apr 21, 2024
466ae82
Merge branch 'master' into clang-formatter
vstumpf Apr 21, 2024
dd2ac54
Set minimum clang-format version
vstumpf Jul 2, 2024
a6f8b2a
Update clang format file
vstumpf Jul 2, 2024
28aa3d4
Merge remote-tracking branch 'upstream/master' into clang-formatter
vstumpf Jul 3, 2024
14721dc
Update column limit to 120
vstumpf Jul 3, 2024
e955c5b
Apply clang-format
vstumpf Jul 3, 2024
39d43b7
Break before else
vstumpf Jul 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check format of code

on:
pull_request:
paths:
# Always trigger all Github Actions if an action or something CI related was changed
- ".github/workflows/**"
- "tools/ci/**"
- ".clang-format"
# This workflow should run when a file in a source directory has been modified.
- "src/**"

jobs:
clang-format:
# Github Actions checks for '[ci skip]', '[skip ci]', '[no ci]', '[skip actions]', or '[actions skip]' but not a hyphenated version.
# It's a catch-all incase a Pull Request has been opened and someone is on auto-pilot.
if: "!contains(github.event.head_commit.message, 'ci-skip')"
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Update & Install packages
# Ubuntu runners already have most of the packages rAthena requires to build.
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
run: |
sudo apt update
sudo apt install clang-format-15
sudo mv /usr/bin/clang-format-15 /usr/bin/clang-format
- name: Check format
run: ./tools/ci/check-format.sh
52 changes: 52 additions & 0 deletions src/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
ColumnLimit: 200
IndentWidth: 4
Language: Cpp
TabWidth: 4
UseTab: ForContinuationAndIndentation
# Replaces any whitespaces between the code and a trailing comment by a single space
SpacesBeforeTrailingComments: 1
BinPackArguments: false
BinPackParameters: false
AccessModifierOffset: -4
IndentCaseLabels: true
PointerAlignment: Left
SortIncludes: true
AlignTrailingComments: false
IndentPPDirectives: BeforeHash
# Put each enum entry into a separate line
AllowShortEnumsOnASingleLine: false
# Prevent newline alignment in Macros
AlignEscapedNewlines: DontAlign
# Add missing curly braces
InsertBraces: true
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: false
AfterForeachMacros: false
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: false
AfterOverloadedOperator: false
# Only supported by clang-format >= 15.0.0
# AfterRequiresInClause: false
# AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
IncludeCategories:
- Regex: '<config/.*h.*>'
Priority: 3
- Regex: '<(common|char|login|map)/.*h.*>'
Priority: 5
- Regex: '<(httplib.h|libconfig.h|mysql.h|nlohmann/json.hpp|pcre.h|ryml.hpp|ryml_std.hpp|yaml-cpp/yaml.h|zlib.h)>'
Priority: 4
- Regex: '<.*\.(h|hpp)>'
Priority: 2
- Regex: '<.*'
Priority: 1
- Regex: '"(common|char|login|map)/.*hpp"'
Priority: 6
...
Loading
Loading