mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 13:11:36 +00:00
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>
This commit is contained in:
33
test/tidy/fairmq-modernize-run-device.cxx
Normal file
33
test/tidy/fairmq-modernize-run-device.cxx
Normal file
@@ -0,0 +1,33 @@
|
||||
// CHECK-FIXES: #include <fairmq/runDevice.h>
|
||||
#include <runFairMQDevice.h>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
struct Sampler : fair::mq::Device
|
||||
{
|
||||
explicit Sampler(int rate) : fRate(rate) {}
|
||||
int fRate;
|
||||
};
|
||||
|
||||
struct Sink : fair::mq::Device
|
||||
{};
|
||||
|
||||
void addCustomOptions(boost::program_options::options_description& options)
|
||||
{
|
||||
options.add_options()("rate", boost::program_options::value<int>()->default_value(1), "rate");
|
||||
}
|
||||
|
||||
// CHECK-MESSAGES: :[[@LINE+1]]:17: warning: 'runFairMQDevice.h' and a raw 'fair::mq::Device*' from 'getDevice()' are superseded; use 'fairmq/runDevice.h' and return a 'std::unique_ptr<fair::mq::Device>' [fairmq-modernize-run-device]
|
||||
FairMQDevicePtr getDevice(const fair::mq::ProgOptions& config)
|
||||
// CHECK-FIXES: std::unique_ptr<fair::mq::Device> getDevice(fair::mq::ProgOptions& config)
|
||||
{
|
||||
if (config.Count("sink")) {
|
||||
return new Sink;
|
||||
// CHECK-FIXES: return std::make_unique<Sink>();
|
||||
}
|
||||
if (config.Count("none")) {
|
||||
return nullptr;
|
||||
}
|
||||
return new Sampler(config.GetProperty<int>("rate"));
|
||||
// CHECK-FIXES: return std::make_unique<Sampler>(config.GetProperty<int>("rate"));
|
||||
}
|
||||
Reference in New Issue
Block a user