Skip to content

Commit b9c58ca

Browse files
committed
Allow clang-tidy to apply it's fixes
These have been: - Remove unused headers - Remove use of temporary objects during construction - Start using ranges functionlity
1 parent 3c1ce35 commit b9c58ca

File tree

12 files changed

+80
-100
lines changed

12 files changed

+80
-100
lines changed

include/inch/eps_magicNumbers.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@
1616

1717
#include <fmt/format.h>
1818

19-
#include <algorithm>
20-
#include <iterator>
21-
#include <map>
2219
#include <string>
2320
#include <utility>
24-
#include <vector>
2521

2622

2723
class EPSMagicNumbers : public MagicNumbers
@@ -34,7 +30,7 @@ class EPSMagicNumbers : public MagicNumbers
3430

3531
/// Delete both due to const members
3632
EPSMagicNumbers& operator=(const EPSMagicNumbers&) = delete;
37-
EPSMagicNumbers& operator=(EPSMagicNumbers&&) = delete;
33+
EPSMagicNumbers& operator=(EPSMagicNumbers&&) = delete;
3834

3935
~EPSMagicNumbers() noexcept override = default;
4036

include/inch/partition.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include "inch/chartColour.hpp"
1515
#include "inch/converter.hpp"
16-
#include "inch/nuclide.hpp"
1716

1817
#include <algorithm>
1918
#include <chrono>
@@ -32,7 +31,7 @@ class Partition
3231
Partition(Partition&&) = default;
3332

3433
Partition& operator=(const Partition&) = default;
35-
Partition& operator=(Partition&&) = default;
34+
Partition& operator=(Partition&&) = default;
3635

3736
~Partition() = default;
3837

src/dripline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bool DripLine::readFRDMFile(const bool overwrite) const
5252

5353
while (modelFile >> A >> Z >> dummy >> ME)
5454
{
55-
DripLine::dm_data.emplace_back(drop_model_data(A, Z, ME));
55+
DripLine::dm_data.emplace_back(A, Z, ME);
5656
}
5757

5858
modelFile.close();

src/eps_chart.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,12 @@ void EPSChart::write(const std::vector<Nuclide>& nuc, const Partition& part) con
108108

109109
if (options.single_drip_lines != 2)
110110
{
111-
drip_lines.emplace_back(
112-
EPSDripLine(neutronMass, protonMass, options.limits, LineType::singleneutron, dripLineColour));
111+
drip_lines.emplace_back(neutronMass, protonMass, options.limits, LineType::singleneutron, dripLineColour);
113112
}
114113

115114
if (options.single_drip_lines != 3)
116115
{
117-
drip_lines.emplace_back(
118-
EPSDripLine(neutronMass, protonMass, options.limits, LineType::singleproton, dripLineColour));
116+
drip_lines.emplace_back(neutronMass, protonMass, options.limits, LineType::singleproton, dripLineColour);
119117
}
120118
}
121119
else
@@ -132,14 +130,12 @@ void EPSChart::write(const std::vector<Nuclide>& nuc, const Partition& part) con
132130

133131
if (options.double_drip_lines != 2)
134132
{
135-
drip_lines.emplace_back(
136-
EPSDripLine(neutronMass, protonMass, options.limits, LineType::doubleneutron, dripLineColour));
133+
drip_lines.emplace_back(neutronMass, protonMass, options.limits, LineType::doubleneutron, dripLineColour);
137134
}
138135

139136
if (options.double_drip_lines != 3)
140137
{
141-
drip_lines.emplace_back(
142-
EPSDripLine(neutronMass, protonMass, options.limits, LineType::doubleproton, dripLineColour));
138+
drip_lines.emplace_back(neutronMass, protonMass, options.limits, LineType::doubleproton, dripLineColour);
143139
}
144140
}
145141
else

src/eps_dripline.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
#include "inch/eps_dripline.hpp"
22

3-
#include "inch/options.hpp"
4-
53
#include <fmt/ostream.h>
64
#include <fmt/std.h>
75

8-
#include <algorithm>
9-
#include <filesystem>
106
#include <limits>
11-
#include <sstream>
12-
#include <vector>
137

148

159
int EPSDripLine::WriteLine(std::ostream& outFile) const

src/eps_key.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <fmt/format.h>
99
#include <fmt/ostream.h>
1010

11-
#include <algorithm>
11+
#include <ranges>
1212

1313

1414
std::string EPSKey::Setup() const
@@ -140,18 +140,18 @@ void EPSKey::Write(std::ofstream& outFile, const Partition& part) const
140140
const double text_yShift{ 0.2 };
141141

142142
// Only draw the parts of the key required
143-
for (auto it = part.values.crbegin(); it != part.values.crend(); ++it)
143+
for (const auto& value : std::ranges::reverse_view(part.values))
144144
{
145-
if (it->draw)
145+
if (value.draw)
146146
{
147147
fmt::print(outFile,
148148
"0 {} 0.5 {} curve Nucleus\n"
149149
"2.5 {} m ResetWidth\n"
150150
"{}",
151-
it->colour,
151+
value.colour,
152152
yPos,
153153
(yPos + text_yShift),
154-
it->keyText);
154+
value.keyText);
155155

156156
yPos += 1.5;
157157
}

src/eps_rProcess.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
#include "inch/eps_rProcess.hpp"
22

3-
#include "inch/options.hpp"
4-
53
#include <fmt/format.h>
64
#include <fmt/ostream.h>
75

86
#include <fstream>
9-
#include <limits>
10-
#include <sstream>
117

128

139
std::string EPSrProcess::PathSetup(const bool shaded) const
@@ -27,16 +23,16 @@ void EPSrProcess::WritePath(std::ofstream& outFile, const bool shaded) const
2723

2824
bool initial{ true };
2925

30-
for (const auto& it : data)
26+
for (const auto& point : data)
3127
{
3228
// it.first = N
3329
// it.second = Z
34-
if (limits.inZRange(it.second) && limits.inNRange(it.first))
30+
if (limits.inZRange(point.second) && limits.inNRange(point.first))
3531
{
3632
fmt::print(outFile,
3733
"{:>3d} {:>3d} {}\n",
38-
(it.first - limits.Nmin),
39-
(it.second - limits.Zmin),
34+
(point.first - limits.Nmin),
35+
(point.second - limits.Zmin),
4036
(initial ? 'm' : 'l'));
4137

4238
initial = false;

src/io.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ std::map<std::string, std::string> IO::readOptionFile(const std::string& inputFi
299299
++i;
300300
}
301301

302-
if (inputfile_options.count(theLine.front()) > 0)
302+
if (inputfile_options.contains(theLine.front()))
303303
{
304304
fmt::print("\n**WARNING**: Already have a value for <{}> ({}), will use the new value ({})\n",
305305
theLine.front(),

src/key.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "inch/key.hpp"
22

3-
#include "inch/chartColour.hpp"
43
#include "inch/chartSelection.hpp"
54
#include "inch/options.hpp"
65
#include "inch/partition.hpp"

src/nuclide.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <algorithm>
88
#include <cmath>
9+
#include <ranges>
910

1011

1112
void Nuclide::setSpinParity() const
@@ -233,51 +234,51 @@ void Nuclide::setSeparationEnergies(const std::vector<Nuclide>& nuc) const
233234
// Loop from the penultimate isotope towards the beginning.
234235
// As the vector is ordered by A (low to high), this will
235236
// remove a large number of checks as the vector get bigger.
236-
for (auto previous = nuc.crbegin(); previous != nuc.crend(); ++previous)
237+
for (const auto& previous : std::ranges::reverse_view(nuc))
237238
{
238239
// Single particle energies.
239-
if (A - previous->A == 1)
240+
if (A - previous.A == 1)
240241
{
241242
// S_p(Z,N) = M(Z-1,N) - M(Z,N) + M(1,0)
242-
if (N - previous->N == 0 && Z - previous->Z == 1)
243+
if (N - previous.N == 0 && Z - previous.Z == 1)
243244
{
244-
s_p = previous->NUBASE_ME - NUBASE_ME + p_ME;
245-
ds_p = errorQuadrature(previous->NUBASE_dME, NUBASE_dME, p_dME);
245+
s_p = previous.NUBASE_ME - NUBASE_ME + p_ME;
246+
ds_p = errorQuadrature(previous.NUBASE_dME, NUBASE_dME, p_dME);
246247
numSeparationEnergiesRead++;
247248
}
248249
// S_n(Z,N) = M(Z,N-1) - M(Z,N) + M(0,1)
249-
else if (Z - previous->Z == 0 && N - previous->N == 1)
250+
else if (Z - previous.Z == 0 && N - previous.N == 1)
250251
{
251-
s_n = previous->NUBASE_ME - NUBASE_ME + n_ME;
252-
ds_n = errorQuadrature(previous->NUBASE_dME, NUBASE_dME, n_dME);
252+
s_n = previous.NUBASE_ME - NUBASE_ME + n_ME;
253+
ds_n = errorQuadrature(previous.NUBASE_dME, NUBASE_dME, n_dME);
253254
numSeparationEnergiesRead++;
254255
}
255256
}
256257
// Two particle energies.
257-
else if (A - previous->A == 2)
258+
else if (A - previous.A == 2)
258259
{
259260
// S_2p(Z,N) = M(Z-2,N) - M(Z,N) + 2*M(1,0)
260-
if (N - previous->N == 0 && Z - previous->Z == 2)
261+
if (N - previous.N == 0 && Z - previous.Z == 2)
261262
{
262-
s_2p = previous->NUBASE_ME - NUBASE_ME + 2 * p_ME;
263-
ds_2p = errorQuadrature(previous->NUBASE_dME, NUBASE_dME, p_dME, p_dME);
263+
s_2p = previous.NUBASE_ME - NUBASE_ME + 2 * p_ME;
264+
ds_2p = errorQuadrature(previous.NUBASE_dME, NUBASE_dME, p_dME, p_dME);
264265
numSeparationEnergiesRead++;
265266
}
266267
// S_2n(Z,N) = M(Z,N-2) - M(Z,N) + 2*M(0,1)
267-
else if (Z - previous->Z == 0 && N - previous->N == 2)
268+
else if (Z - previous.Z == 0 && N - previous.N == 2)
268269
{
269-
s_2n = previous->NUBASE_ME - NUBASE_ME + 2 * n_ME;
270-
ds_2n = errorQuadrature(previous->NUBASE_dME, NUBASE_dME, n_dME, n_dME);
270+
s_2n = previous.NUBASE_ME - NUBASE_ME + 2 * n_ME;
271+
ds_2n = errorQuadrature(previous.NUBASE_dME, NUBASE_dME, n_dME, n_dME);
271272

272273
// |dV_pn(Z,N)| = 1/4*[S_2p(Z,N) - S_2p(Z,N-2)]
273-
dV_pn = fabs(0.25 * (s_2p - previous->s_2p));
274-
ddV_pn = 0.25 * errorQuadrature(previous->ds_2p, ds_2p);
274+
dV_pn = fabs(0.25 * (s_2p - previous.s_2p));
275+
ddV_pn = 0.25 * errorQuadrature(previous.ds_2p, ds_2p);
275276
numSeparationEnergiesRead++;
276277
}
277278
}
278279
// Once the difference in A is greater than 2 we wont get any more useful data
279280
// so set the 'exit variable' to the get out value.
280-
else if (A - previous->A >= 3)
281+
else if (A - previous.A >= 3)
281282
{
282283
numSeparationEnergiesRead = 4;
283284
}
@@ -296,9 +297,9 @@ void Nuclide::setIsomerData(std::vector<Nuclide>& nuc, const int state) const
296297
// Loop from the penultimate isotope towards the beginning.
297298
// Original order is ground state followed by ascending states,
298299
// theoretically we could just modify nuc.back(), but that's not safe
299-
for (auto previous = nuc.rbegin(); previous != nuc.rend(); ++previous)
300+
for (auto& previous : std::ranges::reverse_view(nuc))
300301
{
301-
if (A == previous->A && Z == previous->Z)
302+
if (A == previous.A && Z == previous.Z)
302303
{
303304
double energy{ 0.0 };
304305
double error{ 0.0 };
@@ -313,7 +314,7 @@ void Nuclide::setIsomerData(std::vector<Nuclide>& nuc, const int state) const
313314

314315
setIsomerEnergyError(error);
315316

316-
previous->energy_levels.emplace_back(State(state, energy, error));
317+
previous.energy_levels.emplace_back(state, energy, error);
317318
break;
318319
}
319320
}

0 commit comments

Comments
 (0)