mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 13:11:36 +00:00
feat(tidy): add fairmq-modernize-parts-api
- Replace Parts::AtRef(i) with Parts::At(i). At() returns a reference to the MessagePtr, so a following '.' becomes '->', and a lone call gets a leading '*'. - Wrap the raw pointer of Parts::AddPart(Message*) in fair::mq::MessagePtr. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
21
test/tidy/fairmq-modernize-parts-api.cxx
Normal file
21
test/tidy/fairmq-modernize-parts-api.cxx
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <fairmq/Message.h>
|
||||
#include <fairmq/Parts.h>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
std::size_t sizes(fair::mq::Parts& parts, fair::mq::Message* raw)
|
||||
{
|
||||
// CHECK-MESSAGES: :[[@LINE+1]]:11: warning: 'Parts::AddPart(Message*)' is deprecated; pass a 'fair::mq::MessagePtr' [fairmq-modernize-parts-api]
|
||||
parts.AddPart(raw);
|
||||
// CHECK-FIXES: parts.AddPart(fair::mq::MessagePtr(raw));
|
||||
// CHECK-MESSAGES: :[[@LINE+1]]:33: warning: 'Parts::AtRef()' is deprecated; use 'Parts::At()' [fairmq-modernize-parts-api]
|
||||
std::size_t const a = parts.AtRef(0).GetSize();
|
||||
// CHECK-FIXES: std::size_t const a = parts.At(0)->GetSize();
|
||||
// CHECK-MESSAGES: :[[@LINE+1]]:38: warning: 'Parts::AtRef()' is deprecated; use 'Parts::At()' [fairmq-modernize-parts-api]
|
||||
fair::mq::Message& first = parts.AtRef(0);
|
||||
// CHECK-FIXES: fair::mq::Message& first = *parts.At(0);
|
||||
// The current API is not reported.
|
||||
parts.AddPart(fair::mq::MessagePtr(nullptr));
|
||||
std::size_t const b = parts.At(0)->GetSize() + first.GetSize();
|
||||
return a + b;
|
||||
}
|
||||
Reference in New Issue
Block a user