-
Notifications
You must be signed in to change notification settings - Fork 461
CppCheck Cleanups #11319
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
CppCheck Cleanups #11319
Conversation
rraustad
left a comment
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.
CppCheck is running pretty fast so including these doesn't seem to hurt GHA run time.
|
@rraustad yeah, I don't think it was the speed, but that it was just that those files were throwing some errors that they didn't have time to deal with. |
|
|
|
|
|
|
||
| // Check the number of primary air loops | ||
| if (!simulation_control.DuctLoss) { | ||
| int NumAPL; |
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.
I would think this should be initialized to 0 here since distribution_simulated could be false? and NumAPL is used at line 2224.
src/EnergyPlus/BaseboardElectric.cc
Outdated
| int BaseboardNum = 0; | ||
| for (int ConvElecBBNum = 1; ConvElecBBNum <= NumConvElecBaseboards; ++ConvElecBBNum) { | ||
|
|
||
| auto &s_ipsc = state.dataIPShortCut; |
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.
Shouldn't this be done outside the for loop? after line 190?
src/EnergyPlus/DataHeatBalance.cc
Outdated
| for (nLayer = 1; nLayer <= Construction::MaxLayersInConstruct; ++nLayer) { | ||
| state.dataConstruction->Construct(state.dataHeatBal->TotConstructs).LayerPoint(nLayer) = state.dataConstruction->LayerPoint(nLayer); | ||
| if (state.dataConstruction->LayerPoint(nLayer) != 0) { | ||
| auto &s_mat = state.dataMaterial; |
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.
Same here, do this just above line 863?
src/EnergyPlus/DemandManager.cc
Outdated
|
|
||
| auto &thisDemandMgrList = state.dataDemandManager->DemandManagerList(ListNum); | ||
|
|
||
| auto &s_ipsc = state.dataIPShortCut; |
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.
Same, outside for loop.
src/EnergyPlus/DuctLoss.cc
Outdated
| for (int DuctLossNum = 1; DuctLossNum <= state.dataDuctLoss->NumOfDuctLosses; DuctLossNum++) { | ||
| auto &thisDuctLoss(state.dataDuctLoss->ductloss(DuctLossNum)); | ||
|
|
||
| std::string CurrentModuleObject; |
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.
outside for loop.
| bool errorsFound = false; | ||
| std::string &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; | ||
| for (auto const &classToInput : classesToInput) { | ||
| std::string &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; |
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.
I wonder why CppCheck would want this scope reduced?? and line 3780.
|
@mitchute @rraustad I started the CppCheck cleanup with the |
|
…nto code-integrity
|
|
|
|
mitchute
left a comment
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.
Alright, this is "fine" enough for now. Mostly just silly scope adjustments for variables where cppcheck was complaining. It does address a small bug in HeatBalanceSurfaceManager, which is causing some diffs.
| -i EnergyPlus/DXCoils.cc | ||
| -i EnergyPlus/RefrigeratedCase.cc | ||
| -i EnergyPlus/SolarShading.cc |
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.
These were being ignored previously. Adding them back now.
| --suppress="uninitvar:*" \ | ||
| --suppress="arrayIndexThenCheck:*" \ | ||
| --suppress="checkLevelNormal:*" \ | ||
| --suppress="constParameterPointer:*" \ | ||
| --suppress="constParameterReference:*" \ | ||
| --suppress="constVariable:*" \ | ||
| --suppress="constVariablePointer:*" \ | ||
| --suppress="constVariableReference:*" \ | ||
| --suppress="cstyleCast:*" \ | ||
| --suppress="duplicateCondition:*" \ | ||
| --suppress="duplicateExpression:*" \ | ||
| --suppress="knownConditionTrueFalse:*" \ | ||
| --suppress="multiCondition:*" \ | ||
| --suppress="noExplicitConstructor:*" \ | ||
| --suppress="passedByValueCallback:*" \ | ||
| --suppress="redundantAssignment:*" \ | ||
| --suppress="redundantCondition:*" \ | ||
| --suppress="redundantInitialization:*" \ | ||
| --suppress="sameIteratorExpression:*" \ | ||
| --suppress="shadowFunction:*" \ | ||
| --suppress="shadowVariable:*" \ | ||
| --suppress="unassignedVariable:*" \ | ||
| --suppress="unmatchedSuppression:*" \ | ||
| --suppress="unpreciseMathCall:*" \ | ||
| --suppress="unreadVariable:*" \ | ||
| --suppress="useInitializationList:*" \ | ||
| --suppress="useStlAlgorithm:*" \ | ||
| --suppress="uselessAssignmentArg:*" \ | ||
| --suppress="uselessCallsSubstr:*" \ |
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.
These all exist currently, but we don't do anything about them. After this PR, cppcheck should be "clean." We will keep working to address these, but at least we will know if anything new is popping up after this.
| // Start of Step 1 ... | ||
| // set to tiny value to avoid log(0) below | ||
| AMatRowNormMax = 1e-12; |
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.
As stated, changed to avoid log(0) below.
| auto &cmpType = state.dataPlnt->PlantLoop(loopNum).plantCoilObjectTypes; | ||
| int arrayIndex = -1; | ||
| // check if component has been added to array | ||
| if (!plntComps.empty()) { | ||
| auto &cmpType = state.dataPlnt->PlantLoop(loopNum).plantCoilObjectTypes; |
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.
Most of these are just scope adjustments. I'm not going to review them individually.
| int slatIdxLo = surfShade.blind.slatAngIdxLo; | ||
| int slatIdxHi = surfShade.blind.slatAngIdxLo; | ||
| int slatIdxHi = surfShade.blind.slatAngIdxHi; |
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.
This appears to be a bug that was addressed here. It's causing some minor diffs in results.
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.
@mitchute maybe this change should be reverted here to see if diffs go away? CppCheck changes typically require no diffs.
|
|
|
|
|
Thanks @dareumnam. Merging. |
Pull request overview
CppCheck has a flagged number of warnings, as well as some style and performance recommendations. In addition, several files are being ignored. This is expected to be a pass at moving these towards a better place.
Update: this generally only addresses variables out of scope.
Pull Request Author
Reviewer