From ba46f89499a87ccaa717e2ab16861c6eafd245bc Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Wed, 5 Feb 2025 13:28:39 -0500 Subject: [PATCH] cleanup: changes following clang-tidy suggestions (#14976) * cleanup: changes following clang-tidy suggestions * fix * fix --- .clang-tidy | 5 +++++ generator/internal/mixin_utils.cc | 9 ++++----- google/cloud/bigtable/row_reader.h | 1 + google/cloud/storage/async/reader.cc | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 372b7fadaf48d..9dd40ccb9bb1f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -29,6 +29,10 @@ # -modernize-type-traits: clang-tidy recommands using c++17 style variable # templates. We will enable this check after we moved to c++17. # +# -modernize-unary-static-assert: clang-tidy asks removing empty string in +# static_assert(), the check is only applicable for c++17 and later code. +# We will enable this check after we moved to c++17. +# # -performance-move-const-arg: This warning requires the developer to # know/care more about the implementation details of types/functions than # should be necessary. For example, `A a; F(std::move(a));` will trigger a @@ -93,6 +97,7 @@ Checks: > -modernize-use-nodiscard, -modernize-avoid-c-arrays, -modernize-type-traits, + -modernize-unary-static-assert, -performance-move-const-arg, -performance-avoid-endl, -performance-enum-size, diff --git a/generator/internal/mixin_utils.cc b/generator/internal/mixin_utils.cc index c2257d40c8198..918cf39df2b0b 100644 --- a/generator/internal/mixin_utils.cc +++ b/generator/internal/mixin_utils.cc @@ -65,9 +65,8 @@ google::api::HttpRule ParseHttpRule(YAML::detail::iterator_value const& rule) { kv.second.Type() != YAML::NodeType::Scalar) continue; - std::string const rule_key = - absl::AsciiStrToLower(kv.first.as()); - std::string const rule_value = kv.second.as(); + auto const rule_key = absl::AsciiStrToLower(kv.first.as()); + auto const rule_value = kv.second.as(); if (rule_key == "get") { http_rule.set_get(rule_value); @@ -107,7 +106,7 @@ std::unordered_map GetMixinHttpOverrides( auto const& selector = rule["selector"]; if (selector.Type() != YAML::NodeType::Scalar) continue; - std::string const method_full_name = selector.as(); + auto const method_full_name = selector.as(); google::api::HttpRule http_rule = ParseHttpRule(rule); if (rule["additional_bindings"]) { @@ -150,7 +149,7 @@ std::vector GetMixinProtoPaths(YAML::Node const& service_config) { if (api.Type() != YAML::NodeType::Map) continue; auto const& name = api["name"]; if (name.Type() != YAML::NodeType::Scalar) continue; - std::string const package_path = name.as(); + auto const package_path = name.as(); auto const& mixin_proto_path_map = GetMixinProtoPathMap(); auto const it = mixin_proto_path_map.find(package_path); if (it == mixin_proto_path_map.end()) continue; diff --git a/google/cloud/bigtable/row_reader.h b/google/cloud/bigtable/row_reader.h index 538b3c323617c..11ba0d202eba9 100644 --- a/google/cloud/bigtable/row_reader.h +++ b/google/cloud/bigtable/row_reader.h @@ -81,6 +81,7 @@ class RowReader { MetadataUpdatePolicy metadata_update_policy, std::unique_ptr parser_factory); + // NOLINTNEXTLINE(performance-noexcept-move-constructor) RowReader(RowReader&&) = default; ~RowReader() = default; diff --git a/google/cloud/storage/async/reader.cc b/google/cloud/storage/async/reader.cc index 8858116095e19..71be31755eac9 100644 --- a/google/cloud/storage/async/reader.cc +++ b/google/cloud/storage/async/reader.cc @@ -55,6 +55,7 @@ class Discard : public std::enable_shared_from_this { } // namespace +// NOLINTNEXTLINE(bugprone-exception-escape) AsyncReader::~AsyncReader() { if (!impl_ || finished_) return; impl_->Cancel();