Skip to content

Commit a790a9e

Browse files
authored
Add clang-format enforcement
1 parent eef150f commit a790a9e

Some content is hidden

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

69 files changed

+1680
-1566
lines changed

.clang-format

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
---
2+
Language: Proto
3+
BasedOnStyle: Google
4+
---
5+
Language: Cpp
6+
# BasedOnStyle: Google
7+
AccessModifierOffset: -1
8+
AlignAfterOpenBracket: Align
9+
AlignArrayOfStructures: None
10+
AlignConsecutiveAssignments: Consecutive
11+
AlignConsecutiveBitFields: None
12+
AlignConsecutiveDeclarations: None
13+
AlignEscapedNewlines: Left
14+
AlignOperands: Align
15+
AlignTrailingComments: true
16+
AllowAllArgumentsOnNextLine: true
17+
AllowAllConstructorInitializersOnNextLine: true
18+
AllowAllParametersOfDeclarationOnNextLine: true
19+
AllowShortEnumsOnASingleLine: true
20+
AllowShortBlocksOnASingleLine: Never
21+
AllowShortCaseLabelsOnASingleLine: false
22+
AllowShortFunctionsOnASingleLine: All
23+
AllowShortLambdasOnASingleLine: All
24+
AllowShortIfStatementsOnASingleLine: WithoutElse
25+
AllowShortLoopsOnASingleLine: true
26+
AlwaysBreakAfterDefinitionReturnType: None
27+
AlwaysBreakAfterReturnType: None
28+
AlwaysBreakBeforeMultilineStrings: true
29+
AlwaysBreakTemplateDeclarations: Yes
30+
AttributeMacros:
31+
- __capability
32+
BinPackArguments: false
33+
BinPackParameters: false
34+
BraceWrapping:
35+
AfterCaseLabel: false
36+
AfterClass: false
37+
AfterControlStatement: Never
38+
AfterEnum: false
39+
AfterFunction: false
40+
AfterNamespace: false
41+
AfterObjCDeclaration: false
42+
AfterStruct: false
43+
AfterUnion: false
44+
AfterExternBlock: false
45+
BeforeCatch: false
46+
BeforeElse: false
47+
BeforeLambdaBody: false
48+
BeforeWhile: false
49+
IndentBraces: false
50+
SplitEmptyFunction: true
51+
SplitEmptyRecord: true
52+
SplitEmptyNamespace: true
53+
BreakBeforeBinaryOperators: None
54+
BreakBeforeConceptDeclarations: true
55+
BreakBeforeBraces: Linux
56+
BreakBeforeInheritanceComma: false
57+
BreakInheritanceList: BeforeColon
58+
BreakBeforeTernaryOperators: true
59+
BreakConstructorInitializersBeforeComma: true
60+
BreakConstructorInitializers: BeforeColon
61+
BreakAfterJavaFieldAnnotations: false
62+
BreakStringLiterals: true
63+
ColumnLimit: 100
64+
CommentPragmas: '^ IWYU pragma:'
65+
CompactNamespaces: false
66+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
67+
ConstructorInitializerIndentWidth: 4
68+
ContinuationIndentWidth: 4
69+
Cpp11BracedListStyle: true
70+
DeriveLineEnding: true
71+
DerivePointerAlignment: false
72+
DisableFormat: false
73+
EmptyLineAfterAccessModifier: Never
74+
EmptyLineBeforeAccessModifier: LogicalBlock
75+
ExperimentalAutoDetectBinPacking: false
76+
FixNamespaceComments: true
77+
AlignConsecutiveMacros: true
78+
ForEachMacros:
79+
- foreach
80+
- Q_FOREACH
81+
- BOOST_FOREACH
82+
IfMacros:
83+
- KJ_IF_MAYBE
84+
IncludeBlocks: Regroup
85+
IncludeCategories:
86+
- Regex: '^<ext/.*\.h>'
87+
Priority: 2
88+
SortPriority: 0
89+
CaseSensitive: false
90+
- Regex: '^<.*\.h>'
91+
Priority: 1
92+
SortPriority: 0
93+
CaseSensitive: false
94+
- Regex: '^<.*'
95+
Priority: 2
96+
SortPriority: 0
97+
CaseSensitive: false
98+
- Regex: '.*'
99+
Priority: 3
100+
SortPriority: 0
101+
CaseSensitive: false
102+
IncludeIsMainRegex: '([-_](test|unittest))?$'
103+
IncludeIsMainSourceRegex: ''
104+
IndentAccessModifiers: false
105+
IndentCaseLabels: true
106+
IndentCaseBlocks: false
107+
IndentGotoLabels: true
108+
IndentPPDirectives: None
109+
IndentExternBlock: AfterExternBlock
110+
IndentRequires: false
111+
IndentWidth: 4
112+
IndentWrappedFunctionNames: false
113+
InsertTrailingCommas: None
114+
JavaScriptQuotes: Leave
115+
JavaScriptWrapImports: true
116+
KeepEmptyLinesAtTheStartOfBlocks: false
117+
LambdaBodyIndentation: Signature
118+
MacroBlockBegin: ''
119+
MacroBlockEnd: ''
120+
MaxEmptyLinesToKeep: 1
121+
NamespaceIndentation: None
122+
ObjCBinPackProtocolList: Never
123+
ObjCBlockIndentWidth: 2
124+
ObjCBreakBeforeNestedBlockParam: true
125+
ObjCSpaceAfterProperty: false
126+
ObjCSpaceBeforeProtocolList: true
127+
PenaltyBreakAssignment: 2
128+
PenaltyBreakBeforeFirstCallParameter: 1
129+
PenaltyBreakComment: 300
130+
PenaltyBreakFirstLessLess: 120
131+
PenaltyBreakString: 1000
132+
PenaltyBreakTemplateDeclaration: 10
133+
PenaltyExcessCharacter: 1000000
134+
PenaltyReturnTypeOnItsOwnLine: 200
135+
PenaltyIndentedWhitespace: 0
136+
PointerAlignment: Left
137+
PPIndentWidth: -1
138+
RawStringFormats:
139+
- Language: Cpp
140+
Delimiters:
141+
- cc
142+
- CC
143+
- cpp
144+
- Cpp
145+
- CPP
146+
- 'c++'
147+
- 'C++'
148+
CanonicalDelimiter: ''
149+
BasedOnStyle: google
150+
- Language: TextProto
151+
Delimiters:
152+
- pb
153+
- PB
154+
- proto
155+
- PROTO
156+
EnclosingFunctions:
157+
- EqualsProto
158+
- EquivToProto
159+
- PARSE_PARTIAL_TEXT_PROTO
160+
- PARSE_TEST_PROTO
161+
- PARSE_TEXT_PROTO
162+
- ParseTextOrDie
163+
- ParseTextProtoOrDie
164+
- ParseTestProto
165+
- ParsePartialTestProto
166+
CanonicalDelimiter: pb
167+
BasedOnStyle: google
168+
ReferenceAlignment: Pointer
169+
ReflowComments: true
170+
ShortNamespaceLines: 1
171+
172+
# CaseSensitive breaks with Protobuf for some reason
173+
# we just disable this rule for now
174+
# SortIncludes: CaseSensitive
175+
SortIncludes: false
176+
177+
SortJavaStaticImport: Before
178+
SortUsingDeclarations: true
179+
SpaceAfterCStyleCast: false
180+
SpaceAfterLogicalNot: false
181+
SpaceAfterTemplateKeyword: true
182+
SpaceBeforeAssignmentOperators: true
183+
SpaceBeforeCaseColon: false
184+
SpaceBeforeCpp11BracedList: false
185+
SpaceBeforeCtorInitializerColon: true
186+
SpaceBeforeInheritanceColon: true
187+
SpaceBeforeParens: ControlStatements
188+
SpaceAroundPointerQualifiers: Default
189+
SpaceBeforeRangeBasedForLoopColon: true
190+
SpaceInEmptyBlock: false
191+
SpaceInEmptyParentheses: false
192+
SpacesBeforeTrailingComments: 2
193+
SpacesInAngles: Always
194+
SpacesInConditionalStatement: false
195+
SpacesInContainerLiterals: true
196+
SpacesInCStyleCastParentheses: false
197+
SpacesInLineCommentPrefix:
198+
Minimum: 1
199+
Maximum: -1
200+
SpacesInParentheses: false
201+
SpacesInSquareBrackets: false
202+
SpaceBeforeSquareBrackets: false
203+
BitFieldColonSpacing: Both
204+
Standard: Auto
205+
StatementAttributeLikeMacros:
206+
- Q_EMIT
207+
StatementMacros:
208+
- Q_UNUSED
209+
- QT_REQUIRE_VERSION
210+
TabWidth: 8
211+
UseCRLF: false
212+
UseTab: Never
213+
214+
# This needed feature is broken on clang-format version 14.0.0
215+
# https://github.com/llvm/llvm-project/issues/54522
216+
# Use version 13.0.1.1 to make it work correctly
217+
WhitespaceSensitiveMacros:
218+
- STRINGIZE
219+
- PP_STRINGIZE
220+
- BOOST_PP_STRINGIZE
221+
- NS_SWIFT_NAME
222+
- CF_SWIFT_NAME
223+
- ENABLE_WARNING
224+
- DISABLE_WARNING
225+
...
226+

.github/workflows/pr.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,18 @@ jobs:
4646
# so your job can access it
4747
- uses: actions/checkout@v2
4848
- uses: luisremis/find-trailing-whitespace@master
49+
50+
formatting-check:
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
55+
- uses: actions/checkout@v2
56+
- name: Run clang-format style check for C/C++/Protobuf programs.
57+
uses: jidicula/[email protected]
58+
with:
59+
clang-format-version: '13'
60+
# This will recursively check the paths
61+
check-path: '.'
62+
# Google format is what we use as based for our .clang-format
63+
fallback-style: 'Google'

include/aperturedb/Exception.h

Lines changed: 57 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -32,68 +32,62 @@
3232

3333
#include <string>
3434

35-
namespace VDMS {
36-
37-
enum ExceptionType {
38-
FATAL_Internal_Error,
39-
40-
WriteFail, // For write/send failure
41-
ReadFail, // For read/recv failure
42-
BindFail, // Fail to bind a port
43-
SocketFail,
44-
ListentFail,
45-
46-
ServerAddError,
47-
PortError,
48-
ConnectionError,
49-
ConnectionShutDown,
50-
51-
ProtocolError,
52-
TLSError,
53-
54-
AuthenticationError,
55-
56-
InvalidMessageSize,
57-
Undefined = 100,// Any undefined error
58-
};
59-
60-
struct Exception {
61-
// Which exception
62-
const int num; // Exception number
63-
const char *const name; // Exception name
64-
65-
// Additional information
66-
const std::string msg;
67-
const int errno_val;
68-
69-
// Where it was thrown
70-
const char * const file; // Source file name
71-
const int line; // Source line number
72-
73-
Exception(int exc, const char *exc_name, const char *f, int l)
74-
: num(exc), name(exc_name),
75-
msg(), errno_val(0),
76-
file(f), line(l)
77-
{}
78-
79-
Exception(int exc, const char *exc_name,
80-
const std::string &m,
81-
const char *f, int l)
82-
: num(exc), name(exc_name),
83-
msg(m), errno_val(0),
84-
file(f), line(l)
85-
{}
86-
87-
Exception(int exc, const char *exc_name,
88-
int err, const std::string &m,
89-
const char *f, int l)
90-
: num(exc), name(exc_name),
91-
msg(m), errno_val(err),
92-
file(f), line(l)
93-
{}
94-
Exception() = delete;
95-
Exception(const Exception&) = default;
96-
Exception& operator=(const Exception&) = delete;
97-
};
35+
namespace VDMS
36+
{
9837

38+
enum ExceptionType {
39+
FATAL_Internal_Error,
40+
41+
WriteFail, // For write/send failure
42+
ReadFail, // For read/recv failure
43+
BindFail, // Fail to bind a port
44+
SocketFail,
45+
ListentFail,
46+
47+
ServerAddError,
48+
PortError,
49+
ConnectionError,
50+
ConnectionShutDown,
51+
52+
ProtocolError,
53+
TLSError,
54+
55+
AuthenticationError,
56+
57+
InvalidMessageSize,
58+
Undefined = 100, // Any undefined error
59+
};
60+
61+
struct Exception {
62+
// Which exception
63+
const int num; // Exception number
64+
const char* const name; // Exception name
65+
66+
// Additional information
67+
const std::string msg;
68+
const int errno_val;
69+
70+
// Where it was thrown
71+
const char* const file; // Source file name
72+
const int line; // Source line number
73+
74+
Exception(int exc, const char* exc_name, const char* f, int l)
75+
: num(exc), name(exc_name), msg(), errno_val(0), file(f), line(l)
76+
{
77+
}
78+
79+
Exception(int exc, const char* exc_name, const std::string& m, const char* f, int l)
80+
: num(exc), name(exc_name), msg(m), errno_val(0), file(f), line(l)
81+
{
82+
}
83+
84+
Exception(int exc, const char* exc_name, int err, const std::string& m, const char* f, int l)
85+
: num(exc), name(exc_name), msg(m), errno_val(err), file(f), line(l)
86+
{
87+
}
88+
Exception() = delete;
89+
Exception(const Exception&) = default;
90+
Exception& operator=(const Exception&) = delete;
9991
};
92+
93+
}; // namespace VDMS

0 commit comments

Comments
 (0)