Skip to content

Commit

Permalink
code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Oct 16, 2024
1 parent 6bc87fc commit ae979cb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/libs/antares/study/area/links.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ AreaLink::~AreaLink()

bool AreaLink::linkLoadTimeSeries_for_version_below_810(const fs::path& folder)
{
fs::path path = folder / std::string(with->id + ".txt");
fs::path path = folder / static_cast<std::string>(with->id + ".txt");

// Load link's data
Matrix<> tmpMatrix;
Expand Down Expand Up @@ -120,11 +120,11 @@ bool AreaLink::linkLoadTimeSeries_for_version_820_and_later(const fs::path& fold
fs::path capacitiesFolder = folder / "capacities";

// Read link's direct capacities time series
path = capacitiesFolder / std::string(with->id + "_direct.txt");
path = capacitiesFolder / static_cast<std::string>(with->id + "_direct.txt");
success = directCapacities.loadFromFile(path, false) && success;

// Read link's indirect capacities time series
path = capacitiesFolder / std::string(with->id + "_indirect.txt");
path = capacitiesFolder / static_cast<std::string>(with->id + "_indirect.txt");
success = indirectCapacities.loadFromFile(path, false) && success;

return success;
Expand Down
2 changes: 0 additions & 2 deletions src/libs/antares/study/parts/hydro/prepro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ bool PreproHydro::loadFromFolder(Study& s, const std::string& areaID, const fs::
};

constexpr int maxNbOfLineToLoad = 12;

data.resize(hydroPreproMax, 12, true);
String& buffer = s.bufferLoadingTS;

fs::path preproPath = folder / areaID / "prepro.ini";
bool ret = PreproHydroLoadSettings(this, preproPath);
Expand Down
2 changes: 1 addition & 1 deletion src/solver/ts-generator/hydro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ bool GenerateHydroTimeSeries(Data::Study& study, uint currentYear, Solver::IResu
{
logs.info() << "Archiving the hydro time-series";
study.areas.each(
[&study, &currentYear, &writer, &progression](const Data::Area& area)
[&currentYear, &writer, &progression](const Data::Area& area)
{
const int precision = 0;
std::string mcYear = "mc-" + currentYear;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ void List<NextT>::buildSurveyReport(SurveyResults& results,

// The new filename
results.data.filename.clear();
results.data.filename << std::filesystem::path(std::string(results.data.output)) / "";
results.data.filename << std::filesystem::path(static_cast<std::string>(results.data.output))
/ "";
Category::FileLevelToStream(results.data.filename, fileLevel);
results.data.filename << '-';
Category::PrecisionLevelToStream(results.data.filename, precision);
Expand Down Expand Up @@ -280,7 +281,8 @@ void List<NextT>::buildAnnualSurveyReport(SurveyResults& results,

// The new filename
results.data.filename.clear();
results.data.filename << std::filesystem::path(std::string(results.data.output)) / "";
results.data.filename << std::filesystem::path(static_cast<std::string>(results.data.output))
/ "";
Category::FileLevelToStream(results.data.filename, fileLevel);
results.data.filename << '-';
Category::PrecisionLevelToStream(results.data.filename, precision);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public:
}
// THIS FILE IS DEPRECATED !!!
YString digestFileName;
std::filesystem::path path = std::string(results.data.originalOutput);
std::filesystem::path path = static_cast<std::string>(results.data.originalOutput);
path /= "grid";
path /= "digest.txt";
writer.addEntryFromBuffer(path, digestBuffer);
Expand Down Expand Up @@ -320,7 +320,7 @@ private:
{
logs.info() << "Exporting results : " << area.name;
// The new output
std::filesystem::path path = std::string(results.data.originalOutput);
std::filesystem::path path = static_cast<std::string>(results.data.originalOutput);
path /= "areas";
path /= area.id.to<std::string>();

Expand Down Expand Up @@ -356,7 +356,7 @@ private:

logs.info() << "Exporting results : " << area.name << " :: " << cluster->name();
// The new output
std::filesystem::path path = std::string(results.data.originalOutput);
std::filesystem::path path = static_cast<std::string>(results.data.originalOutput);
path /= std::filesystem::path("areas") / area.id.to<std::string>() / "thermal"
/ cluster->id();

Expand Down Expand Up @@ -409,8 +409,10 @@ private:
Antares::logs.info() << "Exporting results : " << area.name << " - "
<< results.data.link->with->name;
// The new output
std::filesystem::path path = std::string(results.data.originalOutput);
std::string areaId = std::string(area.id) + " - " + results.data.link->with->id;
std::filesystem::path path = static_cast<std::string>(
results.data.originalOutput);
std::string areaId = static_cast<std::string>(area.id) + " - "
+ results.data.link->with->id;
path /= std::filesystem::path("links") / areaId;

results.data.output = path.string();
Expand Down Expand Up @@ -456,7 +458,7 @@ private:

logs.info() << "Exporting results : " << sets.caption(i);
// The new output
std::filesystem::path path = std::string(results.data.originalOutput);
std::filesystem::path path = static_cast<std::string>(results.data.originalOutput);
std::string setId = "@ " + sets.nameByIndex(i);
path /= std::filesystem::path("areas") / setId;

Expand All @@ -478,7 +480,7 @@ private:
{
logs.info() << "Exporting results : binding constraints";
// The new output
std::filesystem::path path = std::string(results.data.originalOutput);
std::filesystem::path path = static_cast<std::string>(results.data.originalOutput);
path /= "binding_constraints";

results.data.output = path.string();
Expand Down

0 comments on commit ae979cb

Please sign in to comment.