-
Notifications
You must be signed in to change notification settings - Fork 501
[CodeHealth] Fix clang-tidy warnings part 1 #3493
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
[CodeHealth] Fix clang-tidy warnings part 1 #3493
Conversation
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3493 +/- ##
==========================================
+ Coverage 89.92% 89.95% +0.03%
==========================================
Files 219 219
Lines 7042 7039 -3
==========================================
- Hits 6332 6331 -1
+ Misses 710 708 -2
🚀 New features to boost your workflow:
|
| { | ||
| LastValuePointData merge_data = nostd::get<LastValuePointData>(ToPoint()); | ||
| return std::unique_ptr<Aggregation>(new LongLastValueAggregation(std::move(merge_data))); | ||
| return std::unique_ptr<Aggregation>(new LongLastValueAggregation(merge_data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes:
warning: std::move of the variable 'merge_data' of the trivially-copyable type 'LastValuePointData' has no effect [performance-move-const-arg]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bellieve it's a mistake of clang. But it's OK to copy LastValuePointData because it's small and will not cost a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. The class is trivially copyable, but we could consider disabling this warning with clang-tidy and keep the std::move. I'd prefer to keep the warning enabled and remove the moves that don't have any effect.
| { | ||
| public: | ||
| DoubleLastValueAggregation(); | ||
| DoubleLastValueAggregation(LastValuePointData &&); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LastValuePointData is trivially-copyable and std::move has no effect.
| public: | ||
| explicit OtlpFileOstreamBackend(const std::reference_wrapper<std::ostream> &os) : os_(os) {} | ||
|
|
||
| ~OtlpFileOstreamBackend() override {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes
warning: class 'OtlpFileOstreamBackend' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]| { | ||
| public: | ||
| LongSumAggregation(bool is_monotonic); | ||
| LongSumAggregation(SumPointData &&); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SumPointData is trivially-copyable and std::move has no effect.
| { | ||
| LastValuePointData merge_data = nostd::get<LastValuePointData>(ToPoint()); | ||
| return std::unique_ptr<Aggregation>(new LongLastValueAggregation(std::move(merge_data))); | ||
| return std::unique_ptr<Aggregation>(new LongLastValueAggregation(merge_data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bellieve it's a mistake of clang. But it's OK to copy LastValuePointData because it's small and will not cost a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the cleanup.
Contributes to #2053
Changes
Fix some clang-tidy warnings:
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes