-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move data validation to specialized functions [ANT-1213] #2149
Conversation
@@ -95,8 +95,9 @@ class PreproHydro | |||
** \param folder The source folder (ex: `input/hydro/prepro`) | |||
** \return A non-zero value if the operation succeeded, 0 otherwise | |||
*/ | |||
bool loadFromFolder(Study& s, const AreaName& areaID, const char folder[]); | |||
bool loadFromFolder(Study& s, const AreaName& areaID, const std::string& folder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible (or usefull) to use std::filesystem::path for folder ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be done in another PR
if (col[day] < 0. || (i % 2U /*column hours*/ && col[day] > 24.)) | ||
{ | ||
logs.error() << areaName << ": invalid power or energy value"; | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Carefull
With the early return you are returning after the first error. Previous behaviour is to check all values and log all errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!errorPower avoided going into this scope after the first error, I simplified while keeping the same behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you don't keep the same behavior. The user will only see the 1st error, not the following ones if any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split loading / validation.
bool loadParameters();
bool validateParameters(); // if (area.hydro.xxx < 1.) { return false;}, etc.
Co-authored-by: Vincent Payet <[email protected]> Co-authored-by: payetvin <[email protected]>
Please retry analysis of this Pull-Request directly on SonarCloud |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good start @payetvin ! Please revert to the former behavior and we're good
if (col[day] < 0. || (i % 2U /*column hours*/ && col[day] > 24.)) | ||
{ | ||
logs.error() << areaName << ": invalid power or energy value"; | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you don't keep the same behavior. The user will only see the 1st error, not the following ones if any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing leewayDown / leewayUp comparison check.
…esSimulatorTeam/Antares_Simulator into feature/modular-validation
Quality Gate passedIssues Measures |
I checked, behavior is unchanged
The goal of this PR is to separate loading and validation of data.
This separation will allow to have a modular loading.