Skip to content

Commit a13638b

Browse files
xiaocai2333yefu.chen
authored and
yefu.chen
committed
Add cpplint and optimize the check of c++ code
Signed-off-by: cai.zhang <[email protected]>
1 parent 84f3d97 commit a13638b

15 files changed

+7143
-30
lines changed

.clang-tidy

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# The checks defined here will be run and will display by default as warnings.
19+
Checks: >
20+
-*, clang-diagnostic-*, -clang-diagnostic-error,
21+
clang-analyzer-*, -clang-analyzer-alpha*,
22+
google-*, -google-runtime-references, -google-readability-todo,
23+
modernize-*, -modernize-pass-by-value, -modernize-use-equals-default,
24+
performance-faster-string-find, performance-for-range-copy,
25+
performance-implicit-conversion-in-loop, performance-inefficient-algorithm,
26+
performance-trivially-destructible, performance-inefficient-vector-operation,
27+
performance-move-const-arg, performance-move-constructor-init,
28+
performance-noexcept-move-constructor, performance-no-automatic-move,
29+
performance-type-promotion-in-math-fn
30+
31+
# produce HeaderFilterRegex from core/build-support/lint_exclusions.txt with:
32+
# echo -n '^?!('; sed -e 's/*/\.*/g' core/build-support/lint_exclusions.txt | tr '\n' '|'; echo ')$'
33+
HeaderFilterRegex: '^?!(.*cmake-build-debug.*|.*cmake-build-release.*|.*cmake_build.*|.*thirdparty.*|.*src/grpc.*|.*output.*|.*unittest.*|.*src/pb.*)$'
34+
AnalyzeTemporaryDtors: true
35+
CheckOptions:
36+
- key: google-readability-braces-around-statements.ShortStatementLines
37+
value: '1'
38+
- key: google-readability-function-size.StatementThreshold
39+
value: '800'
40+
- key: google-readability-namespace-comments.ShortNamespaceLines
41+
value: '10'
42+
- key: google-readability-namespace-comments.SpacesBeforeComments
43+
value: '2'

.clang-tidy-ignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#

Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ all: build-cpp build-go
2121
get-build-deps:
2222
@(env bash $(PWD)/scripts/install_deps.sh)
2323

24-
clang-format:
25-
@echo "Running $@ check"
26-
@(env bash ${PWD}/scripts/run_clang_format.sh internal/core)
24+
cppcheck:
25+
@(env bash ${PWD}/scripts/core_build.sh -l)
2726

2827
generated-proto-go:export protoc:=${PWD}/cmake_build/thirdparty/protobuf/protobuf-build/protoc
2928
generated-proto-go: build-cpp
@@ -52,7 +51,7 @@ ruleguard:
5251
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./cmd/...
5352
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./test/...
5453

55-
verifiers: clang-format fmt lint ruleguard
54+
verifiers: cppcheck fmt lint ruleguard
5655

5756
# Builds various components locally.
5857
build-go:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<code_scheme name="milvus" version="173">
2+
<Objective-C>
3+
<option name="INDENT_NAMESPACE_MEMBERS" value="0" />
4+
<option name="INDENT_VISIBILITY_KEYWORDS" value="1" />
5+
<option name="KEEP_STRUCTURES_IN_ONE_LINE" value="true" />
6+
<option name="KEEP_CASE_EXPRESSIONS_IN_ONE_LINE" value="true" />
7+
<option name="FUNCTION_NON_TOP_AFTER_RETURN_TYPE_WRAP" value="0" />
8+
<option name="FUNCTION_TOP_AFTER_RETURN_TYPE_WRAP" value="2" />
9+
<option name="FUNCTION_PARAMETERS_WRAP" value="5" />
10+
<option name="FUNCTION_CALL_ARGUMENTS_WRAP" value="5" />
11+
<option name="TEMPLATE_CALL_ARGUMENTS_WRAP" value="5" />
12+
<option name="TEMPLATE_CALL_ARGUMENTS_ALIGN_MULTILINE" value="true" />
13+
<option name="CLASS_CONSTRUCTOR_INIT_LIST_WRAP" value="5" />
14+
<option name="ALIGN_INIT_LIST_IN_COLUMNS" value="false" />
15+
<option name="SPACE_BEFORE_PROTOCOLS_BRACKETS" value="false" />
16+
<option name="SPACE_BEFORE_POINTER_IN_DECLARATION" value="false" />
17+
<option name="SPACE_AFTER_POINTER_IN_DECLARATION" value="true" />
18+
<option name="SPACE_BEFORE_REFERENCE_IN_DECLARATION" value="false" />
19+
<option name="SPACE_AFTER_REFERENCE_IN_DECLARATION" value="true" />
20+
<option name="KEEP_BLANK_LINES_BEFORE_END" value="1" />
21+
</Objective-C>
22+
<codeStyleSettings language="ObjectiveC">
23+
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
24+
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
25+
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
26+
<option name="BLANK_LINES_AROUND_CLASS" value="0" />
27+
<option name="BLANK_LINES_AROUND_METHOD_IN_INTERFACE" value="0" />
28+
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" />
29+
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
30+
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
31+
<option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="false" />
32+
<option name="FOR_STATEMENT_WRAP" value="1" />
33+
<option name="ASSIGNMENT_WRAP" value="1" />
34+
<indentOptions>
35+
<option name="CONTINUATION_INDENT_SIZE" value="4" />
36+
</indentOptions>
37+
</codeStyleSettings>
38+
</code_scheme>

0 commit comments

Comments
 (0)