Skip to content

Commit cca3466

Browse files
committed
add c++ autoformatting
Signed-off-by: Tim Paine <[email protected]>
1 parent 323122e commit cca3466

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ lint-py:
4040
python -m ruff format --check csp/ examples/ setup.py
4141

4242
lint-cpp:
43-
# clang-format --dry-run -Werror -i -style=file `find ./cpp/ -name "*.*pp"`
44-
echo "C++ linting disabled for now"
43+
clang-format --dry-run -Werror -i -style=file `find ./cpp/ -type f -name "*.cpp" -o -name "*.h"`
4544

4645
lint-docs:
4746
python -m mdformat --check docs/wiki/ README.md examples/
@@ -58,8 +57,7 @@ fix-py:
5857
python -m ruff format csp/ examples/ setup.py
5958

6059
fix-cpp:
61-
# clang-format -i -style=file `find ./cpp/ -name "*.*pp"`
62-
echo "C++ autoformatting disabled for now"
60+
clang-format -i -style=file `find ./cpp/ -type f -name "*.cpp" -o -name "*.h"`
6361

6462
fix-docs:
6563
python -m mdformat docs/wiki/ README.md examples/

cpp/.clang-format

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: true
6+
AlignEscapedNewlinesLeft: false
7+
AlignOperands: false
8+
AlignTrailingComments: true
9+
AllowAllParametersOfDeclarationOnNextLine: true
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: All
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterDefinitionReturnType: false
16+
AlwaysBreakBeforeMultilineStrings: false
17+
AlwaysBreakTemplateDeclarations: true
18+
BinPackArguments: true
19+
BinPackParameters: true
20+
BraceWrapping:
21+
BeforeElse: true
22+
BreakBeforeBinaryOperators: All
23+
BreakBeforeBraces: Allman
24+
BreakBeforeTernaryOperators: true
25+
BreakConstructorInitializersBeforeComma: true
26+
ColumnLimit: 120
27+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
28+
ConstructorInitializerIndentWidth: 4
29+
ContinuationIndentWidth: 4
30+
Cpp11BracedListStyle: true
31+
DerivePointerAlignment: false
32+
DisableFormat: false
33+
ExperimentalAutoDetectBinPacking: false
34+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
35+
IndentCaseLabels: true
36+
IndentWidth: 4
37+
IndentWrappedFunctionNames: false
38+
KeepEmptyLinesAtTheStartOfBlocks: true
39+
MacroBlockBegin: ''
40+
MacroBlockEnd: ''
41+
MaxEmptyLinesToKeep: 1
42+
NamespaceIndentation: Inner
43+
ObjCBlockIndentWidth: 4
44+
ObjCSpaceAfterProperty: true
45+
ObjCSpaceBeforeProtocolList: true
46+
PenaltyBreakBeforeFirstCallParameter: 19
47+
PenaltyBreakComment: 300
48+
PenaltyBreakFirstLessLess: 120
49+
PenaltyBreakString: 1000
50+
PenaltyExcessCharacter: 1000000
51+
PenaltyReturnTypeOnItsOwnLine: 60
52+
PointerAlignment: Middle
53+
SortIncludes: CaseInsensitive
54+
SortUsingDeclarations: true
55+
SpaceAfterCStyleCast: false
56+
SpaceAfterTemplateKeyword: false
57+
SpaceBeforeAssignmentOperators: true
58+
SpaceBeforeParens: false
59+
SpaceInEmptyParentheses: false
60+
SpacesBeforeTrailingComments: 1
61+
SpacesInAngles: false
62+
SpacesInContainerLiterals: true
63+
SpacesInCStyleCastParentheses: false
64+
SpacesInParentheses: true
65+
SpacesInSquareBrackets: false
66+
Standard: Cpp11
67+
TabWidth: 4
68+
UseTab: Never

0 commit comments

Comments
 (0)