diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..93e3edeb --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +--- +Checks: | + clang-diagnostic-*, + clang-analyzer-*, + -clang-analyzer-alpha*, + google-*, + modernize-*, + -modernize-avoid-c-arrays, + -modernize-use-trailing-return-type, + -modernize-use-nodiscard, + +CheckOptions: + - key: google-readability-braces-around-statements.ShortStatementLines + value: '1' + - key: google-readability-function-size.StatementThreshold + value: '800' + - key: google-readability-namespace-comments.ShortNamespaceLines + value: '10' + - key: google-readability-namespace-comments.SpacesBeforeComments + value: '2' \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..262fd02e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# To use this, install the python package `pre-commit` and +# run once `pre-commit install`. This will setup a git pre-commit-hook +# that is executed on each commit and will report the linting problems. +# To run all hooks on all files use `pre-commit run -a` + +repos: + - repo: https://github.com/pocc/pre-commit-hooks + rev: v1.3.5 + hooks: + - id: clang-tidy + args: ['--quiet', '-p=build/compile_commands.json', '--config-file=.clang-tidy'] + types_or: [c++, c] \ No newline at end of file diff --git a/count/include/count_min_impl.hpp b/count/include/count_min_impl.hpp index 45376e7b..99b0a41e 100644 --- a/count/include/count_min_impl.hpp +++ b/count/include/count_min_impl.hpp @@ -74,7 +74,7 @@ uint64_t count_min_sketch::get_seed() const { template double count_min_sketch::get_relative_error() const { - return exp(1.0) / double(_num_buckets); + return exp(1.0) / static_cast(_num_buckets); } template @@ -449,8 +449,9 @@ string count_min_sketch::to_string() const { // count the number of used entries in the sketch uint64_t num_nonzero = 0; for (const auto entry: _sketch_array) { - if (entry != static_cast(0.0)) + if (entry != static_cast(0.0)){ ++num_nonzero; + } } // Using a temporary stream for implementation here does not comply with AllocatorAwareContainer requirements.