Address review: update .clang-format for short expressions on one line

Updated .clang-format to minimize diffs with develop by enabling
AllowShort* options (blocks, case labels, enums, if statements, loops)
and adding IfMacros/SpaceBeforeParens settings so SECTION() blocks
stay on one line. Added PackConstructorInitializers: CurrentLine.
Re-ran clang-format-19 on all source files with the new config.

Note: AllowShortEnumsOnASingleLine and PackConstructorInitializers
do not take effect with ColumnLimit: 0 (a known clang-format
limitation), so a few short enums and constructor initializers in
tests are still expanded.

Requested by @lefticus in PR #691 review.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
leftibot 2026-04-15 17:16:01 -06:00
parent 4ce9577654
commit 7c5e4b264f
4 changed files with 174 additions and 362 deletions

View File

@ -1,10 +1,14 @@
# clang-format: 11
# clang-format: 19
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveBitFields: false
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakTemplateDeclarations: true
BasedOnStyle: WebKit
BinPackArguments: true
@ -13,12 +17,14 @@ BreakBeforeBraces: Attach
ColumnLimit: 0
Cpp11BracedListStyle: true
FixNamespaceComments: true
IfMacros: ['SECTION']
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: All
PackConstructorInitializers: CurrentLine
PenaltyBreakBeforeFirstCallParameter: 200
PenaltyBreakComment: 5
PenaltyBreakFirstLessLess: 50
@ -27,7 +33,11 @@ PointerAlignment: Right
SortIncludes: true
SpaceAfterTemplateKeyword: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterIfMacros: false
SpaceInEmptyBlock: false
Standard: Latest
TabWidth: 2
UseTab: Never
UseTab: Never

File diff suppressed because it is too large Load Diff

View File

@ -1762,9 +1762,7 @@ TEST_CASE("push_back on script vector with vector_conversion") {
chai.add(chaiscript::fun([](const std::vector<std::string> &v) -> std::string {
std::string result;
for (const auto &s : v) {
if (!result.empty()) {
result += ",";
}
if (!result.empty()) { result += ","; }
result += s;
}
return result;
@ -2061,14 +2059,10 @@ TEST_CASE("Multiple C++ exception types from registered functions") {
chai.add(chaiscript::fun([](int which) -> int {
switch (which) {
case 0:
throw std::runtime_error("runtime");
case 1:
throw std::out_of_range("range");
case 2:
throw std::logic_error("logic");
default:
return which;
case 0: throw std::runtime_error("runtime");
case 1: throw std::out_of_range("range");
case 2: throw std::logic_error("logic");
default: return which;
}
}),
"cpp_multi_throw");
@ -2127,9 +2121,7 @@ TEST_CASE("Exception from C++ [] operator is catchable in ChaiScript") {
chai.add(chaiscript::user_type<IndexableType>(), "IndexableType");
chai.add(chaiscript::constructor<IndexableType(int)>(), "IndexableType");
chai.add(chaiscript::fun([](const IndexableType &, int idx) -> int {
if (idx < 0) {
throw std::out_of_range("negative index");
}
if (idx < 0) { throw std::out_of_range("negative index"); }
return idx;
}),
"[]");

View File

@ -31,30 +31,14 @@ TEST_CASE("Type_Info objects generate expected results") {
CHECK(ti.is_arithmetic() == t_is_arithmetic);
};
SECTION("void") {
test_type(chaiscript::user_type<void>(), false, false, false, true, false, false);
}
SECTION("const int") {
test_type(chaiscript::user_type<const int>(), true, false, false, false, false, true);
}
SECTION("const int &") {
test_type(chaiscript::user_type<const int &>(), true, false, true, false, false, true);
}
SECTION("int") {
test_type(chaiscript::user_type<int>(), false, false, false, false, false, true);
}
SECTION("int *") {
test_type(chaiscript::user_type<int *>(), false, true, false, false, false, false);
}
SECTION("const int *") {
test_type(chaiscript::user_type<const int *>(), true, true, false, false, false, false);
}
SECTION("const bool &") {
test_type(chaiscript::user_type<const bool &>(), true, false, true, false, false, false);
}
SECTION("default") {
test_type(chaiscript::Type_Info(), false, false, false, false, true, false);
}
SECTION("void") { test_type(chaiscript::user_type<void>(), false, false, false, true, false, false); }
SECTION("const int") { test_type(chaiscript::user_type<const int>(), true, false, false, false, false, true); }
SECTION("const int &") { test_type(chaiscript::user_type<const int &>(), true, false, true, false, false, true); }
SECTION("int") { test_type(chaiscript::user_type<int>(), false, false, false, false, false, true); }
SECTION("int *") { test_type(chaiscript::user_type<int *>(), false, true, false, false, false, false); }
SECTION("const int *") { test_type(chaiscript::user_type<const int *>(), true, true, false, false, false, false); }
SECTION("const bool &") { test_type(chaiscript::user_type<const bool &>(), true, false, true, false, false, false); }
SECTION("default") { test_type(chaiscript::Type_Info(), false, false, false, false, true, false); }
std::cout << "Size of Type_Info " << sizeof(chaiscript::Type_Info) << '\n';
}