Skip to content

Commit 24897b7

Browse files
authored
Format by the new style. (#55)
1 parent 4ee94df commit 24897b7

Some content is hidden

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

67 files changed

+8355
-8634
lines changed

.clang-format

+37-18
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,38 @@
33
# This source code is licensed under Apache 2.0 License,
44
# attached with Common Clause Condition 1.0, found in the LICENSES directory.
55
#
6-
# This is the output of clang-format-7.0 --style=google --dump-config,
6+
# This is the output of clang-format-10.0.0 --style=google --dump-config,
77
# except for changes mentioned below.
88
# We have locked the version of clang-format in order to avoid inconsistencies
99
# in the format caused by developers using different clang-format versions.
1010
---
1111
Language: Cpp
1212
# BasedOnStyle: Google
13+
AccessModifierOffset: -1
1314
AlignAfterOpenBracket: Align
15+
AlignConsecutiveMacros: false
16+
AlignConsecutiveAssignments: false
1417
AlignConsecutiveDeclarations: false
18+
AlignEscapedNewlines: Left
1519
AlignOperands: true
1620
AlignTrailingComments: true
17-
AllowShortBlocksOnASingleLine: false
21+
AllowAllArgumentsOnNextLine: true
22+
AllowAllConstructorInitializersOnNextLine: true
23+
AllowAllParametersOfDeclarationOnNextLine: true
24+
AllowShortBlocksOnASingleLine: Never
1825
AllowShortCaseLabelsOnASingleLine: false
19-
AllowShortIfStatementsOnASingleLine: true
26+
AllowShortFunctionsOnASingleLine: All
27+
AllowShortLambdasOnASingleLine: All
28+
AllowShortIfStatementsOnASingleLine: WithoutElse
2029
AllowShortLoopsOnASingleLine: true
2130
AlwaysBreakAfterDefinitionReturnType: None
2231
AlwaysBreakAfterReturnType: None
32+
AlwaysBreakBeforeMultilineStrings: true
2333
AlwaysBreakTemplateDeclarations: Yes
34+
BinPackArguments: false
35+
BinPackParameters: false
2436
BraceWrapping:
37+
AfterCaseLabel: false
2538
AfterClass: false
2639
AfterControlStatement: false
2740
AfterEnum: false
@@ -46,12 +59,14 @@ BreakConstructorInitializersBeforeComma: false
4659
BreakConstructorInitializers: BeforeColon
4760
BreakAfterJavaFieldAnnotations: false
4861
BreakStringLiterals: true
62+
ColumnLimit: 100
4963
CommentPragmas: '^ IWYU pragma:'
5064
CompactNamespaces: false
5165
ConstructorInitializerAllOnOneLineOrOnePerLine: true
5266
ConstructorInitializerIndentWidth: 4
5367
ContinuationIndentWidth: 4
5468
Cpp11BracedListStyle: true
69+
DeriveLineEnding: true
5570
DerivePointerAlignment: true
5671
DisableFormat: false
5772
ExperimentalAutoDetectBinPacking: false
@@ -60,19 +75,26 @@ ForEachMacros:
6075
- foreach
6176
- Q_FOREACH
6277
- BOOST_FOREACH
63-
IncludeBlocks: Preserve
78+
IncludeBlocks: Regroup
6479
IncludeCategories:
6580
- Regex: '^<ext/.*\.h>'
6681
Priority: 2
82+
SortPriority: 0
6783
- Regex: '^<.*\.h>'
6884
Priority: 1
85+
SortPriority: 0
6986
- Regex: '^<.*'
7087
Priority: 2
88+
SortPriority: 0
7189
- Regex: '.*'
7290
Priority: 3
91+
SortPriority: 0
7392
IncludeIsMainRegex: '([-_](test|unittest))?$'
93+
IncludeIsMainSourceRegex: ''
7494
IndentCaseLabels: true
95+
IndentGotoLabels: false
7596
IndentPPDirectives: None
97+
IndentWidth: 2
7698
IndentWrappedFunctionNames: false
7799
JavaScriptQuotes: Leave
78100
JavaScriptWrapImports: true
@@ -82,6 +104,7 @@ MacroBlockEnd: ''
82104
MaxEmptyLinesToKeep: 1
83105
NamespaceIndentation: None
84106
ObjCBinPackProtocolList: Never
107+
ObjCBlockIndentWidth: 2
85108
ObjCSpaceAfterProperty: false
86109
ObjCSpaceBeforeProtocolList: true
87110
PenaltyBreakAssignment: 2
@@ -125,33 +148,29 @@ ReflowComments: true
125148
SortIncludes: true
126149
SortUsingDeclarations: true
127150
SpaceAfterCStyleCast: false
151+
SpaceAfterLogicalNot: false
128152
SpaceAfterTemplateKeyword: true
129153
SpaceBeforeAssignmentOperators: true
130154
SpaceBeforeCpp11BracedList: false
131155
SpaceBeforeCtorInitializerColon: true
132156
SpaceBeforeInheritanceColon: true
133157
SpaceBeforeParens: ControlStatements
134158
SpaceBeforeRangeBasedForLoopColon: true
159+
SpaceInEmptyBlock: false
135160
SpaceInEmptyParentheses: false
161+
SpacesBeforeTrailingComments: 2
136162
SpacesInAngles: false
163+
SpacesInConditionalStatement: false
137164
SpacesInContainerLiterals: true
138165
SpacesInCStyleCastParentheses: false
139166
SpacesInParentheses: false
140167
SpacesInSquareBrackets: false
168+
SpaceBeforeSquareBrackets: false
169+
Standard: c++17
170+
StatementMacros:
171+
- Q_UNUSED
172+
- QT_REQUIRE_VERSION
141173
TabWidth: 8
174+
UseCRLF: false
142175
UseTab: Never
143-
144-
#Different from google style
145-
Standard: Cpp11
146-
AccessModifierOffset: -4
147-
AllowAllParametersOfDeclarationOnNextLine: false
148-
ColumnLimit: 100
149-
ObjCBlockIndentWidth: 4
150-
AlignEscapedNewlines: Right
151-
AlwaysBreakBeforeMultilineStrings: false
152-
BinPackArguments: false
153-
BinPackParameters: false
154-
IndentWidth: 4
155-
SpacesBeforeTrailingComments: 3
156-
AllowShortFunctionsOnASingleLine: Empty
157176
...

.linters/cpp/hooks/pre-commit.sh

+12
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,15 @@ else
4848
echo "cpplint code style check failed, please fix and recommit."
4949
exit 1
5050
fi
51+
52+
echo "Performing C++ code format check..."
53+
54+
CLANG_HOME=/opt/vesoft/toolset/clang/10.0.0/
55+
56+
if [ ! -d "$CLANG_HOME" ]; then
57+
echo "The $CLANG_HOME directory is not found, and the source changes cannot be automatically formatted."
58+
exit 0
59+
fi
60+
61+
git diff -U0 --no-color --staged | $CLANG_HOME/share/clang/clang-format-diff.py -i -p1 -binary $CLANG_HOME/bin/clang-format
62+
git add $CHECK_FILES

include/common/datatypes/CommonCpp2Ops.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct Set;
2525
struct List;
2626
struct DataSet;
2727
struct Geography;
28-
} // namespace nebula
28+
} // namespace nebula
2929

3030
namespace apache::thrift {
3131

@@ -46,4 +46,4 @@ SPECIALIZE_CPP2OPS(nebula::List);
4646
SPECIALIZE_CPP2OPS(nebula::DataSet);
4747
SPECIALIZE_CPP2OPS(nebula::Geography);
4848

49-
} // namespace apache::thrift
49+
} // namespace apache::thrift

0 commit comments

Comments
 (0)