Skip to content

Commit 7548810

Browse files
authored
Merge pull request #483 from SYaoJun/0210_tidy
Add clang-tidy and check script and fix the warnings under count dire…
2 parents fccb238 + 2956f15 commit 7548810

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
lines changed

.clang-tidy

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
Checks: |
19+
clang-diagnostic-*,
20+
clang-analyzer-*,
21+
-clang-analyzer-alpha*,
22+
google-*,
23+
modernize-*,
24+
-modernize-avoid-c-arrays,
25+
-modernize-use-trailing-return-type,
26+
-modernize-use-nodiscard,
27+
28+
CheckOptions:
29+
- key: google-readability-braces-around-statements.ShortStatementLines
30+
value: '1'
31+
- key: google-readability-function-size.StatementThreshold
32+
value: '800'
33+
- key: google-readability-namespace-comments.ShortNamespaceLines
34+
value: '10'
35+
- key: google-readability-namespace-comments.SpacesBeforeComments
36+
value: '2'

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
# To use this, install the python package `pre-commit` and
19+
# run once `pre-commit install`. This will setup a git pre-commit-hook
20+
# that is executed on each commit and will report the linting problems.
21+
# To run all hooks on all files use `pre-commit run -a`
22+
23+
repos:
24+
- repo: https://github.com/pocc/pre-commit-hooks
25+
rev: v1.3.5
26+
hooks:
27+
- id: clang-tidy
28+
args: ['--quiet', '-p=build/compile_commands.json', '--config-file=.clang-tidy']
29+
types_or: [c++, c]

count/include/count_min_impl.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ uint64_t count_min_sketch<W,A>::get_seed() const {
7474

7575
template<typename W, typename A>
7676
double count_min_sketch<W,A>::get_relative_error() const {
77-
return exp(1.0) / double(_num_buckets);
77+
return exp(1.0) / static_cast<double>(_num_buckets);
7878
}
7979

8080
template<typename W, typename A>
@@ -449,8 +449,9 @@ string<A> count_min_sketch<W,A>::to_string() const {
449449
// count the number of used entries in the sketch
450450
uint64_t num_nonzero = 0;
451451
for (const auto entry: _sketch_array) {
452-
if (entry != static_cast<W>(0.0))
452+
if (entry != static_cast<W>(0.0)){
453453
++num_nonzero;
454+
}
454455
}
455456

456457
// Using a temporary stream for implementation here does not comply with AllocatorAwareContainer requirements.

0 commit comments

Comments
 (0)