Skip to content

Commit 30f704e

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

File tree

276 files changed

+18270
-16576
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

+18270
-16576
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

+68
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: Inline
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)