Skip to content

Commit

Permalink
Additional clang-tidy suggestions
Browse files Browse the repository at this point in the history
This is a big commit!

Lots of variable renaming, header removal and clang-format changes now
it aligns the equal signs on copy/move assigments correctly.
  • Loading branch information
php1ic committed Feb 9, 2024
1 parent fd377c1 commit f6a70cd
Show file tree
Hide file tree
Showing 30 changed files with 192 additions and 182 deletions.
9 changes: 4 additions & 5 deletions include/inch/chart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

#include <fmt/chrono.h>
#include <fmt/format.h>
#include <fmt/std.h>

#include <cmath>
#include <iostream>
#include <string>
#include <vector>

Expand All @@ -33,7 +32,7 @@ class Chart
Chart(const Chart& Chart) = default;
Chart(Chart&& Chart) noexcept = default;

Chart& operator=(const Chart& Chart) = delete;
Chart& operator=(const Chart& Chart) = delete;
Chart& operator=(Chart&& Chart) noexcept = delete;

virtual ~Chart() noexcept = default;
Expand Down Expand Up @@ -159,8 +158,7 @@ class Chart
*/
[[nodiscard]] static inline std::string getTime()
{
const std::time_t t = std::time(nullptr);
return fmt::format("{:%Y-%m-%dT%H:%M:%S}", *std::localtime(&t));
return fmt::format("{:%Y-%m-%dT%H:%M:%S}", fmt::localtime(std::time(nullptr)));
}

/**
Expand Down Expand Up @@ -200,6 +198,7 @@ class Chart
* \return The height the canvas should be
*/
[[nodiscard]] inline double
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
calculateCanvasHeight(const double key_scale, const double key_height, const int ZRange) const
{
double chart_height = ZRange + 2 * BORDER;
Expand Down
1 change: 1 addition & 0 deletions include/inch/dripline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class DripLine
/// Container to hold each isotope in the drop model data file
struct drop_model_data
{
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
drop_model_data(const int mass_number, const int proton_number, const double mass_excess) :
A(mass_number), Z(proton_number), N(mass_number - proton_number), ME(mass_excess)
{
Expand Down
2 changes: 1 addition & 1 deletion include/inch/eps_chart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class EPSChart : public Chart
EPSChart(const EPSChart& EPSChart) = default;
EPSChart(EPSChart&& EPSChart) noexcept = default;

EPSChart& operator=(const EPSChart& EPSChart) = delete;
EPSChart& operator=(const EPSChart& EPSChart) = delete;
EPSChart& operator=(EPSChart&& EPSChart) noexcept = delete;

~EPSChart() noexcept override = default;
Expand Down
5 changes: 1 addition & 4 deletions include/inch/eps_dripline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@

#include <fmt/format.h>

#include <filesystem>
#include <fstream>
#include <string>
#include <utility>
#include <vector>


class EPSDripLine : public DripLine
Expand All @@ -38,7 +35,7 @@ class EPSDripLine : public DripLine

/// Delete both due to const members
EPSDripLine& operator=(const EPSDripLine&) = delete;
EPSDripLine& operator=(EPSDripLine&&) = delete;
EPSDripLine& operator=(EPSDripLine&&) = delete;

~EPSDripLine() override = default;

Expand Down
2 changes: 1 addition & 1 deletion include/inch/eps_grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class EPSGrid : public Grid
EPSGrid(const EPSGrid& EPSGrid) = default;
EPSGrid(EPSGrid&& EPSGrid) noexcept = default;

EPSGrid& operator=(const EPSGrid& EPSGrid) = default;
EPSGrid& operator=(const EPSGrid& EPSGrid) = default;
EPSGrid& operator=(EPSGrid&& EPSGrid) noexcept = default;

~EPSGrid() noexcept override = default;
Expand Down
4 changes: 1 addition & 3 deletions include/inch/eps_key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

#include <fstream>
#include <string>
#include <utility>
#include <vector>


class Options;
Expand All @@ -30,7 +28,7 @@ class EPSKey : public Key
EPSKey(const EPSKey& EPSKey) = default;
EPSKey(EPSKey&& EPSKey) = default;

EPSKey& operator=(const EPSKey& EPSKey) = default;
EPSKey& operator=(const EPSKey& EPSKey) = default;
EPSKey& operator=(EPSKey&& EPSKey) noexcept = default;

~EPSKey() noexcept override = default;
Expand Down
4 changes: 1 addition & 3 deletions include/inch/eps_rProcess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
#include "inch/limits.hpp"
#include "inch/rProcess.hpp"

#include <filesystem>
#include <string>
#include <utility>
#include <vector>

class EPSrProcess : public rProcess
{
Expand All @@ -24,7 +22,7 @@ class EPSrProcess : public rProcess
EPSrProcess(EPSrProcess&&) = default;

EPSrProcess& operator=(const EPSrProcess&) = delete;
EPSrProcess& operator=(EPSrProcess&&) = delete;
EPSrProcess& operator=(EPSrProcess&&) = delete;

~EPSrProcess() override = default;

Expand Down
2 changes: 1 addition & 1 deletion include/inch/grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Grid
Grid(const Grid& Grid) = default;
Grid(Grid&& Grid) noexcept = default;

Grid& operator=(const Grid& Grid) = default;
Grid& operator=(const Grid& Grid) = default;
Grid& operator=(Grid&& Grid) noexcept = default;

virtual ~Grid() noexcept = default;
Expand Down
2 changes: 1 addition & 1 deletion include/inch/io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class IO
IO(IO&&) = default;

IO& operator=(const IO&) = default;
IO& operator=(IO&&) = default;
IO& operator=(IO&&) = default;

~IO() = default;

Expand Down
2 changes: 1 addition & 1 deletion include/inch/key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Key
Key(const Key& Key) = default;
Key(Key&& Key) = default;

Key& operator=(const Key& Key) = default;
Key& operator=(const Key& Key) = default;
Key& operator=(Key&& Key) noexcept = default;

virtual ~Key() noexcept = default;
Expand Down
2 changes: 1 addition & 1 deletion include/inch/limits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Limits
Limits(const Limits& other) = default;
Limits(Limits&& other) noexcept = default;

Limits& operator=(const Limits& other) = default;
Limits& operator=(const Limits& other) = default;
Limits& operator=(Limits&& other) noexcept = default;

virtual ~Limits() noexcept = default;
Expand Down
11 changes: 6 additions & 5 deletions include/inch/magicNumbers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MagicNumbers

/// Delete both due to const members
MagicNumbers& operator=(const MagicNumbers&) = delete;
MagicNumbers& operator=(MagicNumbers&&) = delete;
MagicNumbers& operator=(MagicNumbers&&) = delete;

virtual ~MagicNumbers() noexcept = default;

Expand All @@ -44,6 +44,7 @@ class MagicNumbers
*/
struct Number
{
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
Number(int minN, int maxN, int minZ, int maxZ) : min_n{ minN }, max_n{ maxN }, min_z{ minZ }, max_z{ maxZ } {}

int min_n;
Expand All @@ -53,12 +54,12 @@ class MagicNumbers
};

/// Store the N,Z limits of the chart being created
const Limits limits;
mutable Limits limits;

/// The min coordinate that the line can have
const int min_val{ -1 };
mutable int min_val{ -1 };
/// The max coordinate that the line can have
const int max_val{ 2 };
mutable int max_val{ 2 };

/// Container for the actual magic numbers
mutable std::vector<int> numbers{ 2, 8, 20, 28, 50, 82, 126 };
Expand Down Expand Up @@ -88,7 +89,7 @@ class MagicNumbers
numbers.cend(),
values.cbegin(),
std::inserter(coords, coords.end()),
[](const int a, const Number b) { return std::make_pair(a, b); });
[](const int number, const Number value) { return std::make_pair(number, value); });
}

/**
Expand Down
10 changes: 5 additions & 5 deletions include/inch/massTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MassTable
MassTable(MassTable&&) noexcept = default;

/// Delete both due to const members
MassTable& operator=(const MassTable&) = delete;
MassTable& operator=(const MassTable&) = delete;
MassTable& operator=(MassTable&&) noexcept = delete;

~MassTable() = default;
Expand Down Expand Up @@ -104,7 +104,7 @@ class MassTable
*
* \return A std::pair<int,int> with min and max N
*/
[[nodiscard]] std::pair<int, int> GetNeutronRange(const int Z, const std::string& decayMode = ".") const;
[[nodiscard]] std::pair<int, int> GetNeutronRange(const int proton_number, const std::string& decayMode = ".") const;

/**
* For the isotope with Z=<Z>, get the min and max N values of the stable isotopes.
Expand All @@ -113,9 +113,9 @@ class MassTable
*
* \return A std::pair<int,int> with min and max N
*/
[[nodiscard]] inline std::pair<int, int> GetStableNeutronRange(const int Z) const
[[nodiscard]] inline std::pair<int, int> GetStableNeutronRange(const int proton_number) const
{
return GetNeutronRange(Z, "stable");
return GetNeutronRange(proton_number, "stable");
}

/**
Expand All @@ -138,7 +138,7 @@ class MassTable
*
* \return Nothing
*/
void SetNeutronLimitForZ(const int Z, std::string_view limit) const;
void SetNeutronLimitForZ(const int proton_number, std::string_view limit) const;

// Tables sizes (ground state only)
// 2003 = 3179
Expand Down
8 changes: 5 additions & 3 deletions include/inch/nuclide.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Nuclide
Nuclide(Nuclide&&) = default;

Nuclide& operator=(const Nuclide&) = default;
Nuclide& operator=(Nuclide&&) = default;
Nuclide& operator=(Nuclide&&) = default;

~Nuclide() = default;

Expand Down Expand Up @@ -164,6 +164,7 @@ class Nuclide
*/
struct State
{
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
State(const int _level, const double _energy, const double _error) : level(_level), energy(_energy), error(_error)
{
}
Expand Down Expand Up @@ -313,8 +314,9 @@ class Nuclide
halflife_unit = full_data.substr(NUBASE_START_HALFLIFEUNIT, NUBASE_END_HALFLIFEUNIT - NUBASE_START_HALFLIFEUNIT);

// Trim leading white space
halflife_unit.erase(halflife_unit.begin(), std::find_if(halflife_unit.begin(), halflife_unit.end(), [](int ch) {
return (std::isspace(ch) == 0);
halflife_unit.erase(halflife_unit.begin(),
std::find_if(halflife_unit.begin(), halflife_unit.end(), [](int character) {
return (std::isspace(character) == 0);
}));
}

Expand Down
8 changes: 4 additions & 4 deletions include/inch/options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Options
Options(const Options& other) = default;
Options(Options&& other) noexcept = default;

Options& operator=(const Options& other) = default;
Options& operator=(const Options& other) = default;
Options& operator=(Options&& other) noexcept = default;

virtual ~Options() noexcept = default;
Expand All @@ -46,7 +46,7 @@ class Options
*
* \return Nothing
*/
void setOutputFilename() const;
bool setOutputFilename() const;

/**
* Validate the selected file name and append the appropriate extension
Expand Down Expand Up @@ -187,11 +187,11 @@ class Options
mutable int np_rich{ 1 };

/// File contain user isotopes to be drawn
mutable std::string personal_isotopes{ "" };
mutable std::string personal_isotopes;
/// File name the chart will be written to, without extension, this is added in the code
mutable std::filesystem::path outfile{ "chart" };
/// Input file name
mutable std::string inputfile{ "" };
mutable std::string inputfile;

/// Output file options will be written to
mutable std::filesystem::path options{ "options.in" };
Expand Down
15 changes: 8 additions & 7 deletions include/inch/partition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ class Partition
*/
[[nodiscard]] inline std::string getColour(const double value, const int start = 0) const
{
auto val = std::find_if(
std::next(values.begin(), start), values.end(), [value](const auto& s) -> bool { return (value <= s.value); });
auto val = std::find_if(std::next(values.begin(), start), values.end(), [value](const auto& part) -> bool {
return (value <= part.value);
});

val->draw = true;
return val->colour;
}

/**
* Get the colour associated with the given time duration <value>,
* Get the colour associated with the given time duration <value>,
* if a <start> value is specified, skip the first <start> partitions
*
* \param The std::chrono:duration<T> value to get the colour for
Expand All @@ -92,7 +93,7 @@ class Partition
{
auto val = std::find_if(std::next(halfLifeMap.cbegin(), start),
halfLifeMap.cend(),
[value](const auto& HL) -> bool { return (value <= HL.second); });
[value](const auto& half_life) -> bool { return (value <= half_life.second); });

// Use numeric paired value to actually access the colour
return getColour(val->first, start);
Expand All @@ -109,9 +110,9 @@ class Partition
*/
[[nodiscard]] inline std::string getColour(std::string_view value, const int start = 0) const
{
auto val = std::find_if(std::next(decayMap.cbegin(), start), decayMap.cend(), [&value](const auto& DM) -> bool {
return (value == DM.second);
});
auto val = std::find_if(std::next(decayMap.cbegin(), start),
decayMap.cend(),
[&value](const auto& decay_mode) -> bool { return (value == decay_mode.second); });

// Use numeric paired value to actually access the colour
return getColour(val->first, start);
Expand Down
4 changes: 2 additions & 2 deletions include/inch/rProcess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class rProcess
rProcess(rProcess&&) = default;

rProcess& operator=(const rProcess&) = delete;
rProcess& operator=(rProcess&&) = delete;
rProcess& operator=(rProcess&&) = delete;

virtual ~rProcess() = default;

/// Store the N,Z limits of the chart being created
const Limits limits;
mutable Limits limits;

/// Minimum Z value in the file that is read
static constexpr int min_Z{ 26 };
Expand Down
Loading

0 comments on commit f6a70cd

Please sign in to comment.