forked from Phobos-developers/Phobos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
200 additions
and
0 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,39 @@ | ||
--- | ||
# See all possible options and defaults with: | ||
# clang-format --style=Microsoft --dump-config | ||
BasedOnStyle: Microsoft | ||
Language: Cpp | ||
Standard: c++20 | ||
AccessModifierOffset: -4 | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BreakBeforeBinaryOperators: All | ||
BreakConstructorInitializers: BeforeColon | ||
ColumnLimit: 0 | ||
CommentPragmas: "NOLINT:.*|^ IWYU pragma:" | ||
IncludeBlocks: Regroup | ||
IndentCaseLabels: true | ||
IndentPPDirectives: AfterHash | ||
# IndentWidth: 4 | ||
SpaceAfterCStyleCast: true | ||
UseTab: Always | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveDeclarations: true | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortFunctionsOnASingleLine: None | ||
AllowShortIfStatementsOnASingleLine: true | ||
AllowShortLoopsOnASingleLine: true | ||
AllowShortLambdasOnASingleLine: Inline | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: true | ||
BreakBeforeBraces: Allman | ||
DerivePointerAlignment: false | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
NamespaceIndentation: None | ||
PointerAlignment: Left | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 |
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,71 @@ | ||
FormatStyle: file | ||
|
||
Checks: | | ||
*bugprone*, | ||
*performance*, | ||
clang-analyzer-optin.cplusplus.VirtualCall, | ||
clang-analyzer-optin.performance.Padding, | ||
cppcoreguidelines-slicing, | ||
google-explicit-constructor, | ||
misc-definitions-in-headers, | ||
misc-misplaced-const, | ||
misc-non-copyable-objects, | ||
misc-static-assert, | ||
misc-throw-by-value-catch-by-reference, | ||
misc-uniqueptr-reset-release, | ||
modernize-avoid-bind, | ||
modernize-loop-convert, | ||
modernize-make-unique, | ||
modernize-redundant-void-arg, | ||
modernize-replace-auto-ptr, | ||
modernize-replace-disallow-copy-and-assign-macro, | ||
modernize-replace-random-shuffle, | ||
modernize-shrink-to-fit, | ||
modernize-use-auto, | ||
modernize-use-bool-literals, | ||
modernize-use-default-member-init, | ||
modernize-use-emplace, | ||
modernize-use-equals-default, | ||
modernize-use-equals-delete, | ||
modernize-use-noexcept, | ||
modernize-use-nullptr, | ||
modernize-use-using, | ||
readability-avoid-const-params-in-decls, | ||
readability-const-return-type, | ||
readability-container-size-empty, | ||
readability-delete-null-pointer, | ||
readability-else-after-return, | ||
readability-inconsistent-declaration-parameter-name, | ||
readability-make-member-function-const, | ||
readability-misplaced-array-index, | ||
readability-non-const-parameter, | ||
readability-qualified-auto, | ||
readability-redundant-function-ptr-dereference, | ||
readability-redundant-smartptr-get, | ||
readability-redundant-string-cstr, | ||
readability-simplify-subscript-expr, | ||
readability-static-accessed-through-instance, | ||
readability-static-definition-in-anonymous-namespace, | ||
readability-string-compare, | ||
readability-suspicious-call-argument, | ||
readability-uniqueptr-delete-release, | ||
-bugprone-easily-swappable-parameters, | ||
-bugprone-exception-escape, | ||
-bugprone-reserved-identifier, | ||
-bugprone-unused-raii, | ||
CheckOptions: | ||
- key: modernize-use-equals-default.IgnoreMacros | ||
value: false | ||
- key: performance-for-range-copy.WarnOnAllAutoCopies | ||
value: true | ||
- key: performance-inefficient-string-concatenation.StrictMode | ||
value: true | ||
- key: performance-unnecessary-value-param.AllowedTypes | ||
value: "exception_ptr$;" | ||
- key: readability-implicit-bool-conversion.AllowPointerConditions | ||
value: true | ||
- key: readability-implicit-bool-conversion.AllowIntegerConditions | ||
value: true | ||
- key: readability-braces-around-statements.ShortStatementLines | ||
value: 2 | ||
# HeaderFilterRegex: |
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,35 @@ | ||
name: Formatting | ||
|
||
# Controls when the workflow will run | ||
on: | ||
pull_request: | ||
# Triggers the workflow on push or pull request events but only for the master and dev branch | ||
push: | ||
branches: [volkov/test-this] | ||
|
||
jobs: | ||
formatting-check: | ||
name: Format | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: Install clang-format | ||
run: | | ||
pip install clang-format \ | ||
&& clang-format --version | ||
shell: bash | ||
|
||
- name: Format files | ||
run: ${{github.workspace}}/scripts/format.sh ${{github.workspace}} y | ||
shell: bash | ||
|
||
- name: Commit changes | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
committer_name: GitHub Actions | ||
committer_email: 41898282+github-actions[bot]@users.noreply.github.com | ||
message: ":octocat: Applied clang-format." | ||
add: "*.h *.cpp" |
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,55 @@ | ||
#!/usr/bin/env bash | ||
|
||
# By Gabriel Staples | ||
# For documentation on this file, see my answer here: | ||
# [my answer] How to call clang-format over a cpp project folder?: | ||
# https://stackoverflow.com/a/65988393/4561887 | ||
|
||
# See my ans: https://stackoverflow.com/a/60157372/4561887 | ||
INPUT_PATH_TO_FILES=${1:-"./src/"} | ||
FULL_PATH_TO_SCRIPT="$(realpath "$INPUT_PATH_TO_FILES")" | ||
SCRIPT_DIRECTORY="$(dirname "$FULL_PATH_TO_SCRIPT")" | ||
|
||
RETURN_CODE_SUCCESS=0 | ||
RETURN_CODE_ERROR=1 | ||
|
||
# Find all files in SCRIPT_DIRECTORY with one of these extensions | ||
FILE_LIST="$(find "$SCRIPT_DIRECTORY" | grep -E ".*\.(ino|cpp|c|h|hpp|hh)$")" | ||
# echo "\"$FILE_LIST\"" # debugging | ||
# split into an array; see my ans: https://stackoverflow.com/a/71575442/4561887 | ||
# mapfile -t FILE_LIST_ARRAY <<< "$FILE_LIST" | ||
IFS=$'\n' read -r -d '' -a FILE_LIST_ARRAY <<< "$FILE_LIST" | ||
|
||
num_files="${#FILE_LIST_ARRAY[@]}" | ||
echo -e "$num_files files found to format:" | ||
if [ "$num_files" -eq 0 ]; then | ||
echo "Nothing to do." | ||
exit $RETURN_CODE_SUCCESS | ||
fi | ||
|
||
# print the list of all files | ||
for i in "${!FILE_LIST_ARRAY[@]}"; do | ||
file="${FILE_LIST_ARRAY["$i"]}" | ||
printf " %2i: %s\n" $((i + 1)) "$file" | ||
done | ||
echo "" | ||
|
||
format_files="false" | ||
# See: https://stackoverflow.com/a/226724/4561887 | ||
case "$2" in | ||
[Yy]* ) format_files="true" | ||
;; | ||
*) | ||
read -p "Do you wish to auto-format all of these files [y/N] " user_response | ||
case "$user_response" in | ||
[Yy]* ) format_files="true" | ||
esac | ||
esac | ||
|
||
if [ "$format_files" = "false" ]; then | ||
echo "Aborting." | ||
exit $RETURN_CODE_SUCCESS | ||
fi | ||
|
||
# Format each file. | ||
clang-format --verbose -i --style=file "${FILE_LIST_ARRAY[@]}" |