diff --git a/.clang-format b/.clang-format index b5891be0a1..2580761a88 100644 --- a/.clang-format +++ b/.clang-format @@ -2,13 +2,13 @@ Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: DontAlign -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false +AlignConsecutiveAssignments: None +AlignConsecutiveDeclarations: None AlignEscapedNewlines: Right AlignOperands: false AlignTrailingComments: false AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false +AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: Inline AllowShortIfStatementsOnASingleLine: false @@ -83,7 +83,7 @@ PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left ReflowComments: true -SortIncludes: true +SortIncludes: CaseSensitive SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterTemplateKeyword: true diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 400db26dc5..c3e22b8412 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -15,3 +15,5 @@ # Date: 9/22/2022 9:26:05 PM # Apply clang-format to code base ddb0522bbf2aa8aa7c9e139ff7395fb8ed6a841f + +88ec8a95231341e7962b85716510d414e9f0c424 diff --git a/CI/check_clang_format.sh b/CI/check_clang_format.sh index 109849a98a..3acb7a5c72 100755 --- a/CI/check_clang_format.sh +++ b/CI/check_clang_format.sh @@ -1,33 +1,10 @@ -#!/bin/bash +#!/bin/bash -ex + +set -o pipefail CLANG_FORMAT="${CLANG_FORMAT:-clang-format}" -HAS_DIFFS=0 - -check_format_file() { - local item=$1 - "$CLANG_FORMAT" --dry-run -Werror "$item" &>/dev/null - if [[ $? = 1 ]]; then - "${CLANG_FORMAT}" "${item}" | git diff --color=always --no-index "${item}" - - HAS_DIFFS=1 - fi -} - -check_format() { - local path=$1 - find "$path" -type f -name "*" | while read item; - do - if [[ "$item" =~ .*\.(cpp|hpp|h) ]]; then - check_format_file "$item" - fi; - done; -} - -check_format "./apps" -check_format "./components" - -if [[ $HAS_DIFFS -eq 1 ]]; then - echo "clang-format differences detected" - exit 1 -fi; - -exit 0 \ No newline at end of file +git ls-files | + grep -v '^extern/' | + grep -P '\.(cpp|hpp|h)$' | + xargs -I '{}' -P $(nproc) bash -ec "\"${CLANG_FORMAT:?}\" --dry-run -Werror \"\${0:?}\" &> /dev/null || \"${CLANG_FORMAT:?}\" \"\${0:?}\" | git diff --color=always --no-index \"\${0:?}\" -" '{}' || + ( echo "clang-format differences detected"; exit -1 ) diff --git a/apps/opencs/model/world/infocollection.hpp b/apps/opencs/model/world/infocollection.hpp index 1f745dc84d..4174d5f15c 100644 --- a/apps/opencs/model/world/infocollection.hpp +++ b/apps/opencs/model/world/infocollection.hpp @@ -56,7 +56,10 @@ namespace CSMWorld /// Works like getAppendIndex unless an overloaded method uses the record pointer /// to get additional info about the record that results in an alternative index. - int getAppendIndex (const std::string& id, UniversalId::Type type) const override { return getInsertIndex(id, type); } + int getAppendIndex(const std::string& id, UniversalId::Type type) const override + { + return getInsertIndex(id, type); + } bool reorderRows(int baseIndex, const std::vector& newOrder) override; ///< Reorder the rows [baseIndex, baseIndex+newOrder.size()) according to the indices diff --git a/components/debug/debugging.cpp b/components/debug/debugging.cpp index 017d73a177..cfd3b75ba2 100644 --- a/components/debug/debugging.cpp +++ b/components/debug/debugging.cpp @@ -165,7 +165,10 @@ namespace Debug CurrentDebugLevel = Verbose; } - virtual std::streamsize writeImpl(const char* str, std::streamsize size, Level debugLevel) { return size; } + virtual std::streamsize writeImpl(const char* str, std::streamsize size, Level debugLevel) + { + return size; + } }; #if defined _WIN32 && defined _DEBUG