Skip to content

Commit bf3ff3c

Browse files
committed
Add C++ auto formatting
Signed-off-by: Tim Paine <[email protected]>
1 parent 7ea2a7b commit bf3ff3c

File tree

276 files changed

+18290
-16595
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

276 files changed

+18290
-16595
lines changed

Makefile

+3-6
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@ 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/csp -type f -name "*.cpp" -o -name "*.h"`
4544

4645
lint-docs:
4746
python -m mdformat --check docs/wiki/ README.md examples/
4847
python -m codespell_lib docs/wiki/ README.md examples/ --skip "*.cpp,*.h"
4948

50-
# lint: lint-py lint-cpp ## run lints
51-
lint: lint-py lint-docs ## run lints
49+
lint: lint-py lint-cpp lint-docs ## run lints
5250

5351
# Alias
5452
lints: lint
@@ -58,8 +56,7 @@ fix-py:
5856
python -m ruff format csp/ examples/ setup.py
5957

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

6461
fix-docs:
6562
python -m mdformat docs/wiki/ README.md examples/

conda/dev-environment-unix.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ dependencies:
66
- bison
77
- brotli
88
- bump-my-version
9+
- clang-format
910
- cmake
1011
- codespell>=2.2.6,<2.3
1112
- compilers

conda/dev-environment-win.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ channels:
55
dependencies:
66
- brotli
77
- bump-my-version
8+
- clang-format
89
- cmake
910
- codespell>=2.2.6,<2.3
1011
- compilers

cpp/.clang-format

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

0 commit comments

Comments
 (0)