From db9363238adff00e202b5ec72a1209831705260e Mon Sep 17 00:00:00 2001 From: Derek Argueta <dereka@pinterest.com> Date: Fri, 27 Sep 2019 03:03:29 +0000 Subject: [PATCH 1/3] clang-tidy: check casing on class names Signed-off-by: Derek Argueta <dereka@pinterest.com> --- .clang-tidy | 3 +++ source/common/common/fmt.h | 1 + test/common/common/log_macros_test.cc | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index a53d3ff5ea23..b1c262c9301c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -59,6 +59,9 @@ CheckOptions: - key: modernize-use-auto.MinTypeNameLength value: '10' + - key: readability-identifier-naming.ClassCase + value: 'CamelCase' + - key: readability-identifier-naming.EnumCase value: 'CamelCase' diff --git a/source/common/common/fmt.h b/source/common/common/fmt.h index bffdf9fb62f9..ba019fabe46a 100644 --- a/source/common/common/fmt.h +++ b/source/common/common/fmt.h @@ -12,6 +12,7 @@ namespace fmt { // formatted with the same format specifiers available to std::string. // TODO(zuercher): Once absl::string_view is replaced with std::string_view, this can be removed // as fmtlib handles std::string_view natively. +// NOLINTNEXTLINE(readability-identifier-naming) template <> struct formatter<absl::string_view> : formatter<string_view> { auto format(absl::string_view absl_string_view, fmt::format_context& ctx) -> decltype(ctx.out()) { string_view fmt_string_view(absl_string_view.data(), absl_string_view.size()); diff --git a/test/common/common/log_macros_test.cc b/test/common/common/log_macros_test.cc index 8d683910bb6b..363a5ff9400f 100644 --- a/test/common/common/log_macros_test.cc +++ b/test/common/common/log_macros_test.cc @@ -87,7 +87,7 @@ TEST(Logger, logAsStatement) { } TEST(Logger, checkLoggerLevel) { - class logTestClass : public Logger::Loggable<Logger::Id::misc> { + class LogTestClass : public Logger::Loggable<Logger::Id::misc> { public: void setLevel(const spdlog::level::level_enum level) { ENVOY_LOGGER().set_level(level); } uint32_t executeAtTraceLevel() { @@ -101,7 +101,7 @@ TEST(Logger, checkLoggerLevel) { } }; - logTestClass testObj; + LogTestClass testObj; // Set Loggers severity low testObj.setLevel(spdlog::level::trace); From 32e48a97b0179934c7c4c7b0f343700eea937899 Mon Sep 17 00:00:00 2001 From: Derek Argueta <dereka@pinterest.com> Date: Thu, 3 Oct 2019 23:47:33 +0000 Subject: [PATCH 2/3] set abseil_strings and fmtlib as dependencies of fmtlib Signed-off-by: Derek Argueta <dereka@pinterest.com> --- bazel/envoy_library.bzl | 8 ++++++-- source/common/common/BUILD | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index 352dbfa5efd4..661e64be6cce 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -22,8 +22,12 @@ def _tcmalloc_external_deps(repository): # passed to cc_library should be specified with this function. Note: this exists to ensure that # all envoy targets pass through an envoy-declared skylark function where they can be modified # before being passed to a native bazel function. -def envoy_basic_cc_library(name, **kargs): - native.cc_library(name = name, **kargs) +def envoy_basic_cc_library(name, deps = [], external_deps = [], **kargs): + native.cc_library( + name = name, + deps = deps + [envoy_external_dep_path(dep) for dep in external_deps], + **kargs + ) # Envoy C++ library targets should be specified with this function. def envoy_cc_library( diff --git a/source/common/common/BUILD b/source/common/common/BUILD index fbe3714e6374..401d32364634 100644 --- a/source/common/common/BUILD +++ b/source/common/common/BUILD @@ -86,6 +86,10 @@ envoy_cc_library( envoy_basic_cc_library( name = "fmt_lib", hdrs = ["fmt.h"], + external_deps = [ + "abseil_strings", + "fmtlib", + ], include_prefix = envoy_include_prefix(package_name()), ) From 86677af7dc78de728114559312f3c81be253767b Mon Sep 17 00:00:00 2001 From: Derek Argueta <dereka@pinterest.com> Date: Fri, 4 Oct 2019 00:06:05 +0000 Subject: [PATCH 3/3] fix variable casing Signed-off-by: Derek Argueta <dereka@pinterest.com> --- test/common/common/log_macros_test.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/common/common/log_macros_test.cc b/test/common/common/log_macros_test.cc index 363a5ff9400f..cb56821c03f9 100644 --- a/test/common/common/log_macros_test.cc +++ b/test/common/common/log_macros_test.cc @@ -101,14 +101,14 @@ TEST(Logger, checkLoggerLevel) { } }; - LogTestClass testObj; + LogTestClass test_obj; // Set Loggers severity low - testObj.setLevel(spdlog::level::trace); - EXPECT_THAT(testObj.executeAtTraceLevel(), testing::Eq(1)); + test_obj.setLevel(spdlog::level::trace); + EXPECT_THAT(test_obj.executeAtTraceLevel(), testing::Eq(1)); - testObj.setLevel(spdlog::level::info); - EXPECT_THAT(testObj.executeAtTraceLevel(), testing::Eq(2)); + test_obj.setLevel(spdlog::level::info); + EXPECT_THAT(test_obj.executeAtTraceLevel(), testing::Eq(2)); } TEST(RegistryTest, LoggerWithName) {