Skip to content

Commit bc69b0d

Browse files
committed
Reformat code (and add make target to do so)
1 parent 35a993d commit bc69b0d

28 files changed

+3071
-2839
lines changed

.clang-format

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
AccessModifierOffset: -1
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlines: Left
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: true
14+
AllowShortFunctionsOnASingleLine: Empty
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterDefinitionReturnType: None
18+
AlwaysBreakAfterReturnType: None
19+
AlwaysBreakBeforeMultilineStrings: true
20+
AlwaysBreakTemplateDeclarations: true
21+
BinPackArguments: false
22+
BinPackParameters: true
23+
BreakBeforeBinaryOperators: None
24+
BreakBeforeBraces: WebKit
25+
BreakBeforeInheritanceComma: false
26+
BreakBeforeTernaryOperators: true
27+
BreakConstructorInitializersBeforeComma: false
28+
BreakConstructorInitializers: BeforeColon
29+
BreakStringLiterals: true
30+
ColumnLimit: 100
31+
CommentPragmas: '^[*]* [@\\]'
32+
CompactNamespaces: false
33+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
34+
ConstructorInitializerIndentWidth: 4
35+
ContinuationIndentWidth: 4
36+
Cpp11BracedListStyle: true
37+
DerivePointerAlignment: true
38+
DisableFormat: false
39+
ExperimentalAutoDetectBinPacking: false
40+
FixNamespaceComments: true
41+
IncludeCategories:
42+
- Regex: '^<.*\.h>'
43+
Priority: 1
44+
- Regex: '^<.*'
45+
Priority: 2
46+
- Regex: '.*'
47+
Priority: 3
48+
IncludeIsMainRegex: '([-_](test|unittest))?$'
49+
IndentCaseLabels: true
50+
IndentWidth: 4
51+
IndentWrappedFunctionNames: false
52+
JavaScriptQuotes: Leave
53+
JavaScriptWrapImports: true
54+
KeepEmptyLinesAtTheStartOfBlocks: false
55+
MacroBlockBegin: '^TRY$'
56+
MacroBlockEnd: '^CATCH$'
57+
MaxEmptyLinesToKeep: 1
58+
NamespaceIndentation: None
59+
PenaltyBreakAssignment: 2
60+
PenaltyBreakBeforeFirstCallParameter: 1
61+
PenaltyBreakComment: 300
62+
PenaltyBreakFirstLessLess: 120
63+
PenaltyBreakString: 1000
64+
PenaltyExcessCharacter: 1000000
65+
PenaltyReturnTypeOnItsOwnLine: 200
66+
PointerAlignment: Left
67+
ReflowComments: true
68+
SortIncludes: true
69+
SortUsingDeclarations: true
70+
SpaceAfterCStyleCast: false
71+
SpaceAfterTemplateKeyword: true
72+
SpaceBeforeAssignmentOperators: true
73+
SpaceBeforeParens: ControlStatements
74+
SpaceInEmptyParentheses: false
75+
SpacesBeforeTrailingComments: 2
76+
SpacesInAngles: false
77+
SpacesInContainerLiterals: true
78+
SpacesInCStyleCastParentheses: false
79+
SpacesInParentheses: false
80+
SpacesInSquareBrackets: false
81+
Standard: Auto
82+
TabWidth: 8
83+
UseTab: Never
84+
...
85+

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ test: jsonnet libjsonnet.so libjsonnet_test_snippet libjsonnet_test_file
102102
cd test_suite ; ./run_fmt_tests.sh
103103
cd test_suite ; ./run_fmt_idempotence_tests.sh
104104

105+
reformat:
106+
clang-format -i -style=file **/*.cpp **/*.h
107+
108+
test-formatting:
109+
test "`clang-format -style=file -output-replacements-xml **/*.cpp **/*.h | grep -c "<replacement "`" == 0
110+
105111
MAKEDEPEND_SRCS = \
106112
cmd/jsonnet.cpp \
107113
core/libjsonnet_test_snippet.c \
@@ -167,3 +173,5 @@ clean:
167173
rm -vf */*~ *~ .*~ */.*.swp .*.swp $(ALL) *.o core/*.jsonnet.h Makefile.depend
168174

169175
-include Makefile.depend
176+
177+
.PHONY: default all depend clean reformat test test-formatting

0 commit comments

Comments
 (0)