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

@@ -37,6 +37,7 @@ The `fairmq-*` checks are a clang-tidy module ([Module.cxx](/source/fairmq/tidy/
| `fairmq-modernize-deprecated-functions` | Calls of deprecated functions: `Device::GetStateName()`, `Device::GetTransitionName()`, `Socket::GetConstant()`, `Socket::Close()` | The free function, for example `fair::mq::GetStateName()`. No fix for `Close()`. |
| `fairmq-modernize-deprecated-headers` | `#include` lines of the deprecated headers, for example `<FairMQDevice.h>` | The new header, for example `<fairmq/Device.h>` |
| `fairmq-modernize-nonnamespaced-types` | Uses of the deprecated global type aliases, for example `FairMQDevice` or `InputMsgCallback` | The namespaced type, for example `fair::mq::Device` |
| `fairmq-modernize-parts-api` | Calls of `Parts::AtRef()` and of `Parts::AddPart(Message*)` | `At()` with `->` or `*`, and `MessagePtr(p)` |
The checks report a name in a macro, but they do not fix it. Like all clang-tidy checks, they show findings in headers only if the header matches `--header-filter=<regex>`.
@@ -97,6 +98,14 @@ The check finds uses of `fChannels` outside of `fair::mq::Device`:
The check does not fix a call on an object expression with side effects, for example `makeDevice()->GetStateName(s)`.
### fairmq-modernize-parts-api
| Code | Fix |
| --- | --- |
| `parts.AtRef(i).GetSize()` | `parts.At(i)->GetSize()` |
| `auto& msg = parts.AtRef(i);` | `auto& msg = *parts.At(i);` |
| `parts.AddPart(rawPtr)` | `parts.AddPart(fair::mq::MessagePtr(rawPtr))` |
## Build fairmq-tidy
Set the CMake option `BUILD_TIDY_TOOL` (default `OFF`) when you configure FairMQ: