From aa80ea812691da87df499687e19ffe80860ea915 Mon Sep 17 00:00:00 2001 From: Simon Hoinkis Date: Mon, 18 Jul 2022 19:23:17 +0200 Subject: [PATCH 1/4] iox-#1196 Fix left-over clang-tidy warnings in cxx::vector Signed-off-by: Simon Hoinkis --- iceoryx_hoofs/include/iceoryx_hoofs/cxx/vector.hpp | 4 ++-- .../include/iceoryx_hoofs/internal/cxx/vector.inl | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/vector.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/vector.hpp index 104ca6df93..2057eff384 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/vector.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/vector.hpp @@ -200,10 +200,10 @@ class vector const T& at_unchecked(const uint64_t index) const noexcept; /// @todo #1196 Replace with UninitializedArray - // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays) + // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays) using element_t = uint8_t[sizeof(T)]; alignas(T) element_t m_data[Capacity]; - // NOLINTEND(cppcoreguidelines-avoid-c-arrays) + // NOLINTEND(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays) uint64_t m_size{0U}; }; } // namespace cxx diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl index 6db9442b94..ca36c7f1a4 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl @@ -25,6 +25,8 @@ namespace iox { namespace cxx { +// NOLINTJUSTIFICATION Not all elements in the array shall be initialized +// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init) template inline vector::vector(const uint64_t count, const T& value) noexcept { @@ -41,6 +43,8 @@ inline vector::vector(const uint64_t count, const T& value) noexcep } } +// NOLINTJUSTIFICATION Not all elements in the array shall be initialized +// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init) template inline vector::vector(const uint64_t count) noexcept { @@ -58,12 +62,16 @@ inline vector::vector(const uint64_t count) noexcept } } +// NOLINTJUSTIFICATION Not all elements in the array shall be initialized +// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init) template inline vector::vector(const vector& rhs) noexcept { *this = rhs; } +// NOLINTJUSTIFICATION Not all elements in the array shall be initialized +// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init) template inline vector::vector(vector&& rhs) noexcept { From 2c99a383139020c6b27448e8676a0a7cbb8c5919 Mon Sep 17 00:00:00 2001 From: Simon Hoinkis Date: Tue, 19 Jul 2022 11:43:32 +0200 Subject: [PATCH 2/4] iox-#1196 Remove space between NOLINTNEXTLINE and '(' and add CI check Signed-off-by: Simon Hoinkis --- .../include/iceoryx_hoofs/cxx/variant.hpp | 2 +- .../internal/cxx/function_ref.inl | 6 ++-- .../internal/cxx/poor_mans_heap.inl | 2 +- .../iceoryx_hoofs/internal/cxx/unique_ptr.inl | 4 +-- .../iceoryx_hoofs/internal/cxx/variant.inl | 14 +++++----- .../internal/cxx/variant_internal.hpp | 28 +++++++++---------- .../iceoryx_hoofs/internal/cxx/vector.inl | 21 +++++++------- .../moduletests/test_concurrent_loffli.cpp | 6 ++-- .../moduletests/test_cxx_forward_list.cpp | 28 +++++++++---------- .../moduletests/test_cxx_function_ref.cpp | 7 +++-- .../test_cxx_functional_interface_expect.cpp | 2 +- .../test/moduletests/test_cxx_string.cpp | 16 +++++------ .../test/moduletests/test_cxx_unique_ptr.cpp | 6 ++-- .../test/moduletests/test_cxx_variant.cpp | 20 ++++++------- .../test/moduletests/test_cxx_vector.cpp | 28 +++++++++---------- .../test/moduletests/test_file_reader.cpp | 2 +- tools/scripts/clang_tidy_check.sh | 7 +++++ 17 files changed, 105 insertions(+), 94 deletions(-) diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant.hpp index cc620eae33..3d83d3271d 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant.hpp @@ -178,7 +178,7 @@ class variant /// @return reference to the variant itself template // Correct return type is used through enable_if - // NOLINTNEXTLINE (cppcoreguidelines-c-copy-assignment-signature) + // NOLINTNEXTLINE(cppcoreguidelines-c-copy-assignment-signature) typename std::enable_if&>::value, variant>::type& operator=(T&& rhs) noexcept; diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/function_ref.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/function_ref.inl index ca99108f76..368c3906cf 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/function_ref.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/function_ref.inl @@ -35,7 +35,7 @@ template inline function_ref::function_ref(CallableType&& callable) noexcept // AXIVION Next Construct AutosarC++19_03-A5.2.4, AutosarC++19_03-A5.2.3, CertC++-EXP55 : Type-safety ensured by // casting back on call - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast, cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast, cppcoreguidelines-pro-type-const-cast) : m_pointerToCallable(const_cast(reinterpret_cast(std::addressof(callable)))) // AXIVION Next Line AutosarC++19_03-A15.4.4 : Lambda not 'noexcept' as callable might throw , m_functionPointer([](void* target, ArgTypes... args) -> ReturnType { @@ -54,7 +54,7 @@ inline function_ref::function_ref(ReturnType (&function // the cast is required to work on POSIX systems // AXIVION Next Construct AutosarC++19_03-A5.2.4, AutosarC++19_03-A5.2.4-M5.2.6 : Type-safety ensured by casting // back function pointer on call - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) : m_pointerToCallable(reinterpret_cast(function)) , // the lambda does not capture and is thus convertible to a function pointer @@ -62,7 +62,7 @@ inline function_ref::function_ref(ReturnType (&function m_functionPointer([](void* target, ArgTypes... args) -> ReturnType { using PointerType = ReturnType (*)(ArgTypes...); // AXIVION Next Construct AutosarC++19_03-A5.2.4 : The class design ensures a cast to the actual type of target - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast,hicpp-use-auto) PointerType f = reinterpret_cast(target); // AXIVION Next Line AutosarC++19_03-A5.3.2 : Check for 'nullptr' is performed on call return f(args...); diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/poor_mans_heap.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/poor_mans_heap.inl index 4cf67898bf..de4ecfcb31 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/poor_mans_heap.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/poor_mans_heap.inl @@ -33,7 +33,7 @@ PoorMansHeap::~PoorMansHeap() noexcept deleteInstance(); } -// NOLINTNEXTLINE (cppcoreguidelines-pro-type-member-init,hicpp-member-init) justification in header +// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init) justification in header template template // NOLINTNEXTLINE(hicpp-named-parameter, readability-named-parameter) justification in header diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/unique_ptr.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/unique_ptr.inl index 9a6bcb5c14..258c9a1a0f 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/unique_ptr.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/unique_ptr.inl @@ -77,7 +77,7 @@ template const T* unique_ptr::operator->() const noexcept { // Avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast(get()); } @@ -97,7 +97,7 @@ template const T* unique_ptr::get() const noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.3 : Avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast*>(this)->get(); } diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant.inl index b3aa10f488..332dc7cbe3 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant.inl @@ -37,7 +37,7 @@ inline constexpr variant::variant(const variant& rhs) noexcept template template // First param is helper struct only -// NOLINTNEXTLINE (hicpp-named-parameter) +// NOLINTNEXTLINE(hicpp-named-parameter) inline constexpr variant::variant(const in_place_index&, CTorArguments&&... args) noexcept { emplace_at_index(std::forward(args)...); @@ -46,7 +46,7 @@ inline constexpr variant::variant(const in_place_index&, CTorArgume template template // First param is helper struct only -// NOLINTNEXTLINE (hicpp-named-parameter) +// NOLINTNEXTLINE(hicpp-named-parameter) inline constexpr variant::variant(const in_place_type&, CTorArguments&&... args) noexcept { emplace(std::forward(args)...); @@ -139,7 +139,7 @@ inline void variant::call_element_destructor() noexcept } // Correct return type is used through enable_if -// NOLINTNEXTLINE (cppcoreguidelines-c-copy-assignment-signature) +// NOLINTNEXTLINE(cppcoreguidelines-c-copy-assignment-signature) template template inline typename std::enable_if&>::value, variant>::type& @@ -224,7 +224,7 @@ variant::get_at_index() const noexcept { using T = typename internal::get_type_at_index<0, TypeIndex, Types...>::type; // AXIVION Next Construct AutosarC++19_03-A5.2.3 : avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast(const_cast(this)->template get_at_index()); } @@ -237,7 +237,7 @@ inline const T* variant::get() const noexcept return nullptr; } // AXIVION Next Construct AutosarC++19_03-A5.2.3 : avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return static_cast(static_cast(m_storage)); } @@ -246,7 +246,7 @@ template inline T* variant::get() noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.3 : avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast(const_cast(this)->get()); } @@ -255,7 +255,7 @@ template inline T* variant::get_if(T* defaultValue) noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.3 : avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast(const_cast(this)->get_if(const_cast(defaultValue))); } diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_internal.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_internal.hpp index 631f736a59..518332ac17 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_internal.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_internal.hpp @@ -99,7 +99,7 @@ struct call_at_index if (N == index) { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type safety ensured through template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) reinterpret_cast(ptr)->~T(); } else @@ -113,7 +113,7 @@ struct call_at_index if (N == index) { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type safety ensured through template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) *reinterpret_cast(destination) = std::move(*reinterpret_cast(source)); } else @@ -127,7 +127,7 @@ struct call_at_index if (N == index) { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type safety ensured through template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) new (destination) T(std::move(*reinterpret_cast(source))); } else @@ -141,7 +141,7 @@ struct call_at_index if (N == index) { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type safety ensured through template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) *reinterpret_cast(destination) = *reinterpret_cast(source); } else @@ -155,7 +155,7 @@ struct call_at_index if (N == index) { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type safety ensured through template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) new (destination) T(*reinterpret_cast(source)); } else @@ -169,13 +169,13 @@ template struct call_at_index { // d'tor changes the data to which source is pointing to - // NOLINTNEXTLINE (readability-non-const-parameter) + // NOLINTNEXTLINE(readability-non-const-parameter) static void destructor(const uint64_t index, byte_t* ptr) noexcept { if (N == index) { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type safety ensured through template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) reinterpret_cast(ptr)->~T(); } else @@ -185,13 +185,13 @@ struct call_at_index } // move c'tor changes the data to which source is pointing to - // NOLINTNEXTLINE (readability-non-const-parameter) + // NOLINTNEXTLINE(readability-non-const-parameter) static void move(const uint64_t index, byte_t* source, byte_t* destination) noexcept { if (N == index) { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type safety ensured through template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) *reinterpret_cast(destination) = std::move(*reinterpret_cast(source)); } else @@ -201,13 +201,13 @@ struct call_at_index } // Both 'source' and 'destination' will be changed and can't be const - // NOLINTNEXTLINE (readability-non-const-parameter) + // NOLINTNEXTLINE(readability-non-const-parameter) static void moveConstructor(const uint64_t index, byte_t* source, byte_t* destination) noexcept { if (N == index) { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type safety ensured through template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) new (destination) T(std::move(*reinterpret_cast(source))); } else @@ -221,7 +221,7 @@ struct call_at_index if (N == index) { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type safety ensured through template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) *reinterpret_cast(destination) = *reinterpret_cast(source); } else @@ -231,13 +231,13 @@ struct call_at_index } // 'operator new()' needs non-const 'destination' - // NOLINTNEXTLINE (readability-non-const-parameter) + // NOLINTNEXTLINE(readability-non-const-parameter) static void copyConstructor(const uint64_t index, const byte_t* source, byte_t* destination) noexcept { if (N == index) { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type safety ensured through template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) new (destination) T(*reinterpret_cast(source)); } else diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl index ca36c7f1a4..c435129cdb 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl @@ -258,7 +258,7 @@ template inline T* vector::data() noexcept { // AXIVION Next Line AutosarC++19_03-A5.2.3 : const cast to avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast(const_cast*>(this)->data()); } @@ -272,7 +272,7 @@ template inline T& vector::at(const uint64_t index) noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.3 : const cast to avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast(const_cast*>(this)->at(index)); } @@ -306,7 +306,7 @@ template inline const T& vector::front() const noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.3 : const cast to avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast*>(this)->front(); } @@ -321,7 +321,7 @@ template inline const T& vector::back() const noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.3 : const cast to avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast*>(this)->back(); } @@ -329,7 +329,7 @@ template inline typename vector::iterator vector::begin() noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.3 : const cast to avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast(const_cast*>(this)->begin()); } @@ -337,7 +337,7 @@ template inline typename vector::const_iterator vector::begin() const noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type-safety ensured by template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) return reinterpret_cast(&at_unchecked(0)); } @@ -345,7 +345,7 @@ template inline typename vector::iterator vector::end() noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.3 : const cast to avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast(const_cast*>(this)->end()); } @@ -353,7 +353,7 @@ template inline typename vector::const_iterator vector::end() const noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type-safety ensured by template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) return reinterpret_cast(&(at_unchecked(0)) + m_size); } @@ -378,7 +378,7 @@ template T& vector::at_unchecked(const uint64_t index) noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.3 : const cast to avoid code duplication - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return const_cast(const_cast*>(this)->at_unchecked(index)); } @@ -386,7 +386,8 @@ template const T& vector::at_unchecked(const uint64_t index) const noexcept { // AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type-safety ensured by template parameter - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast) + // NOLINTJUSTIFICATION User accessible method at() performs bounds check + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast,cppcoreguidelines-pro-bounds-pointer-arithmetic) return reinterpret_cast(m_data)[index]; } diff --git a/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp b/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp index de8e33c3c4..91d1b1f5c0 100644 --- a/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp +++ b/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp @@ -62,7 +62,7 @@ TYPED_TEST(LoFFLi_test, Misuse_NullptrMemory) ::testing::Test::RecordProperty("TEST_ID", "ab877f29-cab0-48ae-a2c0-054633b6415a"); decltype(this->m_loffli) loFFLi; // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(loFFLi.init(nullptr, 1), ".*"); } @@ -73,7 +73,7 @@ TYPED_TEST(LoFFLi_test, Misuse_ZeroSize) uint32_t memoryLoFFLi[4]; decltype(this->m_loffli) loFFLi; // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(loFFLi.init(memoryLoFFLi, 0), ".*"); } @@ -84,7 +84,7 @@ TYPED_TEST(LoFFLi_test, Misuse_SizeToLarge) uint32_t memoryLoFFLi[4]; decltype(this->m_loffli) loFFLi; // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(loFFLi.init(memoryLoFFLi, UINT32_MAX - 1), ".*"); } diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_forward_list.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_forward_list.cpp index 0c52780cea..feb7a66e9c 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_forward_list.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_forward_list.cpp @@ -293,7 +293,7 @@ TEST_F(forward_list_test, FullWhenFilledWithMoreThanCapacityElements) EXPECT_THAT(sut.full(), Eq(true)); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(sut.emplace_front(), ""); } TEST_F(forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneElements) @@ -667,7 +667,7 @@ TEST_F(forward_list_test, EmplaceAfterWithWrongListIterator) } // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(sut11.emplace_after(iterOfSut12, cnt), ""); } @@ -1167,37 +1167,37 @@ TEST_F(forward_list_test, IteratorComparisonOfDifferentLists) auto iterSut1 = sut11.begin(); auto iterSut2 = sut12.begin(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(dummyFunc(iterSut1 == iterSut2), ""); iterSut1 = sut11.before_begin(); iterSut2 = sut12.before_begin(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(dummyFunc(iterSut1 == iterSut2), ""); iterSut1 = sut11.end(); iterSut2 = sut12.end(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(dummyFunc(iterSut1 == iterSut2), ""); iterSut1 = sut11.begin(); iterSut2 = sut12.begin(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(dummyFunc(iterSut1 != iterSut2), ""); iterSut1 = sut11.before_begin(); iterSut2 = sut12.before_begin(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(dummyFunc(iterSut1 != iterSut2), ""); iterSut1 = sut11.end(); iterSut2 = sut12.end(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(dummyFunc(iterSut1 != iterSut2), ""); } @@ -1987,7 +1987,7 @@ TEST_F(forward_list_test, invalidIteratorErase) sut.pop_front(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(sut.erase_after(iter), ""); } @@ -2004,7 +2004,7 @@ TEST_F(forward_list_test, invalidIteratorIncrement) sut.pop_front(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(++iter, ""); } @@ -2021,7 +2021,7 @@ TEST_F(forward_list_test, invalidIteratorComparison) sut.pop_front(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(dummyFunc(sut.cbegin() == iter), ""); } @@ -2038,7 +2038,7 @@ TEST_F(forward_list_test, invalidIteratorComparisonUnequal) auto iter2 = sut.cbegin(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(dummyFunc(iter2 != iter), ""); } @@ -2055,7 +2055,7 @@ TEST_F(forward_list_test, invalidIteratorDereferencing) sut.pop_front(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(sut.remove(*iter), ""); } @@ -2072,7 +2072,7 @@ TEST_F(forward_list_test, invalidIteratorAddressOfOperator) sut.pop_front(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(dummyFunc(iter->m_value == 12U), ""); } diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_function_ref.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_function_ref.cpp index d0e717e320..862b611b01 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_function_ref.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_function_ref.cpp @@ -166,8 +166,11 @@ TEST_F(function_refDeathTest, CallMovedFromLeadsToTermination) function_ref sut1{lambda}; function_ref sut2{std::move(sut1)}; // Use after move is tested here - // NOLINTNEXTLINE (bugprone-use-after-move) + // NOLINTBEGIN(bugprone-use-after-move, hicpp-invalid-access-moved, cppcoreguidelines-pro-type-vararg, + // cppcoreguidelines-avoid-goto) EXPECT_DEATH(sut1(), "Empty function_ref invoked"); + // NOLINTEND(bugprone-use-after-move, hicpp-invalid-access-moved, cppcoreguidelines-pro-type-vararg, + // cppcoreguidelines-avoid-goto) } TEST_F(function_refTest, CreateValidAndSwapResultEqual) @@ -219,7 +222,7 @@ TEST_F(function_refTest, CreateValidWithFreeFunctionResultEqual) TEST_F(function_refTest, CreateValidWithComplexTypeResultEqual) { ::testing::Test::RecordProperty("TEST_ID", "7c6a4bf0-989f-4d15-a905-03fddf6d80bc"); - ComplexType fuubar{1, 2, 1.3f}; + ComplexType fuubar{1, 2, 1.3F}; function_ref sut(returnComplexType); EXPECT_THAT(sut(fuubar), Eq(fuubar)); } diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp index b2af894e71..4648f66f26 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp @@ -86,7 +86,7 @@ void ExpectDoesCallTerminateWhenObjectIsInvalid(const ExpectCall& callExpect) auto handle = iox::ErrorHandlerMock::setTemporaryErrorHandler([&](auto, auto) { std::terminate(); }); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH(callExpect(sut), ".*"); } } diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_string.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_string.cpp index 7d1b14fdd1..c5ce268e51 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_string.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_string.cpp @@ -3292,7 +3292,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOfEmptyStringViaAtFails) { ::testing::Test::RecordProperty("TEST_ID", "89817818-f05a-4ceb-8663-9727d227048c"); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH({ this->testSubject.at(0U); }, "Out of bounds access!"); } @@ -3302,7 +3302,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaAtFails) using MyString = typename TestFixture::stringType; constexpr auto STRINGCAP = MyString().capacity(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH({ this->testSubject.at(STRINGCAP); }, "Out of bounds access!"); } @@ -3337,7 +3337,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOfEmptyStringViaConstAtFails) constexpr auto STRINGCAP = MyString().capacity(); const string sut; // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH({ sut.at(0U); }, "Out of bounds access!"); } @@ -3348,7 +3348,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaConstAtFails) constexpr auto STRINGCAP = MyString().capacity(); const string sut; // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH({ sut.at(STRINGCAP); }, "Out of bounds access"); } @@ -3378,7 +3378,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOfEmptyStringViaSubscriptOperatorFail { ::testing::Test::RecordProperty("TEST_ID", "95ced457-1aec-47e9-a496-0197ea3f4600"); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH({ this->testSubject[0U]; }, "Out of bounds access!"); } @@ -3388,7 +3388,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaSubscriptOperatorFails) using MyString = typename TestFixture::stringType; constexpr auto STRINGCAP = MyString().capacity(); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH({ this->testSubject[STRINGCAP]; }, "Out of bounds access!"); } @@ -3423,7 +3423,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOfEmptyStringViaConstSubscriptOperato constexpr auto STRINGCAP = MyString().capacity(); const string sut; // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH({ sut[0U]; }, "Out of bounds access!"); } @@ -3434,7 +3434,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaConstSubscriptOperatorF constexpr auto STRINGCAP = MyString().capacity(); const string sut; // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH({ sut[STRINGCAP]; }, "Out of bounds access!"); } diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_unique_ptr.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_unique_ptr.cpp index 4fc7a3dcc7..df9479e783 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_unique_ptr.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_unique_ptr.cpp @@ -108,7 +108,7 @@ TEST_F(UniquePtrTest, CtorUsingMoveWithObjectPtrAndDeleterSetsPtrToObjectAndCall // no deleter called during move EXPECT_FALSE(m_deleterCalled); // check if move is invalidating the object - // NOLINTNEXTLINE (bugprone-use-after-move) + // NOLINTNEXTLINE(bugprone-use-after-move) EXPECT_FALSE(sut); EXPECT_EQ(anotherSut.get(), object); } @@ -134,7 +134,7 @@ TEST_F(UniquePtrTest, MoveAssignmentUniquePtrsSetsPtrToObjectAndCallsDeleter) // no deleter called during move EXPECT_FALSE(m_deleterCalled); // check if move is invalidating the object - // NOLINTNEXTLINE (bugprone-use-after-move) + // NOLINTNEXTLINE(bugprone-use-after-move) EXPECT_FALSE(sut); EXPECT_EQ(anotherSut.get(), object); } @@ -165,7 +165,7 @@ TEST_F(UniquePtrTest, MoveAssignmentOverwriteAUniquePtrWithAnotherOneAndCallsAno // SUT deleter not called during move EXPECT_FALSE(m_deleterCalled); // check if move is invalidating the object - // NOLINTNEXTLINE (bugprone-use-after-move) + // NOLINTNEXTLINE(bugprone-use-after-move) EXPECT_FALSE(sut); EXPECT_EQ(anotherSut.get(), object); } diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_variant.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_variant.cpp index 552fb4ad06..4a6b52f4ac 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_variant.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_variant.cpp @@ -47,7 +47,7 @@ class variant_Test : public Test { public: // Ok-ish for tests - // NOLINTNEXTLINE (bugprone-easily-swappable-parameters) + // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) ComplexClass(int a, float b) : a(a) , b(b) @@ -232,7 +232,7 @@ TEST_F(variant_Test, ConstGetOnUninitializedVariantFails) { ::testing::Test::RecordProperty("TEST_ID", "16b511c8-e56a-48c9-bbff-5a7d07e7a500"); // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->get(), Eq(nullptr)); } @@ -241,7 +241,7 @@ TEST_F(variant_Test, constGetVariantWithCorrectValue) ::testing::Test::RecordProperty("TEST_ID", "4419f569-0541-43ab-8448-9ba10556b459"); sut.emplace(123.12F); // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->get(), Ne(nullptr)); } @@ -250,7 +250,7 @@ TEST_F(variant_Test, ConstGetVariantWithIncorrectValueFails) ::testing::Test::RecordProperty("TEST_ID", "979e1131-e981-4f67-bef2-a1fe4770c5a6"); sut.emplace(123.12F); // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->get(), Eq(nullptr)); } @@ -314,7 +314,7 @@ TEST_F(variant_Test, CopyCTorWithoutValueResultsInInvalidVariant) ::testing::Test::RecordProperty("TEST_ID", "31b12efc-4f2d-4b3c-ad72-c12ca8a0cfc3"); iox::cxx::variant schlomo; // Copy c'tor shall be tested - // NOLINTNEXTLINE (performance-unnecessary-copy-initialization) + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) iox::cxx::variant ignatz(schlomo); ASSERT_THAT(ignatz.index(), Eq(iox::cxx::INVALID_VARIANT_INDEX)); } @@ -355,7 +355,7 @@ TEST_F(variant_Test, MoveCTorWithValueLeadsToSameValue) ASSERT_THAT(ignatz.get(), Ne(nullptr)); EXPECT_THAT(*ignatz.get(), Eq(123)); // check if move is invalidating the object - // NOLINTNEXTLINE (bugprone-use-after-move) + // NOLINTNEXTLINE(bugprone-use-after-move,hicpp-invalid-access-moved,clang-analyzer-cplusplus.Move) EXPECT_THAT(schlomo.index(), Eq(0U)); } @@ -403,7 +403,7 @@ TEST_F(variant_Test, CreatingSecondObjectViaCopyCTorResultsInTwoDTorCalls) DTorTest::dtorWasCalled = false; { // Copy c'tor shall be tested - // NOLINTNEXTLINE (performance-unnecessary-copy-initialization) + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) iox::cxx::variant schlomo(ignatz); EXPECT_THAT(DTorTest::dtorWasCalled, Eq(false)); } @@ -443,7 +443,7 @@ TEST_F(variant_Test, CreatingSecondObjectViaMoveCTorResultsInTwoDTorCalls) iox::cxx::variant schlomo(std::move(ignatz)); EXPECT_THAT(DTorTest::dtorWasCalled, Eq(false)); // check if move is invalidating the object - // NOLINTNEXTLINE (bugprone-use-after-move) + // NOLINTNEXTLINE(bugprone-use-after-move,hicpp-invalid-access-moved,clang-analyzer-cplusplus.Move) EXPECT_THAT(ignatz.index(), Eq(1U)); } EXPECT_THAT(DTorTest::dtorWasCalled, Eq(true)); @@ -464,7 +464,7 @@ TEST_F(variant_Test, CreatingSecondObjectViaMoveAssignmentResultsInTwoDTorCalls) schlomo.emplace(123); schlomo = std::move(ignatz); // check if move is invalidating the object - // NOLINTNEXTLINE (bugprone-use-after-move) + // NOLINTNEXTLINE(bugprone-use-after-move,hicpp-invalid-access-moved,clang-analyzer-cplusplus.Move) EXPECT_THAT(ignatz.index(), Eq(1U)); EXPECT_THAT(DTorTest::dtorWasCalled, Eq(false)); } @@ -608,7 +608,7 @@ TEST_F(variant_Test, ComplexDTorWithCopyCTor) { iox::cxx::variant schlomo{iox::cxx::in_place_type()}; // Copy c'tor shall be tested - // NOLINTNEXTLINE (performance-unnecessary-copy-initialization) + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) iox::cxx::variant sut{schlomo}; } diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_vector.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_vector.cpp index 959e4090c5..a3213121a3 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_vector.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_vector.cpp @@ -341,7 +341,7 @@ TEST_F(vector_test, CopyConstructorWithEmptyVector) ::testing::Test::RecordProperty("TEST_ID", "438c8835-8545-40e4-b544-d66107507e2f"); vector sut1; // Testing empty copy - // NOLINTNEXTLINE (performance-unnecessary-copy-initialization) + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) vector sut2(sut1); EXPECT_THAT(copyCTor, Eq(0U)); EXPECT_THAT(sut2.size(), Eq(0U)); @@ -662,7 +662,7 @@ TEST_F(vector_test, BeginEndConstIteratorAreTheSameWhenEmpty) { ::testing::Test::RecordProperty("TEST_ID", "51a9a205-dfff-4abe-b68e-1254d46865f0"); // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->begin() == const_cast(&sut)->end(), Eq(true)); } @@ -679,7 +679,7 @@ TEST_F(vector_test, BeginConstIteratorComesBeforeEndConstIteratorWhenNotEmpty) ::testing::Test::RecordProperty("TEST_ID", "c1a101ff-c840-45d2-acf8-f2de2fd504c7"); sut.emplace_back(1U); // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->begin() < const_cast(&sut)->end(), Eq(true)); } @@ -702,7 +702,7 @@ TEST_F(vector_test, BeginConstIteratorComesBeforeEndConstIteratorWhenFull) sut.emplace_back(i); } // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->begin() < const_cast(&sut)->end(), Eq(true)); } @@ -736,8 +736,8 @@ TEST_F(vector_test, ConstIteratorIteratesThroughNonEmptyVector) uint64_t count = 0U; // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) - for (auto& v : *const_cast(&sut)) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) + for (const auto& v : *const_cast(&sut)) { EXPECT_THAT(v, Eq(INITIAL_VALUE + count)); ++count; @@ -773,7 +773,7 @@ TEST_F(vector_test, ConstIteratorIteratesThroughFullVector) int i = 0; // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) for (const auto& v : *const_cast(&sut)) { EXPECT_THAT(v, Eq(142 * (i++))); @@ -791,7 +791,7 @@ TEST_F(vector_test, IterateUsingData) for (uint64_t k = 0U; k < sut.size(); ++k) { // Bounds considered - // NOLINTNEXTLINE (cppcoreguidelines-pro-bounds-pointer-arithmetic) + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) EXPECT_THAT(sut.data()[k], Eq(127U + k)); } } @@ -805,8 +805,8 @@ TEST_F(vector_test, IterateUsingConstData) for (uint64_t k = 0U; k < sut.size(); ++k) { - // Bounds considered - // NOLINTNEXTLINE (cppcoreguidelines-pro-bounds-pointer-arithmetic) + // Bounds considered, const method tested + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic,cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->data()[k], Eq(3127U + k)); } } @@ -834,7 +834,7 @@ TEST_F(vector_test, IterateUsingConstAt) for (uint64_t k = 0; k < sut.size(); ++k) { // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->at(k), Eq(3127U + k)); } } @@ -862,7 +862,7 @@ TEST_F(vector_test, IterateUsingConstSquareBracket) for (uint64_t k = 0; k < sut.size(); ++k) { // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT((*const_cast(&sut))[k], Eq(4127U + k)); } } @@ -1023,7 +1023,7 @@ TEST_F(vector_test, ConstFrontPointsToFirstElement) sut.emplace_back(9U); // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->front(), Eq(7U)); } @@ -1035,7 +1035,7 @@ TEST_F(vector_test, ConstBackPointsToLastElement) sut.emplace_back(12U); // Re-use 'sut' and testing const methods - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->back(), Eq(12U)); } diff --git a/iceoryx_hoofs/test/moduletests/test_file_reader.cpp b/iceoryx_hoofs/test/moduletests/test_file_reader.cpp index 0528a5afb4..6c1ca2bc29 100644 --- a/iceoryx_hoofs/test/moduletests/test_file_reader.cpp +++ b/iceoryx_hoofs/test/moduletests/test_file_reader.cpp @@ -160,7 +160,7 @@ TEST_F(FileReader_test, errorTerminateMode) std::set_terminate([]() { std::cout << "", std::abort(); }); // todo #1196 remove EXPECT_DEATH - // NOLINTNEXTLINE (cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c) EXPECT_DEATH( { iox::cxx::FileReader reader("ISaidNo!", "InTheMiddleOfNowhere", iox::cxx::FileReader::ErrorMode::Terminate); diff --git a/tools/scripts/clang_tidy_check.sh b/tools/scripts/clang_tidy_check.sh index 646f6c95fb..421b098d67 100755 --- a/tools/scripts/clang_tidy_check.sh +++ b/tools/scripts/clang_tidy_check.sh @@ -56,6 +56,13 @@ fi echo "Using clang-tidy version:" $CLANG_TIDY_CMD --version +noSpaceInSuppressions=$(git ls-files | grep -E "$FILE_FILTER" | xargs grep -h "// NOLINTNEXTLINE (") +if [[ -n "$noSpaceInSuppressions" ]]; then + echo -e "\e[1;31mRemove space between NOLINTNEXTLINE and '('!\e[m" + echo "$noSpaceInSuppressions" + false +fi + if [[ "$MODE" == "hook"* ]]; then FILES=$(git diff --cached --name-only --diff-filter=CMRT | grep -E "$FILE_FILTER" | grep -Ev "$FILE_BLACKLIST" | cat) # List only added files From 1e48d5e025fc82aa76283d048ca6fe1c9e700e79 Mon Sep 17 00:00:00 2001 From: Simon Hoinkis Date: Tue, 19 Jul 2022 16:14:34 +0200 Subject: [PATCH 3/4] iox-#1196 Add missing 'NOLINTJUSTIFICATION' Signed-off-by: Simon Hoinkis --- .../include/iceoryx_hoofs/cxx/variant.hpp | 2 +- .../iceoryx_hoofs/internal/cxx/variant.inl | 6 ++--- .../internal/cxx/variant_internal.hpp | 8 +++---- .../iceoryx_hoofs/internal/cxx/vector.inl | 2 +- .../moduletests/test_cxx_function_ref.cpp | 2 +- .../test/moduletests/test_cxx_unique_ptr.cpp | 6 ++--- .../test/moduletests/test_cxx_variant.cpp | 20 ++++++++-------- .../test/moduletests/test_cxx_vector.cpp | 24 +++++++++---------- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant.hpp index 3d83d3271d..3af99bcc06 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant.hpp @@ -177,7 +177,7 @@ class variant /// @param[in] rhs source object for the underlying move assignment /// @return reference to the variant itself template - // Correct return type is used through enable_if + // NOLINTJUSTIFICATION Correct return type is used through enable_if // NOLINTNEXTLINE(cppcoreguidelines-c-copy-assignment-signature) typename std::enable_if&>::value, variant>::type& operator=(T&& rhs) noexcept; diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant.inl index 332dc7cbe3..02d4d0c9f6 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant.inl @@ -36,7 +36,7 @@ inline constexpr variant::variant(const variant& rhs) noexcept template template -// First param is helper struct only +// NOLINTJUSTIFICATION First param is helper struct only // NOLINTNEXTLINE(hicpp-named-parameter) inline constexpr variant::variant(const in_place_index&, CTorArguments&&... args) noexcept { @@ -45,7 +45,7 @@ inline constexpr variant::variant(const in_place_index&, CTorArgume template template -// First param is helper struct only +// NOLINTJUSTIFICATION First param is helper struct only // NOLINTNEXTLINE(hicpp-named-parameter) inline constexpr variant::variant(const in_place_type&, CTorArguments&&... args) noexcept { @@ -138,7 +138,7 @@ inline void variant::call_element_destructor() noexcept } } -// Correct return type is used through enable_if +// NOLINTJUSTIFICATION Correct return type is used through enable_if // NOLINTNEXTLINE(cppcoreguidelines-c-copy-assignment-signature) template template diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_internal.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_internal.hpp index 518332ac17..2ae9fe7399 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_internal.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_internal.hpp @@ -168,7 +168,7 @@ struct call_at_index template struct call_at_index { - // d'tor changes the data to which source is pointing to + // NOLINTJUSTIFICATION d'tor changes the data to which source is pointing to // NOLINTNEXTLINE(readability-non-const-parameter) static void destructor(const uint64_t index, byte_t* ptr) noexcept { @@ -184,7 +184,7 @@ struct call_at_index } } - // move c'tor changes the data to which source is pointing to + // NOLINTJUSTIFICATION move c'tor changes the data to which source is pointing to // NOLINTNEXTLINE(readability-non-const-parameter) static void move(const uint64_t index, byte_t* source, byte_t* destination) noexcept { @@ -200,7 +200,7 @@ struct call_at_index } } - // Both 'source' and 'destination' will be changed and can't be const + // NOLINTJUSTIFICATION Both 'source' and 'destination' will be changed and can't be const // NOLINTNEXTLINE(readability-non-const-parameter) static void moveConstructor(const uint64_t index, byte_t* source, byte_t* destination) noexcept { @@ -230,7 +230,7 @@ struct call_at_index } } - // 'operator new()' needs non-const 'destination' + // NOLINTJUSTIFICATION 'operator new()' needs non-const 'destination' // NOLINTNEXTLINE(readability-non-const-parameter) static void copyConstructor(const uint64_t index, const byte_t* source, byte_t* destination) noexcept { diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl index c435129cdb..eccbb9e6eb 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl @@ -25,7 +25,7 @@ namespace iox { namespace cxx { -// NOLINTJUSTIFICATION Not all elements in the array shall be initialized +// NOLINTJUSTIFICATION See header and todo, using UninitializedArray will solve the issue // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init) template inline vector::vector(const uint64_t count, const T& value) noexcept diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_function_ref.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_function_ref.cpp index 862b611b01..769c1dc6c4 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_function_ref.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_function_ref.cpp @@ -165,7 +165,7 @@ TEST_F(function_refDeathTest, CallMovedFromLeadsToTermination) auto lambda = []() -> int { return 7654; }; function_ref sut1{lambda}; function_ref sut2{std::move(sut1)}; - // Use after move is tested here + // NOLINTJUSTIFICATION Use after move is tested here // NOLINTBEGIN(bugprone-use-after-move, hicpp-invalid-access-moved, cppcoreguidelines-pro-type-vararg, // cppcoreguidelines-avoid-goto) EXPECT_DEATH(sut1(), "Empty function_ref invoked"); diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_unique_ptr.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_unique_ptr.cpp index df9479e783..c9e01cd60b 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_unique_ptr.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_unique_ptr.cpp @@ -107,7 +107,7 @@ TEST_F(UniquePtrTest, CtorUsingMoveWithObjectPtrAndDeleterSetsPtrToObjectAndCall // no deleter called during move EXPECT_FALSE(m_deleterCalled); - // check if move is invalidating the object + // NOLINTJUSTIFICATION check if move is invalidating the object // NOLINTNEXTLINE(bugprone-use-after-move) EXPECT_FALSE(sut); EXPECT_EQ(anotherSut.get(), object); @@ -133,7 +133,7 @@ TEST_F(UniquePtrTest, MoveAssignmentUniquePtrsSetsPtrToObjectAndCallsDeleter) // no deleter called during move EXPECT_FALSE(m_deleterCalled); - // check if move is invalidating the object + // NOLINTJUSTIFICATION check if move is invalidating the object // NOLINTNEXTLINE(bugprone-use-after-move) EXPECT_FALSE(sut); EXPECT_EQ(anotherSut.get(), object); @@ -164,7 +164,7 @@ TEST_F(UniquePtrTest, MoveAssignmentOverwriteAUniquePtrWithAnotherOneAndCallsAno EXPECT_TRUE(m_anotherDeleterCalled); // SUT deleter not called during move EXPECT_FALSE(m_deleterCalled); - // check if move is invalidating the object + // NOLINTJUSTIFICATION check if move is invalidating the object // NOLINTNEXTLINE(bugprone-use-after-move) EXPECT_FALSE(sut); EXPECT_EQ(anotherSut.get(), object); diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_variant.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_variant.cpp index 4a6b52f4ac..e97dde53fb 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_variant.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_variant.cpp @@ -46,7 +46,7 @@ class variant_Test : public Test class ComplexClass { public: - // Ok-ish for tests + // NOLINTJUSTIFICATION Ok-ish for tests // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) ComplexClass(int a, float b) : a(a) @@ -231,7 +231,7 @@ TEST_F(variant_Test, GetVariantWithIncorrectValueFails) TEST_F(variant_Test, ConstGetOnUninitializedVariantFails) { ::testing::Test::RecordProperty("TEST_ID", "16b511c8-e56a-48c9-bbff-5a7d07e7a500"); - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->get(), Eq(nullptr)); } @@ -240,7 +240,7 @@ TEST_F(variant_Test, constGetVariantWithCorrectValue) { ::testing::Test::RecordProperty("TEST_ID", "4419f569-0541-43ab-8448-9ba10556b459"); sut.emplace(123.12F); - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->get(), Ne(nullptr)); } @@ -249,7 +249,7 @@ TEST_F(variant_Test, ConstGetVariantWithIncorrectValueFails) { ::testing::Test::RecordProperty("TEST_ID", "979e1131-e981-4f67-bef2-a1fe4770c5a6"); sut.emplace(123.12F); - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->get(), Eq(nullptr)); } @@ -313,7 +313,7 @@ TEST_F(variant_Test, CopyCTorWithoutValueResultsInInvalidVariant) { ::testing::Test::RecordProperty("TEST_ID", "31b12efc-4f2d-4b3c-ad72-c12ca8a0cfc3"); iox::cxx::variant schlomo; - // Copy c'tor shall be tested + // NOLINTJUSTIFICATION Copy c'tor shall be tested // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) iox::cxx::variant ignatz(schlomo); ASSERT_THAT(ignatz.index(), Eq(iox::cxx::INVALID_VARIANT_INDEX)); @@ -354,7 +354,7 @@ TEST_F(variant_Test, MoveCTorWithValueLeadsToSameValue) iox::cxx::variant ignatz(std::move(schlomo)); ASSERT_THAT(ignatz.get(), Ne(nullptr)); EXPECT_THAT(*ignatz.get(), Eq(123)); - // check if move is invalidating the object + // NOLINTJUSTIFICATION check if move is invalidating the object // NOLINTNEXTLINE(bugprone-use-after-move,hicpp-invalid-access-moved,clang-analyzer-cplusplus.Move) EXPECT_THAT(schlomo.index(), Eq(0U)); } @@ -402,7 +402,7 @@ TEST_F(variant_Test, CreatingSecondObjectViaCopyCTorResultsInTwoDTorCalls) ignatz.emplace(); DTorTest::dtorWasCalled = false; { - // Copy c'tor shall be tested + // NOLINTJUSTIFICATION Copy c'tor shall be tested // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) iox::cxx::variant schlomo(ignatz); EXPECT_THAT(DTorTest::dtorWasCalled, Eq(false)); @@ -442,7 +442,7 @@ TEST_F(variant_Test, CreatingSecondObjectViaMoveCTorResultsInTwoDTorCalls) { iox::cxx::variant schlomo(std::move(ignatz)); EXPECT_THAT(DTorTest::dtorWasCalled, Eq(false)); - // check if move is invalidating the object + // NOLINTJUSTIFICATION check if move is invalidating the object // NOLINTNEXTLINE(bugprone-use-after-move,hicpp-invalid-access-moved,clang-analyzer-cplusplus.Move) EXPECT_THAT(ignatz.index(), Eq(1U)); } @@ -463,7 +463,7 @@ TEST_F(variant_Test, CreatingSecondObjectViaMoveAssignmentResultsInTwoDTorCalls) iox::cxx::variant schlomo; schlomo.emplace(123); schlomo = std::move(ignatz); - // check if move is invalidating the object + // NOLINTJUSTIFICATION check if move is invalidating the object // NOLINTNEXTLINE(bugprone-use-after-move,hicpp-invalid-access-moved,clang-analyzer-cplusplus.Move) EXPECT_THAT(ignatz.index(), Eq(1U)); EXPECT_THAT(DTorTest::dtorWasCalled, Eq(false)); @@ -607,7 +607,7 @@ TEST_F(variant_Test, ComplexDTorWithCopyCTor) DoubleDelete::dtorCalls = 0; { iox::cxx::variant schlomo{iox::cxx::in_place_type()}; - // Copy c'tor shall be tested + // NOLINTJUSTIFICATION Copy c'tor shall be tested // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) iox::cxx::variant sut{schlomo}; } diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_vector.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_vector.cpp index a3213121a3..de0d2a9147 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_vector.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_vector.cpp @@ -340,7 +340,7 @@ TEST_F(vector_test, CopyConstructorWithEmptyVector) { ::testing::Test::RecordProperty("TEST_ID", "438c8835-8545-40e4-b544-d66107507e2f"); vector sut1; - // Testing empty copy + // NOLINTJUSTIFICATION Testing empty copy // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) vector sut2(sut1); EXPECT_THAT(copyCTor, Eq(0U)); @@ -661,7 +661,7 @@ TEST_F(vector_test, BeginEndIteratorAreTheSameWhenEmpty) TEST_F(vector_test, BeginEndConstIteratorAreTheSameWhenEmpty) { ::testing::Test::RecordProperty("TEST_ID", "51a9a205-dfff-4abe-b68e-1254d46865f0"); - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->begin() == const_cast(&sut)->end(), Eq(true)); @@ -678,7 +678,7 @@ TEST_F(vector_test, BeginConstIteratorComesBeforeEndConstIteratorWhenNotEmpty) { ::testing::Test::RecordProperty("TEST_ID", "c1a101ff-c840-45d2-acf8-f2de2fd504c7"); sut.emplace_back(1U); - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->begin() < const_cast(&sut)->end(), Eq(true)); @@ -701,7 +701,7 @@ TEST_F(vector_test, BeginConstIteratorComesBeforeEndConstIteratorWhenFull) { sut.emplace_back(i); } - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->begin() < const_cast(&sut)->end(), Eq(true)); @@ -735,7 +735,7 @@ TEST_F(vector_test, ConstIteratorIteratesThroughNonEmptyVector) const uint64_t EXPECTED_END_COUNT = sut.size(); uint64_t count = 0U; - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) for (const auto& v : *const_cast(&sut)) { @@ -772,7 +772,7 @@ TEST_F(vector_test, ConstIteratorIteratesThroughFullVector) const auto EXPECTED_END_COUNT = sut.size(); int i = 0; - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) for (const auto& v : *const_cast(&sut)) { @@ -790,7 +790,7 @@ TEST_F(vector_test, IterateUsingData) for (uint64_t k = 0U; k < sut.size(); ++k) { - // Bounds considered + // NOLINTJUSTIFICATION Bounds considered // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) EXPECT_THAT(sut.data()[k], Eq(127U + k)); } @@ -805,7 +805,7 @@ TEST_F(vector_test, IterateUsingConstData) for (uint64_t k = 0U; k < sut.size(); ++k) { - // Bounds considered, const method tested + // NOLINTJUSTIFICATION Bounds considered, const method tested // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic,cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->data()[k], Eq(3127U + k)); } @@ -833,7 +833,7 @@ TEST_F(vector_test, IterateUsingConstAt) for (uint64_t k = 0; k < sut.size(); ++k) { - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->at(k), Eq(3127U + k)); } @@ -861,7 +861,7 @@ TEST_F(vector_test, IterateUsingConstSquareBracket) for (uint64_t k = 0; k < sut.size(); ++k) { - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT((*const_cast(&sut))[k], Eq(4127U + k)); } @@ -1022,7 +1022,7 @@ TEST_F(vector_test, ConstFrontPointsToFirstElement) sut.emplace_back(8U); sut.emplace_back(9U); - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->front(), Eq(7U)); } @@ -1034,7 +1034,7 @@ TEST_F(vector_test, ConstBackPointsToLastElement) sut.emplace_back(11U); sut.emplace_back(12U); - // Re-use 'sut' and testing const methods + // NOLINTJUSTIFICATION Re-use 'sut' and testing const methods // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) EXPECT_THAT(const_cast(&sut)->back(), Eq(12U)); } From 7eb4a39fb0ff81ad7f34a7afb72c25bf3cbb8b14 Mon Sep 17 00:00:00 2001 From: Simon Hoinkis Date: Wed, 20 Jul 2022 00:41:26 +0200 Subject: [PATCH 4/4] iox-#1196 Suppress return code in clang-tidy script Signed-off-by: Simon Hoinkis --- tools/scripts/clang_tidy_check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/scripts/clang_tidy_check.sh b/tools/scripts/clang_tidy_check.sh index 421b098d67..b8da988fa1 100755 --- a/tools/scripts/clang_tidy_check.sh +++ b/tools/scripts/clang_tidy_check.sh @@ -56,11 +56,11 @@ fi echo "Using clang-tidy version:" $CLANG_TIDY_CMD --version -noSpaceInSuppressions=$(git ls-files | grep -E "$FILE_FILTER" | xargs grep -h "// NOLINTNEXTLINE (") +noSpaceInSuppressions=$(git ls-files | grep -E "$FILE_FILTER" | grep -Ev "$FILE_BLACKLIST" | xargs -I {} grep -h '// NOLINTNEXTLINE (' {} || true) if [[ -n "$noSpaceInSuppressions" ]]; then echo -e "\e[1;31mRemove space between NOLINTNEXTLINE and '('!\e[m" echo "$noSpaceInSuppressions" - false + exit 1 fi if [[ "$MODE" == "hook"* ]]; then