Skip to content

Commit 8885abc

Browse files
committed
Fixes hinted by clang-tidy
Modernize the code
1 parent 538d55f commit 8885abc

14 files changed

Lines changed: 44 additions & 49 deletions

Framework/src/AlfaReceiverForTests.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool AlfaReceiverForTests::HandleData(FairMQMessagePtr &msg, int /*index*/)
3434
LOG(INFO) << "Received an object of size " << msg->GetSize();
3535

3636
TestTMessage tm(msg->GetData(), msg->GetSize());
37-
MonitorObject *mo = dynamic_cast<MonitorObject *>(tm.ReadObject(tm.GetClass()));
37+
auto *mo = dynamic_cast<MonitorObject *>(tm.ReadObject(tm.GetClass()));
3838

3939
LOG(INFO) << " Name : \"" << mo->GetName() << "\"";
4040

Framework/src/Checker.cxx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <TSystem.h>
1111
#include <TClass.h>
1212
// O2
13-
#include "Common/Exceptions.h"
13+
#include <Common/Exceptions.h>
1414
#include <Configuration/ConfigurationFactory.h>
1515
// QC
1616
#include "QualityControl/DatabaseFactory.h"
@@ -57,7 +57,7 @@ Checker::Checker(std::string checkerName, std::string configurationSource)
5757

5858
// monitoring
5959
try {
60-
mCollector = std::shared_ptr<AliceO2::Monitoring::Collector>(new AliceO2::Monitoring::Collector(configurationSource));
60+
mCollector = std::make_shared<AliceO2::Monitoring::Collector>(configurationSource);
6161
mCollector->addDerivedMetric("objects", AliceO2::Monitoring::DerivedMetricMode::RATE);
6262
} catch (...) {
6363
string diagnostic = boost::current_exception_diagnostic_information();
@@ -131,7 +131,7 @@ Checker::~Checker()
131131
int size_t2int(size_t val)
132132
{
133133
if (val > INT_MAX) {
134-
throw new out_of_range("Conversion from size_t to int failed.");
134+
throw out_of_range("Conversion from size_t to int failed.");
135135
}
136136
return (int) val;
137137
}
@@ -147,7 +147,7 @@ bool Checker::HandleData(FairMQMessagePtr &msg, int index)
147147

148148
// Deserialize the object and process it
149149
HistoMessage tm(msg->GetData(), size_t2int(msg->GetSize()));
150-
MonitorObject *mo = dynamic_cast<MonitorObject *>(tm.ReadObject(tm.GetClass()));
150+
auto *mo = dynamic_cast<MonitorObject *>(tm.ReadObject(tm.GetClass()));
151151
if (mo) {
152152
mo->setIsOwner(true);
153153
check(mo);
@@ -162,7 +162,6 @@ bool Checker::HandleData(FairMQMessagePtr &msg, int index)
162162
endLastObject = system_clock::now();
163163
// if 10 seconds elapsed publish stats
164164
if (timer.isTimeout()) {
165-
double current = timer.getTime();
166165
timer.reset(1000000); // 10 s.
167166
mCollector->send(mTotalNumberHistosReceived, "objects");
168167
}
@@ -228,7 +227,7 @@ void Checker::send(MonitorObject *mo)
228227
/// \param libraryName The name of the library to load.
229228
void Checker::loadLibrary(const string libraryName)
230229
{
231-
if (boost::algorithm::trim_copy(libraryName) == "") {
230+
if (boost::algorithm::trim_copy(libraryName).empty()) {
232231
mLogger << "no library name specified" << AliceO2::InfoLogger::InfoLogger::endm;
233232
return;
234233
}
@@ -255,9 +254,9 @@ CheckInterface *Checker::instantiateCheck(string checkName, string className)
255254
mLogger << "Loading class " << className << AliceO2::InfoLogger::InfoLogger::endm;
256255
cl = TClass::GetClass(className.c_str());
257256
if (!cl) {
258-
tempString += " because no dictionary for class named \"";
257+
tempString += R"( because no dictionary for class named ")";
259258
tempString += className;
260-
tempString += "\" could be retrieved";
259+
tempString += R"(" could be retrieved)";
261260
cerr << tempString << endl;
262261
BOOST_THROW_EXCEPTION(FatalException() << errinfo_details(tempString));
263262
}
@@ -270,9 +269,9 @@ CheckInterface *Checker::instantiateCheck(string checkName, string className)
270269
mLogger << "Instantiating class " << className << " (" << cl << ")" << AliceO2::InfoLogger::InfoLogger::endm;
271270
result = static_cast<CheckInterface *>(cl->New());
272271
if (!result) {
273-
tempString += " because the class named \"";
272+
tempString += R"( because the class named ")";
274273
tempString += className;
275-
tempString += "\" does not follow the TaskInterface interface";
274+
tempString += R"( because the class named ")";
276275
BOOST_THROW_EXCEPTION(FatalException() << errinfo_details(tempString));
277276
}
278277
result->configure(checkName);

Framework/src/Consumer.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int main(int argc, char *argv[])
8282
std::cout << "SVN revision : " << o2::quality_control::core::Version::getRevision() << std::endl;
8383
return EXIT_SUCCESS;
8484
}
85-
string configurationSource = "";
85+
string configurationSource;
8686
if (vm.count("configuration")) {
8787
configurationSource = vm["configuration"].as<string>();
8888
} /*else {

Framework/src/MonitorObject.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace quality_control {
1212
namespace core {
1313

1414
MonitorObject::MonitorObject()
15-
: TObject(), mName(""), mObject(nullptr), mQuality(Quality::Null), mTaskName(""), mIsOwner(true)
15+
: TObject(), mName(""), mQuality(Quality::Null), mObject(nullptr), mTaskName(""), mIsOwner(true)
1616
{
1717
}
1818

@@ -24,7 +24,7 @@ MonitorObject::~MonitorObject()
2424
}
2525

2626
MonitorObject::MonitorObject(const std::string &name, TObject *object, const std::string &taskName)
27-
: TObject(), mName(name), mObject(object), mQuality(Quality::Null), mTaskName(taskName), mIsOwner(true)
27+
: TObject(), mName(name), mQuality(Quality::Null), mObject(object), mTaskName(taskName), mIsOwner(true)
2828
{
2929

3030
}

Framework/src/MySqlDatabase.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ o2::quality_control::core::MonitorObject* MySqlDatabase::retrieve(std::string ta
178178
statement->SetString(0, objectName.c_str());
179179

180180
if (!(statement->Process() && statement->StoreResult())) {
181-
if (statement)
182-
delete statement;
181+
delete statement;
183182
BOOST_THROW_EXCEPTION(
184183
DatabaseException()
185184
<< errinfo_details("Encountered an error when processing and storing results in MySqlDatabase")
@@ -203,8 +202,7 @@ o2::quality_control::core::MonitorObject* MySqlDatabase::retrieve(std::string ta
203202
mess.Reset();
204203
mo = (o2::quality_control::core::MonitorObject*) (mess.ReadObjectAny(mess.GetClass()));
205204
}
206-
if (statement)
207-
delete statement;
205+
delete statement;
208206

209207
return mo;
210208
}

Framework/src/SpyMainFrame.cxx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ SpyMainFrame::SpyMainFrame(SpyDevice *spyDevice, string configurationSource)
4747
throw;
4848
}
4949
} else {
50-
mDbInterface = 0;
50+
mDbInterface = nullptr;
5151
}
5252
cout << "mDbInterface : " << mDbInterface << endl;
5353

@@ -61,9 +61,7 @@ SpyMainFrame::SpyMainFrame(SpyDevice *spyDevice, string configurationSource)
6161

6262
SpyMainFrame::~SpyMainFrame()
6363
{
64-
if (mDrawnObject) {
65-
delete mDrawnObject;
66-
}
64+
delete mDrawnObject;
6765
std::map<std::string, TGButton *>::iterator iter;
6866
for (iter = mMapButtons.begin(); iter != mMapButtons.end(); iter++) {
6967
delete iter->second;
@@ -105,7 +103,7 @@ void SpyMainFrame::constructWindow()
105103
mSourceFairmq = new TGRadioButton(mRadioButtonGroup, "FairMQ");
106104
mSourceDb = new TGRadioButton(mRadioButtonGroup, "Database");
107105
mSourceFairmq->SetOn();
108-
if (mDbInterface == 0) {
106+
if (mDbInterface == nullptr) {
109107
mSourceDb->SetEnabled(false);
110108
mSourceDb->SetToolTipText("Pass a config file to enable the database option.");
111109
}
@@ -296,10 +294,10 @@ void SpyMainFrame::dbRun()
296294
// Get list of objects
297295
string s = "data_";
298296
s += mTaskField->GetText();
299-
vector<string> objectNames = mDbInterface->getPublishedObjectNames(s.c_str());
297+
vector<string> objectNames = mDbInterface->getPublishedObjectNames(s);
300298

301299
// UpdateList for each
302-
for (auto name : objectNames) {
300+
for (const auto &name : objectNames) {
303301
updateList(name, mTaskField->GetText());
304302
}
305303
}

Framework/src/TaskDevice.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ unsigned long TaskDevice::publish()
188188

189189
for (auto &pair : *mObjectsManager) {
190190
auto *mo = pair.second;
191-
TMessage *message = new TMessage(kMESS_OBJECT); // will be deleted by fairmq using our custom method
191+
auto *message = new TMessage(kMESS_OBJECT); // will be deleted by fairmq using our custom method
192192
message->WriteObjectAny(mo, mo->IsA());
193193
FairMQMessagePtr msg(NewMessage(message->Buffer(),
194194
message->BufferSize(),

Framework/src/qcCheckerLauncher.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
5959
} else {
6060
// we don't use the "required" option of the po::value because we want to output the help and avoid
6161
// horrible template error to be displayed to the user.
62-
std::cout << "\"name\" is required!" << "\n";
62+
std::cout << R"("name" is required!)" << "\n";
6363
std::cout << desc << std::endl;
6464
return EXIT_FAILURE;
6565
}
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
6868
} else {
6969
// we don't use the "required" option of the po::value because we want to output the help and avoid
7070
// horrible template error to be displayed to the user.
71-
std::cout << "\"configuration\" is required!" << "\n";
71+
std::cout << R"("configuration" is required!)" << "\n";
7272
std::cout << desc << std::endl;
7373
return EXIT_FAILURE;
7474
}
@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
9090
cout << "We will get data from this address : " << addressesVector[i] << endl;
9191
}
9292
}
93-
for (auto address : addressesForThisChecker) {
93+
for (const auto &address : addressesForThisChecker) {
9494
checker.createChannel("sub", "connect", address, "data-in", true);
9595
}
9696

Modules/Common/src/MeanIsAbove.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ std::string MeanIsAbove::getAcceptedType()
4747

4848
Quality MeanIsAbove::check(const MonitorObject *mo)
4949
{
50-
TH1 *th1 = dynamic_cast<TH1*>(mo->getObject());
50+
auto *th1 = dynamic_cast<TH1*>(mo->getObject());
5151
if (!th1) {
5252
// TODO
5353
return Quality::Null;
@@ -68,7 +68,7 @@ void MeanIsAbove::beautify(MonitorObject *mo, Quality checkResult)
6868
return;
6969
}
7070

71-
TH1* th1 = dynamic_cast<TH1*>(mo->getObject());
71+
auto * th1 = dynamic_cast<TH1*>(mo->getObject());
7272

7373
Double_t xMin = th1->GetXaxis()->GetXmin();
7474
Double_t xMax = th1->GetXaxis()->GetXmax();

Modules/Daq/include/Daq/DaqTask.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DaqTask /*final*/: public TaskInterface // todo add back the "final" when
4141

4242
TH1F *mPayloadSize;
4343
TGraph *mIds;
44-
int fNPoints;
44+
int mNPoints;
4545
TH1F *mNumberSubblocks;
4646
TH1F *mSubPayloadSize;
4747
UInt_t mTimeLastRecord;

0 commit comments

Comments
 (0)