From b7816e06cb923a9339b28c946e280384802a9d50 Mon Sep 17 00:00:00 2001
From: Joachim Wuttke <j.wuttke@fz-juelich.de>
Date: Tue, 23 Jan 2024 19:57:13 +0100
Subject: [PATCH] std local var name

---
 GUI/Model/Tune/JobQueueData.cpp         | 57 +++++++++++++------------
 GUI/View/FitControl/MinimizerEditor.cpp |  6 +--
 Tests/Unit/GUI/TestJobModel.cpp         | 56 ++++++++++++------------
 3 files changed, 60 insertions(+), 59 deletions(-)

diff --git a/GUI/Model/Tune/JobQueueData.cpp b/GUI/Model/Tune/JobQueueData.cpp
index 9a0ca4dd61e..f7b556d3046 100644
--- a/GUI/Model/Tune/JobQueueData.cpp
+++ b/GUI/Model/Tune/JobQueueData.cpp
@@ -34,9 +34,9 @@ bool JobQueueData::hasUnfinishedJobs()
 
 //! Submits job and run it in a thread.
 
-void JobQueueData::runJob(JobItem* jobItem)
+void JobQueueData::runJob(JobItem* job_item)
 {
-    QString identifier = jobItem->batchInfo()->identifier();
+    QString identifier = job_item->batchInfo()->identifier();
     if (getThread(identifier))
         return;
 
@@ -44,19 +44,20 @@ void JobQueueData::runJob(JobItem* jobItem)
         throw std::runtime_error("JobQueueData::runJob -> Error. ISimulation is already existing.");
 
     try {
-        auto simulation = GUI::ToCore::itemsToSimulation(
-            *jobItem->sampleItem(), *jobItem->instrumentItem(), *jobItem->simulationOptionsItem());
+        auto simulation =
+            GUI::ToCore::itemsToSimulation(*job_item->sampleItem(), *job_item->instrumentItem(),
+                                           *job_item->simulationOptionsItem());
         m_simulations[identifier] = simulation.release();
     } catch (const std::exception& ex) {
         QString message("JobQueueData::runJob -> Error. "
                         "Attempt to create sample/instrument object from user description "
                         "has failed with following error message.\n\n");
         message += QString::fromStdString(std::string(ex.what()));
-        jobItem->batchInfo()->setComments(message);
-        jobItem->batchInfo()->setProgress(100);
-        jobItem->setFailed();
+        job_item->batchInfo()->setComments(message);
+        job_item->batchInfo()->setProgress(100);
+        job_item->setFailed();
         clearSimulation(identifier);
-        emit jobSelected(jobItem);
+        emit jobSelected(job_item);
         return;
     }
 
@@ -105,11 +106,11 @@ void JobQueueData::onStartedJob()
 {
     auto* worker = qobject_cast<JobWorker*>(sender());
 
-    auto* jobItem = m_job_model->jobItemForIdentifier(worker->identifier());
-    jobItem->batchInfo()->setProgress(0);
-    jobItem->batchInfo()->setStatus(JobStatus::Running);
-    jobItem->batchInfo()->setBeginTime(worker->simulationStart());
-    jobItem->batchInfo()->setEndTime(QDateTime());
+    auto* job_item = m_job_model->jobItemForIdentifier(worker->identifier());
+    job_item->batchInfo()->setProgress(0);
+    job_item->batchInfo()->setStatus(JobStatus::Running);
+    job_item->batchInfo()->setBeginTime(worker->simulationStart());
+    job_item->batchInfo()->setEndTime(QDateTime());
 }
 
 //! Performs necessary actions when job is finished.
@@ -118,14 +119,14 @@ void JobQueueData::onFinishedJob()
 {
     auto* worker = qobject_cast<JobWorker*>(sender());
 
-    auto* jobItem = m_job_model->jobItemForIdentifier(worker->identifier());
-    processFinishedJob(worker, jobItem);
+    auto* job_item = m_job_model->jobItemForIdentifier(worker->identifier());
+    processFinishedJob(worker, job_item);
 
     // I tell to the thread to exit here (instead of connecting JobRunner::finished
     // to the QThread::quit because of strange behaviour)
     getThread(worker->identifier())->quit();
 
-    emit jobSelected(jobItem);
+    emit jobSelected(job_item);
 
     clearSimulation(worker->identifier());
     assignForDeletion(worker);
@@ -143,8 +144,8 @@ void JobQueueData::onFinishedThread()
 void JobQueueData::onProgressUpdate()
 {
     auto* worker = qobject_cast<JobWorker*>(sender());
-    auto* jobItem = m_job_model->jobItemForIdentifier(worker->identifier());
-    jobItem->batchInfo()->setProgress(worker->progress());
+    auto* job_item = m_job_model->jobItemForIdentifier(worker->identifier());
+    job_item->batchInfo()->setProgress(worker->progress());
     updateGlobalProgress();
 }
 
@@ -155,9 +156,9 @@ void JobQueueData::updateGlobalProgress()
 {
     int global_progress(0);
     int nRunningJobs(0);
-    for (auto* jobItem : m_job_model->jobItems())
-        if (isRunning(jobItem->batchInfo()->status())) {
-            global_progress += jobItem->batchInfo()->progress();
+    for (auto* job_item : m_job_model->jobItems())
+        if (isRunning(job_item->batchInfo()->status())) {
+            global_progress += job_item->batchInfo()->progress();
             nRunningJobs++;
         }
 
@@ -218,22 +219,22 @@ void JobQueueData::clearSimulation(const QString& identifier)
 
 //! Set all data of finished job
 
-void JobQueueData::processFinishedJob(JobWorker* worker, JobItem* jobItem)
+void JobQueueData::processFinishedJob(JobWorker* worker, JobItem* job_item)
 {
-    jobItem->batchInfo()->setEndTime(worker->simulationEnd());
+    job_item->batchInfo()->setEndTime(worker->simulationEnd());
 
     // propagating status of runner
     if (isFailed(worker->status()))
-        jobItem->batchInfo()->setComments(worker->failureMessage());
+        job_item->batchInfo()->setComments(worker->failureMessage());
     else {
         ASSERT(worker->result());
-        jobItem->setResults(*worker->result());
+        job_item->setResults(*worker->result());
     }
-    jobItem->batchInfo()->setStatus(worker->status());
+    job_item->batchInfo()->setStatus(worker->status());
 
     // fixing job progress (if job was successfull, but due to wrong estimation, progress not 100%)
-    if (isCompleted(jobItem->batchInfo()->status()))
-        jobItem->batchInfo()->setProgress(100);
+    if (isCompleted(job_item->batchInfo()->status()))
+        job_item->batchInfo()->setProgress(100);
 }
 
 //! Returns the thread for given identifier.
diff --git a/GUI/View/FitControl/MinimizerEditor.cpp b/GUI/View/FitControl/MinimizerEditor.cpp
index b8c738d840d..e93d3ad4ab2 100644
--- a/GUI/View/FitControl/MinimizerEditor.cpp
+++ b/GUI/View/FitControl/MinimizerEditor.cpp
@@ -34,10 +34,10 @@ MinimizerEditor::MinimizerEditor(QWidget* parent)
     m_main_layout->setSpacing(5);
 }
 
-void MinimizerEditor::setJobItem(JobItem* jobItem)
+void MinimizerEditor::setJobItem(JobItem* job_item)
 {
-    ASSERT(jobItem);
-    setMinContainerItem(jobItem->fitSuiteItem()->minimizerContainerItem());
+    ASSERT(job_item);
+    setMinContainerItem(job_item->fitSuiteItem()->minimizerContainerItem());
 }
 
 void MinimizerEditor::setMinContainerItem(MinimizerContainerItem* containerItem)
diff --git a/Tests/Unit/GUI/TestJobModel.cpp b/Tests/Unit/GUI/TestJobModel.cpp
index 7ed54aa6691..b47ef3c70ec 100644
--- a/Tests/Unit/GUI/TestJobModel.cpp
+++ b/Tests/Unit/GUI/TestJobModel.cpp
@@ -24,20 +24,20 @@ TEST(TestJobsSet, nonXMLData)
     EXPECT_EQ(jobModel.dataItems().size(), 0);
 
     // adding JobItem
-    auto* jobItem = jobModel.createJobItem();
+    auto* job_item = jobModel.createJobItem();
     auto* instrumentItem = new GISASInstrumentItem();
-    jobItem->copyInstrumentIntoJob(instrumentItem);
-    jobItem->createSimulatedDataItem();
+    job_item->copyInstrumentIntoJob(instrumentItem);
+    job_item->createSimulatedDataItem();
     EXPECT_EQ(jobModel.dataItems().size(), 1);
 
     // adding empty DatafileItem to JobItem
     DatafileItem dfi("dfi", UTest::GUI::makeData2D(0.0));
-    jobItem->copyDatafileItemIntoJob(&dfi);
+    job_item->copyDatafileItemIntoJob(&dfi);
     EXPECT_EQ(jobModel.dataItems().size(), 2);
 
     // checking data items of JobsSet
-    EXPECT_EQ(jobModel.dataItems().indexOf(jobItem->simulatedDataItem()), 0);
-    EXPECT_EQ(jobModel.dataItems().indexOf(jobItem->realItem()->dataItem()), 1);
+    EXPECT_EQ(jobModel.dataItems().indexOf(job_item->simulatedDataItem()), 0);
+    EXPECT_EQ(jobModel.dataItems().indexOf(job_item->realItem()->dataItem()), 1);
 }
 
 TEST(TestJobsSet, saveNonXMLData)
@@ -48,21 +48,21 @@ TEST(TestJobsSet, saveNonXMLData)
     JobsSet jobModel;
 
     // adding JobItem with instrument
-    auto* jobItem = jobModel.createJobItem();
+    auto* job_item = jobModel.createJobItem();
     auto* instrumentItem = new GISASInstrumentItem();
-    jobItem->copyInstrumentIntoJob(instrumentItem);
+    job_item->copyInstrumentIntoJob(instrumentItem);
 
     // create simulated data
-    jobItem->createSimulatedDataItem();
-    jobItem->simulatedDataItem()->setDatafield(UTest::GUI::makeData2D(101.));
+    job_item->createSimulatedDataItem();
+    job_item->simulatedDataItem()->setDatafield(UTest::GUI::makeData2D(101.));
 
     // create real data
     DatafileItem dfi("dfi", UTest::GUI::makeData2D(102.));
-    jobItem->copyDatafileItemIntoJob(&dfi);
+    job_item->copyDatafileItemIntoJob(&dfi);
 
     // update names
-    jobItem->batchInfo()->setJobName("name");
-    jobItem->updateFileName();
+    job_item->batchInfo()->setJobName("name");
+    job_item->updateFileName();
 
     // save first time
     jobModel.writeDatafiles(projectDir);
@@ -79,25 +79,25 @@ TEST(TestJobsSet, saveNonXMLData)
         IO::readData2D(fname1.toStdString(), IO::Filetype2D::bornagain2D));
     std::unique_ptr<Datafield> dataOnDisk2(
         IO::readData2D(fname2.toStdString(), IO::Filetype2D::bornagain2D));
-    EXPECT_TRUE(UTest::GUI::isTheSame(*dataOnDisk1, *jobItem->simulatedDataItem()->c_field()));
-    EXPECT_TRUE(UTest::GUI::isTheSame(*dataOnDisk2, *jobItem->realItem()->dataItem()->c_field()));
+    EXPECT_TRUE(UTest::GUI::isTheSame(*dataOnDisk1, *job_item->simulatedDataItem()->c_field()));
+    EXPECT_TRUE(UTest::GUI::isTheSame(*dataOnDisk2, *job_item->realItem()->dataItem()->c_field()));
 
     // modify data and save the project.
-    jobItem->simulatedDataItem()->setDatafield(UTest::GUI::makeData2D(103.));
+    job_item->simulatedDataItem()->setDatafield(UTest::GUI::makeData2D(103.));
     jobModel.writeDatafiles(projectDir);
     QTest::qSleep(10);
 
     // ensure that the simulated data has been changed
-    EXPECT_FALSE(UTest::GUI::isTheSame(*dataOnDisk1, *jobItem->simulatedDataItem()->c_field()));
-    EXPECT_TRUE(UTest::GUI::isTheSame(*dataOnDisk2, *jobItem->realItem()->dataItem()->c_field()));
+    EXPECT_FALSE(UTest::GUI::isTheSame(*dataOnDisk1, *job_item->simulatedDataItem()->c_field()));
+    EXPECT_TRUE(UTest::GUI::isTheSame(*dataOnDisk2, *job_item->realItem()->dataItem()->c_field()));
 
     // check that data on disk has changed
     dataOnDisk1.reset(IO::readData2D(fname1.toStdString(), IO::Filetype2D::bornagain2D));
-    EXPECT_TRUE(UTest::GUI::isTheSame(*dataOnDisk1, *jobItem->simulatedDataItem()->c_field()));
+    EXPECT_TRUE(UTest::GUI::isTheSame(*dataOnDisk1, *job_item->simulatedDataItem()->c_field()));
 
     // rename job and check that file on disk changed the name
-    jobItem->batchInfo()->setJobName("new_job");
-    jobItem->updateFileName();
+    job_item->batchInfo()->setJobName("new_job");
+    job_item->updateFileName();
     jobModel.writeDatafiles(projectDir);
     QTest::qSleep(10);
 
@@ -118,14 +118,14 @@ TEST(TestJobsSet, masksToDetector)
     int ny = 5;
 
     // create JobItem
-    JobItem jobItem;
+    JobItem job_item;
     auto* instrumentItem = new GISASInstrumentItem;
     instrumentItem->detectorItem()->phiAxis().setNbins(nx);
     instrumentItem->detectorItem()->alphaAxis().setNbins(ny);
-    jobItem.copyInstrumentIntoJob(instrumentItem);
+    job_item.copyInstrumentIntoJob(instrumentItem);
 
     // create simulated data (may be empty)
-    jobItem.createSimulatedDataItem();
+    job_item.createSimulatedDataItem();
 
     // create external 2d data
     DatafileItem realItem("foo", UTest::GUI::makeData2D(1.0, nx, -4.5, 2.5, ny, 0., 5.0));
@@ -151,18 +151,18 @@ TEST(TestJobsSet, masksToDetector)
     container->addMaskItem(&mask);
 
     // add DatafileItem to job
-    jobItem.copyDatafileItemIntoJob(&realItem);
+    job_item.copyDatafileItemIntoJob(&realItem);
 
     // check DatafileItem data before applying mask
-    const auto* field_before = jobItem.realItem()->data2DItem()->c_field();
+    const auto* field_before = job_item.realItem()->data2DItem()->c_field();
     for (size_t i = 0; i < field_before->size(); i++)
         EXPECT_EQ(field_before->valAt(i), 1.0);
 
     // adjust detector and DatafileItem to each other, copy and apply masks
-    jobItem.adjustReaDataToJobInstrument();
+    job_item.adjustReaDataToJobInstrument();
 
     // check DatafileItem data after applying mask
-    const auto* field_after = jobItem.realItem()->data2DItem()->c_field();
+    const auto* field_after = job_item.realItem()->data2DItem()->c_field();
     auto flat_i = [nx](int ix, int iy) { return nx * iy + ix; };
 
     for (int ix = 0; ix < nx; ix++)
-- 
GitLab