clang-tidy: modernize-pass-by-value

This commit is contained in:
prisixia 2023-05-05 20:29:32 +02:00
parent a58c313bc9
commit fdf1c4a9ee
Signed by: prisixia
GPG Key ID: CB939A148C9B4125
12 changed files with 74 additions and 78 deletions

View File

@ -37,7 +37,7 @@ along with speciesgen. If not, see <https://www.gnu.org/licenses/>.
namespace SpeciesGen {
class ErrorHandler {
public:
ErrorHandler(const std::string & = "ErrorHandler");
ErrorHandler(std::string = "ErrorHandler");
virtual size_t CheckForErrors() = 0;
virtual std::string GetError(const size_t);
virtual void ClearErrors();

View File

@ -44,7 +44,7 @@ namespace Starbound::Frames {
class Grid {
public:
Grid() = delete;
Grid(const std::vector<std::vector<std::optional<std::string>>> &,
Grid(std::vector<std::vector<std::optional<std::string>>>,
const std::tuple<uint32_t, uint32_t> = {129, 129},
const std::tuple<uint32_t, uint32_t> = {9, 6});
@ -66,7 +66,7 @@ private:
class Frames {
public:
Frames() = delete;
Frames(const std::unordered_map<std::string, std::string> &, const Grid &);
Frames(std::unordered_map<std::string, std::string>, Grid);
[[nodiscard]] std::unordered_map<std::string, std::string>
GetAliases() const;

View File

@ -54,9 +54,8 @@ enum class TooltipKind { Armor = 0 };
class Frames {
public:
Frames() = default;
Frames(const std::filesystem::path &);
Frames(const std::filesystem::path &, const std::filesystem::path &,
const std::filesystem::path &);
Frames(std::filesystem::path);
Frames(std::filesystem::path, std::filesystem::path, std::filesystem::path);
[[nodiscard]] std::filesystem::path GetBody() const;
[[nodiscard]] std::filesystem::path GetBackSleeve() const;
@ -75,10 +74,9 @@ private:
class Item {
public:
Item() = default;
Item(const std::string &, const Rarity);
Item(const std::string &, const std::filesystem::path &, const Category,
const std::string &, const std::string &, const Frames &,
const Frames &);
Item(std::string, const Rarity);
Item(std::string, std::filesystem::path, const Category, std::string,
std::string, Frames, Frames);
[[nodiscard]] std::string GetItemName() const;
[[nodiscard]] uint32_t GetPrice() const;

View File

@ -41,12 +41,12 @@ namespace Starbound {
class Metadata {
public:
Metadata() = default;
Metadata(const std::string &, const std::string &, const std::string &,
const std::string & =
Metadata(std::string, std::string, std::string,
std::string =
"This mod has been generated via speciesgen made by prisixia.",
const std::string & = "1.0.0_gen" SPECIESGEN_VERSION,
const std::string & = "http://git.vern.cc/prisixia/speciesgen",
const std::vector<std::string> & = {"starpounds"});
std::string = "1.0.0_gen" SPECIESGEN_VERSION,
std::string = "http://git.vern.cc/prisixia/speciesgen",
std::vector<std::string> = {"starpounds"});
[[nodiscard]] std::string GetName() const;
[[nodiscard]] std::string GetFriendlyName() const;

View File

@ -39,8 +39,8 @@ namespace Starpounds {
class SpeciesConfig {
public:
SpeciesConfig(const bool = false);
SpeciesConfig(const std::string &, const bool = false);
SpeciesConfig(const std::string &, const std::string &, const bool = false);
SpeciesConfig(std::string, const bool = false);
SpeciesConfig(std::string, std::string, const bool = false);
[[nodiscard]] bool GetFullbright() const;
[[nodiscard]] std::string GetOverride() const;

View File

@ -43,10 +43,9 @@ namespace Starpounds {
class WeightStageSub {
public:
WeightStageSub() = default;
WeightStageSub(const std::string &, const std::string &,
const std::string &, const Types::Chests);
WeightStageSub(const std::string &);
WeightStageSub(const Types::Subs, const std::string &);
WeightStageSub(std::string, std::string, std::string, const Types::Chests);
WeightStageSub(std::string);
WeightStageSub(const Types::Subs, std::string);
[[nodiscard]] std::string GetName() const;
[[nodiscard]] std::string GetFriendlyName() const;
@ -69,11 +68,10 @@ class WeightStage : public WeightStageSub {
public:
WeightStage() = default;
WeightStage(const std::string &, const std::string &, const std::string &,
const Types::Chests, const std::string &, const Types::Legs,
const bool, const bool,
const std::vector<WeightStageSub> & = {});
const Types::Chests, std::string, const Types::Legs, const bool,
const bool, std::vector<WeightStageSub> = {});
WeightStage(const std::string &, const bool, const bool,
const std::vector<WeightStageSub> & = {});
std::vector<WeightStageSub> = {});
[[nodiscard]] std::string GetLegDescription() const;
[[nodiscard]] Types::Legs GetLegType() const;

View File

@ -26,8 +26,8 @@ namespace SpeciesGen {
// ErrorHandler
//----------------------------------------------------------------------
ErrorHandler::ErrorHandler(const std::string &handlerName)
: m_handlerName(handlerName) {}
ErrorHandler::ErrorHandler(std::string handlerName)
: m_handlerName(std::move(handlerName)) {}
std::string ErrorHandler::GetError(const size_t index) {
const std::string handlerName = m_handlerName;

View File

@ -26,10 +26,10 @@ namespace Starbound::Frames {
// Grid
//----------------------------------------------------------------------
Grid::Grid(const std::vector<std::vector<std::optional<std::string>>> &names,
Grid::Grid(std::vector<std::vector<std::optional<std::string>>> names,
const std::tuple<uint32_t, uint32_t> size,
const std::tuple<uint32_t, uint32_t> dimensions)
: m_size(size), m_dimensions(dimensions), m_names(names) {}
: m_size(size), m_dimensions(dimensions), m_names(std::move(names)) {}
std::tuple<uint32_t, uint32_t> Grid::GetSize() const { return m_size; }
@ -56,9 +56,8 @@ void Grid::SetNames(
// Frames
//----------------------------------------------------------------------
Frames::Frames(const std::unordered_map<std::string, std::string> &aliases,
const Grid &grid)
: m_aliases(aliases), m_grid(grid) {}
Frames::Frames(std::unordered_map<std::string, std::string> aliases, Grid grid)
: m_aliases(std::move(aliases)), m_grid(std::move(grid)) {}
std::unordered_map<std::string, std::string> Frames::GetAliases() const {
return m_aliases;

View File

@ -26,12 +26,12 @@ namespace Starbound::Item {
// Frames
//----------------------------------------------------------------------
Frames::Frames(const std::filesystem::path &body) : m_body(body) {}
Frames::Frames(std::filesystem::path body) : m_body(std::move(body)) {}
Frames::Frames(const std::filesystem::path &body,
const std::filesystem::path &backSleeve,
const std::filesystem::path &frontSleeve)
: m_body(body), m_backSleeve(backSleeve), m_frontSleeve(frontSleeve) {}
Frames::Frames(std::filesystem::path body, std::filesystem::path backSleeve,
std::filesystem::path frontSleeve)
: m_body(std::move(body)), m_backSleeve(std::move(backSleeve)),
m_frontSleeve(std::move(frontSleeve)) {}
std::filesystem::path Frames::GetBody() const { return m_body; }
@ -53,18 +53,19 @@ void Frames::SetFrontSleeve(const std::filesystem::path &frontSleeve) {
// Item
//----------------------------------------------------------------------
Item::Item(const std::string &itemName, const Rarity rarity)
: m_itemName(itemName), m_price(0), m_maxStack(1), m_rarity(rarity) {}
Item::Item(std::string itemName, const Rarity rarity)
: m_itemName(std::move(itemName)), m_price(0), m_maxStack(1), m_rarity(rarity) {}
Item::Item(const std::string &itemName,
const std::filesystem::path &inventoryIcon, const Category category,
const std::string &description, const std::string &shortDescription,
const Frames &maleFrames, const Frames &femaleFrames)
: m_itemName(itemName), m_price(0), m_inventoryIcon(inventoryIcon),
m_maxStack(1), m_rarity(Rarity::Essential), m_category(category),
m_description(description), m_shortDescription(shortDescription),
m_tooltipKind(TooltipKind::Armor), m_maleFrames(maleFrames),
m_femaleFrames(femaleFrames) {}
Item::Item(std::string itemName, std::filesystem::path inventoryIcon,
const Category category, std::string description,
std::string shortDescription, Frames maleFrames, Frames femaleFrames)
: m_itemName(std::move(itemName)), m_price(0),
m_inventoryIcon(std::move(inventoryIcon)), m_maxStack(1),
m_rarity(Rarity::Essential), m_category(category),
m_description(std::move(description)),
m_shortDescription(std::move(shortDescription)),
m_tooltipKind(TooltipKind::Armor), m_maleFrames(std::move(maleFrames)),
m_femaleFrames(std::move(femaleFrames)) {}
std::string Item::GetItemName() const { return m_itemName; }

View File

@ -26,13 +26,14 @@ namespace Starbound {
// Metadata
//----------------------------------------------------------------------
Metadata::Metadata(const std::string &name, const std::string &friendlyName,
const std::string &author, const std::string &description,
const std::string &version, const std::string &link,
const std::vector<std::string> &_requires)
: m_name(name), m_friendlyName(friendlyName), m_author(author),
m_description(description), m_version(version), m_link(link),
m_requires(_requires), m_priority(0) {}
Metadata::Metadata(std::string name, std::string friendlyName,
std::string author, std::string description,
std::string version, std::string link,
std::vector<std::string> _requires)
: m_name(std::move(name)), m_friendlyName(std::move(friendlyName)),
m_author(std::move(author)), m_description(std::move(description)),
m_version(std::move(version)), m_link(std::move(link)),
m_requires(std::move(_requires)), m_priority(0) {}
std::string Metadata::GetName() const { return m_name; }

View File

@ -23,14 +23,13 @@ along with speciesgen. If not, see <https://www.gnu.org/licenses/>.
namespace Starpounds {
SpeciesConfig::SpeciesConfig(const bool fullbright)
: m_fullbright(fullbright) {}
SpeciesConfig::SpeciesConfig(const std::string &_override,
SpeciesConfig::SpeciesConfig(std::string _override, const bool fullbright)
: m_fullbright(fullbright), m_override(std::move(_override)) {}
SpeciesConfig::SpeciesConfig(std::string _override,
std::string overrideDirectives,
const bool fullbright)
: m_fullbright(fullbright), m_override(_override) {}
SpeciesConfig::SpeciesConfig(const std::string &_override,
const std::string &overrideDirectives,
const bool fullbright)
: m_fullbright(fullbright), m_override(_override),
m_overrideDirectives(overrideDirectives) {}
: m_fullbright(fullbright), m_override(std::move(_override)),
m_overrideDirectives(std::move(overrideDirectives)) {}
bool SpeciesConfig::GetFullbright() const { return m_fullbright; }
std::string SpeciesConfig::GetOverride() const { return m_override; }

View File

@ -26,20 +26,20 @@ namespace Starpounds {
// WeightStageSub
//----------------------------------------------------------------------
WeightStageSub::WeightStageSub(const std::string &name,
const std::string &friendlyName,
const std::string &descriptionChest,
WeightStageSub::WeightStageSub(std::string name, std::string friendlyName,
std::string descriptionChest,
const Types::Chests typeChest)
: m_name(name), m_friendlyName(friendlyName),
m_descriptionChest(descriptionChest), m_typeChest(typeChest) {}
: m_name(std::move(name)), m_friendlyName(std::move(friendlyName)),
m_descriptionChest(std::move(descriptionChest)), m_typeChest(typeChest) {}
WeightStageSub::WeightStageSub(const std::string &name)
: m_name(name), m_typeChest(Types::Chests::Chest) {}
WeightStageSub::WeightStageSub(std::string name)
: m_name(std::move(name)), m_typeChest(Types::Chests::Chest) {}
WeightStageSub::WeightStageSub(const Types::Subs type,
const std::string &descriptionChest)
std::string descriptionChest)
: m_name(Types::AsString(type)), m_friendlyName(Types::AsFriendly(type)),
m_descriptionChest(descriptionChest), m_typeChest(Types::AsChest(type)) {}
m_descriptionChest(std::move(descriptionChest)),
m_typeChest(Types::AsChest(type)) {}
std::string WeightStageSub::GetName() const { return m_name; }
@ -73,17 +73,17 @@ WeightStage::WeightStage(const std::string &name,
const std::string &friendlyName,
const std::string &descriptionChest,
const Types::Chests typeChest,
const std::string &descriptionLeg,
const Types::Legs typeLeg, const bool frames,
const bool id, const std::vector<WeightStageSub> &subs)
std::string descriptionLeg, const Types::Legs typeLeg,
const bool frames, const bool id,
std::vector<WeightStageSub> subs)
: WeightStageSub(name, friendlyName, descriptionChest, typeChest),
m_descriptionLeg(descriptionLeg), m_typeLeg(typeLeg), m_frames(frames),
m_id(id), m_subs(subs) {}
m_descriptionLeg(std::move(descriptionLeg)), m_typeLeg(typeLeg),
m_frames(frames), m_id(id), m_subs(std::move(subs)) {}
WeightStage::WeightStage(const std::string &name, const bool frames,
const bool id, const std::vector<WeightStageSub> &subs)
const bool id, std::vector<WeightStageSub> subs)
: WeightStageSub(name), m_typeLeg(Types::Legs::Legs), m_frames(frames),
m_id(id), m_subs(subs) {}
m_id(id), m_subs(std::move(subs)) {}
std::string WeightStage::GetLegDescription() const { return m_descriptionLeg; }