diff --git a/.clang-tidy b/.clang-tidy index 7241c372319..f8622039f29 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -41,6 +41,8 @@ Checks: '*, -clang-analyzer-security.insecureAPI.strcpy, -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-const-or-ref-data-members, + -cppcoreguidelines-avoid-do-while, -cppcoreguidelines-avoid-goto, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-avoid-non-const-global-variables, @@ -128,6 +130,7 @@ Checks: '*, -portability-simd-intrinsics, -readability-braces-around-statements, + -readability-convert-member-functions-to-static, -readability-else-after-return, -readability-function-cognitive-complexity, -readability-function-size, diff --git a/base/base/hex.h b/base/base/hex.h index e0c57f9dd42..b8cf95db893 100644 --- a/base/base/hex.h +++ b/base/base/hex.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "types.h" diff --git a/base/poco/Util/src/XMLConfiguration.cpp b/base/poco/Util/src/XMLConfiguration.cpp index 974361044d7..e0d363cc870 100644 --- a/base/poco/Util/src/XMLConfiguration.cpp +++ b/base/poco/Util/src/XMLConfiguration.cpp @@ -27,7 +27,7 @@ #include "Poco/Exception.h" #include "Poco/NumberParser.h" #include "Poco/NumberFormatter.h" -#include +#include namespace Poco { diff --git a/cmake/clang_tidy.cmake b/cmake/clang_tidy.cmake index ceaafdaa9aa..96c295b6bb9 100644 --- a/cmake/clang_tidy.cmake +++ b/cmake/clang_tidy.cmake @@ -5,14 +5,14 @@ if (ENABLE_CLANG_TIDY) find_program (CLANG_TIDY_CACHE_PATH NAMES "clang-tidy-cache") if (CLANG_TIDY_CACHE_PATH) - find_program (_CLANG_TIDY_PATH NAMES "clang-tidy-15" "clang-tidy-14" "clang-tidy-13" "clang-tidy-12" "clang-tidy") + find_program (_CLANG_TIDY_PATH NAMES "clang-tidy-16" "clang-tidy-15" "clang-tidy-14" "clang-tidy") # Why do we use ';' here? # It's a cmake black magic: https://cmake.org/cmake/help/latest/prop_tgt/LANG_CLANG_TIDY.html#prop_tgt:%3CLANG%3E_CLANG_TIDY # The CLANG_TIDY_PATH is passed to CMAKE_CXX_CLANG_TIDY, which follows CXX_CLANG_TIDY syntax. set (CLANG_TIDY_PATH "${CLANG_TIDY_CACHE_PATH};${_CLANG_TIDY_PATH}" CACHE STRING "A combined command to run clang-tidy with caching wrapper") else () - find_program (CLANG_TIDY_PATH NAMES "clang-tidy-15" "clang-tidy-14" "clang-tidy-13" "clang-tidy-12" "clang-tidy") + find_program (CLANG_TIDY_PATH NAMES "clang-tidy-16" "clang-tidy-15" "clang-tidy-14" "clang-tidy") endif () if (CLANG_TIDY_PATH) diff --git a/src/Analyzer/Identifier.h b/src/Analyzer/Identifier.h index 71c5d784464..cf64bcf8bfb 100644 --- a/src/Analyzer/Identifier.h +++ b/src/Analyzer/Identifier.h @@ -400,7 +400,7 @@ struct fmt::formatter /// Only support {}. if (it != end && *it != '}') - throw format_error("invalid format"); + throw fmt::format_error("invalid format"); return it; } @@ -408,7 +408,7 @@ struct fmt::formatter template auto format(const DB::Identifier & identifier, FormatContext & ctx) { - return format_to(ctx.out(), "{}", identifier.getFullName()); + return fmt::format_to(ctx.out(), "{}", identifier.getFullName()); } }; @@ -422,7 +422,7 @@ struct fmt::formatter /// Only support {}. if (it != end && *it != '}') - throw format_error("invalid format"); + throw fmt::format_error("invalid format"); return it; } @@ -430,6 +430,6 @@ struct fmt::formatter template auto format(const DB::IdentifierView & identifier_view, FormatContext & ctx) { - return format_to(ctx.out(), "{}", identifier_view.getFullName()); + return fmt::format_to(ctx.out(), "{}", identifier_view.getFullName()); } }; diff --git a/src/Client/TestHint.h b/src/Client/TestHint.h index 63f16b1dd97..982cd10dce0 100644 --- a/src/Client/TestHint.h +++ b/src/Client/TestHint.h @@ -106,7 +106,7 @@ struct fmt::formatter /// Only support {}. if (it != end && *it != '}') - throw format_error("Invalid format"); + throw fmt::format_error("Invalid format"); return it; } @@ -115,10 +115,10 @@ struct fmt::formatter auto format(const DB::TestHint::ErrorVector & ErrorVector, FormatContext & ctx) { if (ErrorVector.empty()) - return format_to(ctx.out(), "{}", 0); + return fmt::format_to(ctx.out(), "{}", 0); else if (ErrorVector.size() == 1) - return format_to(ctx.out(), "{}", ErrorVector[0]); + return fmt::format_to(ctx.out(), "{}", ErrorVector[0]); else - return format_to(ctx.out(), "[{}]", fmt::join(ErrorVector, ", ")); + return fmt::format_to(ctx.out(), "[{}]", fmt::join(ErrorVector, ", ")); } }; diff --git a/src/Common/Epoll.h b/src/Common/Epoll.h index 9c75974791f..bec86d5bbcb 100644 --- a/src/Common/Epoll.h +++ b/src/Common/Epoll.h @@ -3,6 +3,7 @@ #include #include +#include #include #include diff --git a/src/Common/StringUtils/StringUtils.h b/src/Common/StringUtils/StringUtils.h index 72f172a1e45..8e8df19adee 100644 --- a/src/Common/StringUtils/StringUtils.h +++ b/src/Common/StringUtils/StringUtils.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include diff --git a/src/Common/ZooKeeper/ZooKeeperCommon.cpp b/src/Common/ZooKeeper/ZooKeeperCommon.cpp index 4cc1c24ef8b..1ee56936889 100644 --- a/src/Common/ZooKeeper/ZooKeeperCommon.cpp +++ b/src/Common/ZooKeeper/ZooKeeperCommon.cpp @@ -563,7 +563,7 @@ std::string ZooKeeperMultiRequest::toStringImpl() const for (const auto & request : requests) { const auto & zk_request = dynamic_cast(*request); - format_to(std::back_inserter(out), "SubRequest\n{}\n", zk_request.toString()); + fmt::format_to(std::back_inserter(out), "SubRequest\n{}\n", zk_request.toString()); } return {out.data(), out.size()}; } diff --git a/src/Common/formatReadable.h b/src/Common/formatReadable.h index 6cdc36b4ed2..a05a2a7f9e2 100644 --- a/src/Common/formatReadable.h +++ b/src/Common/formatReadable.h @@ -43,7 +43,7 @@ struct fmt::formatter /// Only support {}. if (it != end && *it != '}') - throw format_error("invalid format"); + throw fmt::format_error("invalid format"); return it; } @@ -51,6 +51,6 @@ struct fmt::formatter template auto format(const ReadableSize & size, FormatContext & ctx) { - return format_to(ctx.out(), "{}", formatReadableSizeWithBinarySuffix(size.value)); + return fmt::format_to(ctx.out(), "{}", formatReadableSizeWithBinarySuffix(size.value)); } }; diff --git a/src/Core/Field.h b/src/Core/Field.h index 2e772a64afc..ef1bd9a895d 100644 --- a/src/Core/Field.h +++ b/src/Core/Field.h @@ -1019,7 +1019,7 @@ struct fmt::formatter /// Only support {}. if (it != end && *it != '}') - throw format_error("Invalid format"); + throw fmt::format_error("Invalid format"); return it; } @@ -1027,6 +1027,6 @@ struct fmt::formatter template auto format(const DB::Field & x, FormatContext & ctx) { - return format_to(ctx.out(), "{}", toString(x)); + return fmt::format_to(ctx.out(), "{}", toString(x)); } }; diff --git a/src/DataTypes/IDataType.h b/src/DataTypes/IDataType.h index e5bdbeca69e..83fe8065e46 100644 --- a/src/DataTypes/IDataType.h +++ b/src/DataTypes/IDataType.h @@ -626,7 +626,7 @@ struct fmt::formatter /// Only support {}. if (it != end && *it != '}') - throw format_error("invalid format"); + throw fmt::format_error("invalid format"); return it; } @@ -634,6 +634,6 @@ struct fmt::formatter template auto format(const DB::DataTypePtr & type, FormatContext & ctx) { - return format_to(ctx.out(), "{}", type->getName()); + return fmt::format_to(ctx.out(), "{}", type->getName()); } }; diff --git a/src/Disks/FakeDiskTransaction.h b/src/Disks/FakeDiskTransaction.h index 5dae17041e1..3a7ea4473b6 100644 --- a/src/Disks/FakeDiskTransaction.h +++ b/src/Disks/FakeDiskTransaction.h @@ -1,6 +1,7 @@ #pragma once #include +#include namespace DB { diff --git a/src/Disks/ObjectStorages/StoredObject.h b/src/Disks/ObjectStorages/StoredObject.h index 04bd0b26495..2b6e76eec01 100644 --- a/src/Disks/ObjectStorages/StoredObject.h +++ b/src/Disks/ObjectStorages/StoredObject.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include diff --git a/src/IO/Archives/IArchiveReader.h b/src/IO/Archives/IArchiveReader.h index ff02dc7e733..37629cd7eed 100644 --- a/src/IO/Archives/IArchiveReader.h +++ b/src/IO/Archives/IArchiveReader.h @@ -2,6 +2,7 @@ #include #include +#include #include diff --git a/src/IO/Archives/createArchiveReader.h b/src/IO/Archives/createArchiveReader.h index 9e1073b9481..64eb4c8eabc 100644 --- a/src/IO/Archives/createArchiveReader.h +++ b/src/IO/Archives/createArchiveReader.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include diff --git a/src/Interpreters/StorageID.h b/src/Interpreters/StorageID.h index 147d50b4e4f..96e3cefe00c 100644 --- a/src/Interpreters/StorageID.h +++ b/src/Interpreters/StorageID.h @@ -138,7 +138,7 @@ namespace fmt template auto format(const DB::StorageID & storage_id, FormatContext & ctx) { - return format_to(ctx.out(), "{}", storage_id.getNameForLogs()); + return fmt::format_to(ctx.out(), "{}", storage_id.getNameForLogs()); } }; } diff --git a/src/Interpreters/TemporaryDataOnDisk.cpp b/src/Interpreters/TemporaryDataOnDisk.cpp index 0b56ce29545..25252f8226b 100644 --- a/src/Interpreters/TemporaryDataOnDisk.cpp +++ b/src/Interpreters/TemporaryDataOnDisk.cpp @@ -45,6 +45,15 @@ void TemporaryDataOnDiskScope::deltaAllocAndCheck(ssize_t compressed_delta, ssiz stat.uncompressed_size += uncompressed_delta; } +TemporaryDataOnDisk::TemporaryDataOnDisk(TemporaryDataOnDiskScopePtr parent_) + : TemporaryDataOnDiskScope(std::move(parent_), /* limit_ = */ 0) +{} + +TemporaryDataOnDisk::TemporaryDataOnDisk(TemporaryDataOnDiskScopePtr parent_, CurrentMetrics::Value metric_scope) + : TemporaryDataOnDiskScope(std::move(parent_), /* limit_ = */ 0) + , current_metric_scope(metric_scope) +{} + TemporaryFileStream & TemporaryDataOnDisk::createStream(const Block & header, size_t max_file_size) { if (file_cache) diff --git a/src/Interpreters/TemporaryDataOnDisk.h b/src/Interpreters/TemporaryDataOnDisk.h index 1b56f953d17..f0e02f16fb6 100644 --- a/src/Interpreters/TemporaryDataOnDisk.h +++ b/src/Interpreters/TemporaryDataOnDisk.h @@ -83,14 +83,9 @@ class TemporaryDataOnDisk : private TemporaryDataOnDiskScope public: using TemporaryDataOnDiskScope::StatAtomic; - explicit TemporaryDataOnDisk(TemporaryDataOnDiskScopePtr parent_) - : TemporaryDataOnDiskScope(std::move(parent_), /* limit_ = */ 0) - {} + explicit TemporaryDataOnDisk(TemporaryDataOnDiskScopePtr parent_); - explicit TemporaryDataOnDisk(TemporaryDataOnDiskScopePtr parent_, CurrentMetrics::Value metric_scope) - : TemporaryDataOnDiskScope(std::move(parent_), /* limit_ = */ 0) - , current_metric_scope(metric_scope) - {} + explicit TemporaryDataOnDisk(TemporaryDataOnDiskScopePtr parent_, CurrentMetrics::Value metric_scope); /// If max_file_size > 0, then check that there's enough space on the disk and throw an exception in case of lack of free space TemporaryFileStream & createStream(const Block & header, size_t max_file_size = 0); diff --git a/src/Processors/Transforms/WindowTransform.h b/src/Processors/Transforms/WindowTransform.h index 424466bca8a..b9894052a96 100644 --- a/src/Processors/Transforms/WindowTransform.h +++ b/src/Processors/Transforms/WindowTransform.h @@ -373,7 +373,7 @@ struct fmt::formatter /// Only support {}. if (it != end && *it != '}') - throw format_error("invalid format"); + throw fmt::format_error("invalid format"); return it; } @@ -381,6 +381,6 @@ struct fmt::formatter template auto format(const DB::RowNumber & x, FormatContext & ctx) { - return format_to(ctx.out(), "{}:{}", x.block, x.row); + return fmt::format_to(ctx.out(), "{}:{}", x.block, x.row); } }; diff --git a/src/Storages/MergeTree/MarkRange.h b/src/Storages/MergeTree/MarkRange.h index d1f4e1a4b45..f31d6a2a73b 100644 --- a/src/Storages/MergeTree/MarkRange.h +++ b/src/Storages/MergeTree/MarkRange.h @@ -63,7 +63,7 @@ struct fmt::formatter /// Only support {}. if (it != end && *it != '}') - throw format_error("invalid format"); + throw fmt::format_error("invalid format"); return it; } @@ -71,6 +71,6 @@ struct fmt::formatter template auto format(const DB::MarkRange & range, FormatContext & ctx) { - return format_to(ctx.out(), "{}", fmt::format("({}, {})", range.begin, range.end)); + return fmt::format_to(ctx.out(), "{}", fmt::format("({}, {})", range.begin, range.end)); } };