Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iox-#1196 Fix left-over clang-tidy warnings in cxx::vector and remove space in suppressions #1525

Conversation

mossmaurice
Copy link
Contributor

@mossmaurice mossmaurice commented Jul 19, 2022

Signed-off-by: Simon Hoinkis [email protected]

Pre-Review Checklist for the PR Author

  1. Code follows the coding style of CONTRIBUTING.md
  2. Tests follow the best practice for testing
  3. Changelog updated in the unreleased section including API breaking changes
  4. Branch follows the naming format (iox-#123-this-is-a-branch)
  5. Commits messages are according to this guideline
    • Commit messages have the issue ID (iox-#123 commit text)
    • Commit messages are signed (git commit -s)
    • Commit author matches Eclipse Contributor Agreement (and ECA is signed)
  6. Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  7. Relevant issues are linked
  8. Add sensible notes for the reviewer
  9. All checks have passed (except task-list-completed)
  10. Assign PR to reviewer

Notes for Reviewer

  • Supress some left-over clang-tidy findings
  • // NOLINTNEXTLINE (foobar) suppresses all findings
    • Added a check to ensure // NOLINTNEXTLINE(foobar)

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Code according to our coding style and naming conventions
  • Unit tests have been written for new behavior
    • Each unit test case has a unique UUID
  • Public API changes are documented via doxygen
  • Copyright owner are updated in the changed files
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

@mossmaurice mossmaurice added the clang-tidy Warning of a clang-tidy rule label Jul 19, 2022
@mossmaurice mossmaurice self-assigned this Jul 19, 2022
@mossmaurice mossmaurice force-pushed the iox-#1196-fix-more-clang-tidy-warnings-in-vector branch from aa36345 to 909afb4 Compare July 19, 2022 08:34
@dkroenke
Copy link
Member

Can we consider to add these files to https://github.com/eclipse-iceoryx/iceoryx/blob/master/clang-tidy-files-to-scan.txt?
Is it intended to close the ticket once the PR is merged or do we want to keep it open? If the latter case applies you can change it to Relates.

@mossmaurice mossmaurice changed the title iox-#1196 Fix left-over clang-tidy warnings in cxx::vector iox-#1196 Fix left-over clang-tidy warnings in cxx::vector and remove space in suppressions Jul 19, 2022
@mossmaurice
Copy link
Contributor Author

mossmaurice commented Jul 19, 2022

@dkroenke

Can we consider to add these files to https://github.com/eclipse-iceoryx/iceoryx/blob/master/clang-tidy-files-to-scan.txt? Is it intended to close the ticket once the PR is merged or do we want to keep it open?

I don't understand the strategy here. Shall we add each class after having it ticked in the list? Or will we enable everything once done with #1196?

If the latter case applies you can change it to Relates.

Unfortunately, that doesn't work. PR and issue are then not linked.

@mossmaurice mossmaurice force-pushed the iox-#1196-fix-more-clang-tidy-warnings-in-vector branch from e35a823 to 179f391 Compare July 19, 2022 10:04
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think bound checks have nothing to do with a reinterpret_cast usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elfenpiff You have to look more carefully above and below ;) Here, two warnings are suppressed:

  1. reinterpret_cast for Axivion with justification and clang-tidy without duplicate justification
  2. Bounds safety issue of working with raw array instead of std::span, justification only for clang-tidy

@@ -166,8 +166,11 @@ TEST_F(function_refDeathTest, CallMovedFromLeadsToTermination)
function_ref<int()> sut1{lambda};
function_ref<int()> 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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does multiline NOLINTBEGIN work? Is this ignored when you run clang-tidy manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elfenpiff Unfortunately, I'm still running clang 13 locally, which does not support this syntax. However, the clang15 in the CI seems to run fine with.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works also locally for me.

iceoryx_hoofs/test/moduletests/test_cxx_vector.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_cxx_variant.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_cxx_unique_ptr.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_cxx_function_ref.cpp Outdated Show resolved Hide resolved
tools/scripts/clang_tidy_check.sh Outdated Show resolved Hide resolved
@mossmaurice mossmaurice removed the request for review from dkroenke July 19, 2022 13:52
@@ -166,8 +166,11 @@ TEST_F(function_refDeathTest, CallMovedFromLeadsToTermination)
function_ref<int()> sut1{lambda};
function_ref<int()> 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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works also locally for me.

@mossmaurice mossmaurice force-pushed the iox-#1196-fix-more-clang-tidy-warnings-in-vector branch 2 times, most recently from 3eb629b to 7eb4a39 Compare July 19, 2022 23:03
@codecov
Copy link

codecov bot commented Jul 19, 2022

Codecov Report

Merging #1525 (3eb629b) into master (f85ee4b) will increase coverage by 0.01%.
The diff coverage is n/a.

❗ Current head 3eb629b differs from pull request most recent head 7eb4a39. Consider uploading reports for the commit 7eb4a39 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1525      +/-   ##
==========================================
+ Coverage   78.96%   78.98%   +0.01%     
==========================================
  Files         378      378              
  Lines       14464    14464              
  Branches     2010     2010              
==========================================
+ Hits        11422    11424       +2     
+ Misses       2412     2411       -1     
+ Partials      630      629       -1     
Flag Coverage Δ
unittests 78.64% <ø> (+0.01%) ⬆️
unittests_timing 14.90% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ceoryx_hoofs/include/iceoryx_hoofs/cxx/variant.hpp 100.00% <ø> (ø)
iceoryx_hoofs/include/iceoryx_hoofs/cxx/vector.hpp 100.00% <ø> (ø)
...nclude/iceoryx_hoofs/internal/cxx/function_ref.inl 93.33% <ø> (ø)
...lude/iceoryx_hoofs/internal/cxx/poor_mans_heap.inl 100.00% <ø> (ø)
.../include/iceoryx_hoofs/internal/cxx/unique_ptr.inl 96.66% <ø> (ø)
...ofs/include/iceoryx_hoofs/internal/cxx/variant.inl 95.78% <ø> (ø)
...de/iceoryx_hoofs/internal/cxx/variant_internal.hpp 78.00% <ø> (ø)
...oofs/include/iceoryx_hoofs/internal/cxx/vector.inl 96.59% <ø> (ø)
iceoryx_hoofs/source/concurrent/loffli.cpp 91.42% <0.00%> (+5.71%) ⬆️

@mossmaurice mossmaurice merged commit d550821 into eclipse-iceoryx:master Jul 20, 2022
@mossmaurice mossmaurice deleted the iox-#1196-fix-more-clang-tidy-warnings-in-vector branch July 20, 2022 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-tidy Warning of a clang-tidy rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable clang-tidy checks and fix warnings in code
4 participants