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:
Claude
2026-11-09 22:57:09 +00:00
parent 3975017183
commit 83d0e741f5
6 changed files with 167 additions and 0 deletions

View 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;
}