Skip to content

Commit

Permalink
iox-#1196 Remove space between NOLINTNEXTLINE and '(' and add CI check
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Hoinkis <[email protected]>
  • Loading branch information
mossmaurice committed Jul 19, 2022
1 parent 909afb4 commit 179f391
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 94 deletions.
2 changes: 1 addition & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class variant
/// @return reference to the variant itself
template <typename T>
// Correct return type is used through enable_if
// NOLINTNEXTLINE (cppcoreguidelines-c-copy-assignment-signature)
// NOLINTNEXTLINE(cppcoreguidelines-c-copy-assignment-signature)
typename std::enable_if<!std::is_same<T, variant<Types...>&>::value, variant<Types...>>::type&
operator=(T&& rhs) noexcept;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ template <typename CallableType, typename>
inline function_ref<ReturnType(ArgTypes...)>::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<void*>(reinterpret_cast<const void*>(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 {
Expand All @@ -54,15 +54,15 @@ inline function_ref<ReturnType(ArgTypes...)>::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<void*>(function))
,
// the lambda does not capture and is thus convertible to a function pointer
// (required by the C++ standard)
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<PointerType>(target);
// AXIVION Next Line AutosarC++19_03-A5.3.2 : Check for 'nullptr' is performed on call
return f(args...);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PoorMansHeap<Interface, TypeSize, TypeAlignment>::~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 <typename Interface, uint64_t TypeSize, uint64_t TypeAlignment>
template <typename Type, typename... CTorArgs>
// NOLINTNEXTLINE(hicpp-named-parameter, readability-named-parameter) justification in header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ template <typename T>
const T* unique_ptr<T>::operator->() const noexcept
{
// Avoid code duplication
// NOLINTNEXTLINE (cppcoreguidelines-pro-type-const-cast)
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
return const_cast<const T*>(get());
}

Expand All @@ -97,7 +97,7 @@ template <typename T>
const T* unique_ptr<T>::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<unique_ptr<T>*>(this)->get();
}

Expand Down
14 changes: 7 additions & 7 deletions iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant.inl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ inline constexpr variant<Types...>::variant(const variant& rhs) noexcept
template <typename... Types>
template <uint64_t N, typename... CTorArguments>
// First param is helper struct only
// NOLINTNEXTLINE (hicpp-named-parameter)
// NOLINTNEXTLINE(hicpp-named-parameter)
inline constexpr variant<Types...>::variant(const in_place_index<N>&, CTorArguments&&... args) noexcept
{
emplace_at_index<N>(std::forward<CTorArguments>(args)...);
Expand All @@ -46,7 +46,7 @@ inline constexpr variant<Types...>::variant(const in_place_index<N>&, CTorArgume
template <typename... Types>
template <typename T, typename... CTorArguments>
// First param is helper struct only
// NOLINTNEXTLINE (hicpp-named-parameter)
// NOLINTNEXTLINE(hicpp-named-parameter)
inline constexpr variant<Types...>::variant(const in_place_type<T>&, CTorArguments&&... args) noexcept
{
emplace<T>(std::forward<CTorArguments>(args)...);
Expand Down Expand Up @@ -139,7 +139,7 @@ inline void variant<Types...>::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 <typename... Types>
template <typename T>
inline typename std::enable_if<!std::is_same<T, variant<Types...>&>::value, variant<Types...>>::type&
Expand Down Expand Up @@ -224,7 +224,7 @@ variant<Types...>::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 T*>(const_cast<variant*>(this)->template get_at_index<TypeIndex>());
}

Expand All @@ -237,7 +237,7 @@ inline const T* variant<Types...>::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<const T*>(static_cast<const void*>(m_storage));
}

Expand All @@ -246,7 +246,7 @@ template <typename T>
inline T* variant<Types...>::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<T*>(const_cast<const variant*>(this)->get<T>());
}

Expand All @@ -255,7 +255,7 @@ template <typename T>
inline T* variant<Types...>::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<T*>(const_cast<const variant*>(this)->get_if<T>(const_cast<const T*>(defaultValue)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T*>(ptr)->~T();
}
else
Expand All @@ -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<T*>(destination) = std::move(*reinterpret_cast<T*>(source));
}
else
Expand All @@ -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<T*>(source)));
}
else
Expand All @@ -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<T*>(destination) = *reinterpret_cast<const T*>(source);
}
else
Expand All @@ -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<const T*>(source));
}
else
Expand All @@ -169,13 +169,13 @@ template <uint64_t N, typename T>
struct call_at_index<N, T>
{
// 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<T*>(ptr)->~T();
}
else
Expand All @@ -185,13 +185,13 @@ struct call_at_index<N, T>
}

// 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<T*>(destination) = std::move(*reinterpret_cast<T*>(source));
}
else
Expand All @@ -201,13 +201,13 @@ struct call_at_index<N, T>
}

// 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<T*>(source)));
}
else
Expand All @@ -221,7 +221,7 @@ struct call_at_index<N, T>
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<T*>(destination) = *reinterpret_cast<const T*>(source);
}
else
Expand All @@ -231,13 +231,13 @@ struct call_at_index<N, T>
}

// '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<const T*>(source));
}
else
Expand Down
21 changes: 11 additions & 10 deletions iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ template <typename T, uint64_t Capacity>
inline T* vector<T, Capacity>::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<T*>(const_cast<const vector<T, Capacity>*>(this)->data());
}

Expand All @@ -272,7 +272,7 @@ template <typename T, uint64_t Capacity>
inline T& vector<T, Capacity>::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<T&>(const_cast<const vector<T, Capacity>*>(this)->at(index));
}

Expand Down Expand Up @@ -306,7 +306,7 @@ template <typename T, uint64_t Capacity>
inline const T& vector<T, Capacity>::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<vector<T, Capacity>*>(this)->front();
}

Expand All @@ -321,39 +321,39 @@ template <typename T, uint64_t Capacity>
inline const T& vector<T, Capacity>::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<vector<T, Capacity>*>(this)->back();
}

template <typename T, uint64_t Capacity>
inline typename vector<T, Capacity>::iterator vector<T, Capacity>::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<iterator>(const_cast<const vector<T, Capacity>*>(this)->begin());
}

template <typename T, uint64_t Capacity>
inline typename vector<T, Capacity>::const_iterator vector<T, Capacity>::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<const_iterator>(&at_unchecked(0));
}

template <typename T, uint64_t Capacity>
inline typename vector<T, Capacity>::iterator vector<T, Capacity>::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<iterator>(const_cast<const vector<T, Capacity>*>(this)->end());
}

template <typename T, uint64_t Capacity>
inline typename vector<T, Capacity>::const_iterator vector<T, Capacity>::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<const_iterator>(&(at_unchecked(0)) + m_size);
}

Expand All @@ -378,15 +378,16 @@ template <typename T, uint64_t Capacity>
T& vector<T, Capacity>::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<T&>(const_cast<const vector<T, Capacity>*>(this)->at_unchecked(index));
}

template <typename T, uint64_t Capacity>
const T& vector<T, Capacity>::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<const T*>(m_data)[index];
}

Expand Down
6 changes: 3 additions & 3 deletions iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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), ".*");
}

Expand All @@ -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), ".*");
}

Expand All @@ -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), ".*");
}

Expand Down
Loading

0 comments on commit 179f391

Please sign in to comment.