Skip to content

Commit

Permalink
Geo/11771 fix code smells in dgeflowcpp reported by sonarcloud (#11819)
Browse files Browse the repository at this point in the history
Fixed some code smells in 'dgeflow.cpp' and 'dgeflow.h' files

* broken down "ExecuteFlowAnalysis" into separate functions to reduce the Cognitive Complexity
* added 'CriticalHeadInfo' structure to reduce the parameters given to the functions
* added some parameters as a member
* made some of the functions 'const'
* replaced 'new' by 'make_shared'
* removed a 'catch' as it was not doing anything
* replaced 'std::cerr' with 'KRATOS_ERROR_IF_NOT(RiverBoundary)' since it was in the if condition: "if (!RiverBoundary)"
* added a function for logging output
* fixed code smell regarding number of nested "break" statements
* built 'CallBackFunctions' structure to reduce code smells
* replaced 2 const references to "std::string" by a "std::string_view"
* replaced the type aliasing to "using" instead of "typedef"
* checked usages of aliases and removed those not being used
* reduced number of parameters given to 'ExecuteFlowAnalysis' function in "dgeflow.cpp" and in "kratos_external_bindings.cpp"
* modified two cpp test files because of the change in parameters given to the 'ExecuteFlowAnalysis' function in "test_head_extrapolation_flow_workflow.cpp" and "test_GeoMechanicsNewtonRaphsonErosionProcessStrategy.cpp" test
* Extracted a loop condition for finding the critical head (One of the loop conditions is whether the current head does not exceed the maximum critical head yet. That logic has been moved to a separate member function, which makes it easier to understand how the loop works. As a result, data member `mExitLoop` was removed, since it had become redundant.)
* replaced 'mCriticalHead' with 'mCurrentHead' in the "AreExceedingMaxCriticalHead" function
  • Loading branch information
indigocoral authored Nov 24, 2023
1 parent 3048ca6 commit 86d7a1f
Show file tree
Hide file tree
Showing 5 changed files with 473 additions and 364 deletions.
Loading

0 comments on commit 86d7a1f

Please sign in to comment.