-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This introduces clang-format to enforce a consistent code style for Stockfish. The lack of an automated code formatter has been a long standing issue #3608. This PR includes a Makefile target to format the code accordingly and write a comment on the PR on GitHub if any formatting changes are required. closes #3608 Co-Authored-By: Joost VandeVondele <[email protected]>
- Loading branch information
Showing
49 changed files
with
6,964 additions
and
6,757 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
AccessModifierOffset: -1 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: Consecutive | ||
AlignConsecutiveDeclarations: Consecutive | ||
AlignEscapedNewlines: DontAlign | ||
AlignOperands: AlignAfterOperator | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortEnumsOnASingleLine: false | ||
AllowShortIfStatementsOnASingleLine: false | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BasedOnStyle: WebKit | ||
BitFieldColonSpacing: After | ||
BinPackParameters: false | ||
BreakBeforeBinaryOperators: NonAssignment | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterFunction: false | ||
AfterClass: false | ||
AfterControlStatement: true | ||
BeforeElse: true | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializers: AfterColon | ||
BreakStringLiterals: false | ||
ColumnLimit: 100 | ||
ContinuationIndentWidth: 2 | ||
Cpp11BracedListStyle: true | ||
IndentGotoLabels: false | ||
IndentPPDirectives: BeforeHash | ||
IndentWidth: 4 | ||
MaxEmptyLinesToKeep: 2 | ||
NamespaceIndentation: None | ||
PackConstructorInitializers: Never | ||
ReflowComments: false | ||
SortIncludes: false | ||
SortUsingDeclarations: false | ||
SpaceAfterCStyleCast: true | ||
SpaceAfterTemplateKeyword: false | ||
SpaceBeforeCaseColon: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeInheritanceColon: false | ||
SpaceInEmptyBlock: false | ||
SpacesBeforeTrailingComments: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# This workflow will run clang-format and comment on the PR. | ||
# Because of security reasons, it is crucial that this workflow | ||
# executes no shell script nor runs make. | ||
# Read this before editing: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | ||
|
||
name: Stockfish | ||
on: | ||
pull_request_target: | ||
branches: | ||
- 'master' | ||
paths: | ||
- '**.cpp' | ||
- '**.h' | ||
jobs: | ||
Stockfish: | ||
name: clang-format check | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Run clang-format style check | ||
uses: jidicula/[email protected] | ||
id: clang-format | ||
continue-on-error: true | ||
with: | ||
clang-format-version: '17' | ||
exclude-regex: 'incbin' | ||
|
||
- name: Comment on PR | ||
if: steps.clang-format.outcome == 'failure' | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
message: | | ||
clang-format 17 needs to be run on this PR. | ||
If you do not have clang-format installed, the maintainer will run it when merging. | ||
For the exact version please see https://packages.ubuntu.com/mantic/clang-format-17. | ||
_(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_ | ||
comment_tag: execution | ||
|
||
- name: Comment on PR | ||
if: steps.clang-format.outcome != 'failure' | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
message: | | ||
_(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_ | ||
create_if_not_exists: false | ||
comment_tag: execution | ||
mode: delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.