From 5c0acab54c99bbbf1c161a67f51931f9de8ecdf6 Mon Sep 17 00:00:00 2001 From: Marco Magdy Date: Tue, 14 Feb 2023 11:37:22 -0800 Subject: [PATCH 1/3] Fix clang-tidy benign warnings Disabled the parameters easily swappable warning because there isn't an easy way to fix that in C++ without introducing another library or a lot of boilerplate code. The code is small enough to not warrant introducing solutions to avoid that warnings. --- .clang-tidy | 3 ++- src/runtime.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 7d343ea..d42139e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,7 @@ --- Checks: -'clang-diagnostic-*,clang-analyzer-*,performance-*,readability-*,modernize-*,bugprone-*,misc-*,-modernize-use-trailing-return-type' +'clang-diagnostic-*,clang-analyzer-*,performance-*,readability-*,modernize-*,bugprone-*,misc-*, +-modernize-use-trailing-return-type,-bugprone-easily-swappable-parameters,-readability-identifier-length' WarningsAsErrors: '*' HeaderFilterRegex: 'include/aws/.*\.h$' FormatStyle: 'none' diff --git a/src/runtime.cpp b/src/runtime.cpp index 4ca70dc..2ae91e2 100644 --- a/src/runtime.cpp +++ b/src/runtime.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include // for strtoul #include @@ -133,12 +134,16 @@ static size_t read_data(char* buffer, size_t size, size_t nitems, void* userdata } if (unread <= limit) { - std::copy_n(ctx->first.begin() + ctx->second, unread, buffer); + auto from = ctx->first.begin(); + std::advance(from, ctx->second); + std::copy_n(from, unread, buffer); ctx->second += unread; return unread; } - std::copy_n(ctx->first.begin() + ctx->second, limit, buffer); + auto from = ctx->first.begin(); + std::advance(from, ctx->second); + std::copy_n(from, limit, buffer); ctx->second += limit; return limit; } From 29220b38c33a2c89d9df90eecb5393f83786ef8b Mon Sep 17 00:00:00 2001 From: Marco Magdy Date: Tue, 14 Feb 2023 11:54:29 -0800 Subject: [PATCH 2/3] fixup! Fix clang-tidy benign warnings --- include/aws/lambda-runtime/runtime.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/aws/lambda-runtime/runtime.h b/include/aws/lambda-runtime/runtime.h index d19dbc2..46b8817 100644 --- a/include/aws/lambda-runtime/runtime.h +++ b/include/aws/lambda-runtime/runtime.h @@ -129,8 +129,7 @@ class invocation_response { bool is_success() const { return m_success; } }; -struct no_result { -}; +struct no_result {}; class runtime { public: From 662975e166dd02af9283191f7e8ca7950b378e69 Mon Sep 17 00:00:00 2001 From: Marco Magdy Date: Tue, 14 Feb 2023 12:12:08 -0800 Subject: [PATCH 3/3] Turn off clang-format for dependencies Explicitly skip the files rather than mark them with clang-format on/off because marking the files still takes many cpu cycles. Skipping the files in bash is instant. --- ci/codebuild/format-check.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ci/codebuild/format-check.sh b/ci/codebuild/format-check.sh index 222b784..035bd54 100755 --- a/ci/codebuild/format-check.sh +++ b/ci/codebuild/format-check.sh @@ -13,6 +13,11 @@ FAIL=0 SOURCE_FILES=$(find src include tests -type f -name "*.h" -o -name "*.cpp") for i in $SOURCE_FILES do + if [[ "$i" == *"gtest.h" || "$i" == *"backward.h" ]]; then + continue + fi + + echo "$i\n" if [ $($CLANG_FORMAT -output-replacements-xml $i | grep -c "