-
Notifications
You must be signed in to change notification settings - Fork 457
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
base: develop
Are you sure you want to change the base?
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.
| if (this->NumCompressors > 1) { | ||
| UpperStageCompressorRatio = (1.0 - this->CompressorSizeRatio) / (this->NumCompressors - 1); | ||
| int Stage; // used for crankcase heater power calculation | ||
| for (Stage = 1; Stage <= this->NumCompressors - 2; ++Stage) { |
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.
really? could you reduce scope by 1 more line?
src/EnergyPlus/OutAirNodeManager.cc
Outdated
| // Loop over all outside air inlet nodes in the input and count them | ||
| CurrentModuleObject = "OutdoorAir:NodeList"; | ||
| int OutAirInletNodeListNum; // OUTSIDE AIR INLET NODE LIST index | ||
| for (OutAirInletNodeListNum = 1; OutAirInletNodeListNum <= NumOutAirInletNodeLists; ++OutAirInletNodeListNum) { |
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.
Several of these here and below, for (int xxx
| 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 |
|
|
|
|
|
src/EnergyPlus/DXCoils.cc
Outdated
| int CapacityStageNum; // Loop index for 1,Number of capacity stages | ||
| for (DehumidModeNum = 0; DehumidModeNum <= thisDXCoil.NumDehumidModes; ++DehumidModeNum) { | ||
| int CapacityStageNum; // Loop index for 1,Number of capacity stages | ||
| for (CapacityStageNum = 1; CapacityStageNum <= thisDXCoil.NumCapacityStages; ++CapacityStageNum) { |
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.
You can delete lines 7044 and 7045 and update line 7046 with for (int DehumidModeNum and line 7047 with for (int CapacityStageNum. Same for lines 14665 and 15083 below.
|
|
|
|
|
|
|
|
|
|
|
|
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.
Pull Request Author
Reviewer