Commit Graph

13 Commits

Author SHA1 Message Date
Claude
b113f0a7d8 feat(tidy): add fairmq-readability-transfer-code
- Replace -1, -2 and -3 in == and != comparisons with the result of
  Send() or Receive() by static_cast<int64_t>(fair::mq::TransferCode::X).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:29:18 +00:00
Claude
e9afe76155 feat(tidy): add fairmq-bugprone-use-after-send
- Report uses of a MessagePtr after a Send() whose result is discarded.
  After the send the message is empty with zeromq, and still points to
  the sent buffer with shmem, so the same code acts differently per
  transport.
- Walk the CFG from the send with ExprSequence, like
  bugprone-use-after-move. A loop back to the send counts as a use.
- Assignment, reset(), Rebuild(), a new declaration in a loop and
  passing by non-const reference (e.g. to Receive()) give a new message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:29:18 +00:00
Claude
3b3446bfcb feat(tidy): add fairmq-bugprone-unchecked-transfer-result
- Report Receive() calls whose result is discarded. On a timeout, an
  error or an interrupt the message stays empty, and only the result
  tells.
- Report Send() too with the option CheckSend: true. Off by default,
  because many devices ignore the result of Send() on purpose.
- A cast to void discards the result on purpose and is not reported.
- Add Transfer.h with matchers for Send() and Receive() of Device,
  Channel and Socket, and isDiscarded(), for this and later checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:29:18 +00:00
Claude
64ec4d7afa test(tidy): support check options and checks without a fix
- RunCheck.cmake passes a `// TIDY-CONFIG: <yaml>` line of the input to
  --config, e.g. to set check options.
- ClangdCheck.py requires a quick fix only if the input has CHECK-FIXES
  lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:28:53 +00:00
Claude
871e7e54cf feat(tidy): add fairmq-modernize-run-device
- Migrate a device main file from <runFairMQDevice.h> to
  <fairmq/runDevice.h>: the include, the FairMQDevicePtr return type,
  the const ProgOptions& parameter and 'return new T(...)', which becomes
  'return std::make_unique<T>(...)'.
- Fix all of it or nothing: if a return statement of getDevice() is not
  a plain new expression, only report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:28:29 +00:00
Claude
67fd7f2305 feat(tidy): add fairmq-modernize-progoptions-accessors
- Replace GetValue<T>(key) with GetProperty<T>(key, {}) and
  GetStringValue(key) with GetPropertyAsString(key, {}). The {} default
  keeps the old result for an unknown key, where the property API throws.
- Replace SetValue() with SetProperty() only where its always-zero
  result is unused, because SetProperty() returns void.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:28:29 +00:00
Claude
83d0e741f5 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>
2026-11-10 09:28:29 +00:00
Claude
3975017183 feat(tidy): add fairmq-modernize-deprecated-functions
- Replace Device::GetStateName() and Device::GetTransitionName() with
  the free functions fair::mq::GetStateName() and GetTransitionName().
- Replace Socket::GetConstant() of the zeromq and shmem transports with
  fair::mq::zmq::getConstant() and include <fairmq/zeromq/Common.h>.
- Report Socket::Close() without a fix: the socket closes when it is
  destroyed, so the call must go away, not be renamed.
- Skip the fix if the object expression has side effects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:28:23 +00:00
Claude
661fc96fbb feat(tidy): add fairmq-clangd for editor integration
- Add the option BUILD_TIDY_CLANGD (default OFF). It builds
  fairmq-clangd from clangdMain plus the fairmq-* module.
- clangd cannot load plugins, but creates its clang-tidy checks from the
  same registry. Thus the checks run on the AST that clangd builds anyway,
  and editors show their fixes as quick fixes.
- Point clangd to the resource directory of the LLVM installation it was
  built with, unless --resource-dir is given.
- Test each check over LSP with test/tidy/ClangdCheck.py: open the input,
  expect a diagnostic of the check and a quick fix for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:26:45 +00:00
Claude
622daae350 feat(tidy): build the checks as a clang-tidy plugin
- Add the MODULE library fairmq-tidy-plugin, installed as
  libfairmq-tidy-checks.so. It adds the fairmq-* checks to a stock
  clang-tidy of the same LLVM release via --load.
- Do not link the LLVM libraries into the plugin: the loading clang-tidy
  has them.
- Run every check test also through the plugin, if a clang-tidy of the
  found LLVM installation exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:26:45 +00:00
Claude
84ac7aecfd feat(tidy): add fairmq-modernize-channels-access
- Report uses of the deprecated member fair::mq::Device::fChannels.
- Replace fChannels.at(name).at(index) with GetChannel(name, index) and
  every other use with GetChannels().
- Ignore uses inside fair::mq::Device itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:23:27 +00:00
Claude
d4a3c06c7b feat(tidy): add fairmq-modernize-deprecated-headers
- Report includes of the ten deprecated headers, e.g. <FairMQDevice.h>
  or <fairmq/FairMQDevice.h>, and replace them with the successor, e.g.
  <fairmq/Device.h>. Today these headers only emit a #pragma warning.
- Keep the quote style of the include.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:23:27 +00:00
Claude
e32bee2533 test(tidy): check the fairmq-* checks with FileCheck
- Add test/tidy/RunCheck.cmake, a small check_clang_tidy.py: run one
  check with --fix on a copy of the input, then match the diagnostics
  against CHECK-MESSAGES lines and the fixed file against CHECK-FIXES
  lines. Any other warning or error fails the test.
- Register one test per test/tidy/fairmq-*.cxx file. The inputs use the
  real FairMQ headers via the usage requirements of the FairMQ target.
- Skip the tests with a warning if FileCheck is not found.
- Add the test for fairmq-modernize-nonnamespaced-types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:23:27 +00:00