-
Notifications
You must be signed in to change notification settings - Fork 392
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 FluidProperties through HVACUnitaryBypassVAV #10668
Conversation
@@ -2039,9 +2037,8 @@ namespace FluidProperties { | |||
// for the refrigerant properties. | |||
// Most properties requested (e.g., Specific Heat) must be > 0 but the tables may | |||
// be set up for symmetry and not be limited to just valid values. | |||
auto &df = state.dataFluidProps; |
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.
Why?
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 thought we were not supposed to reference a class? Maybe this is different. I can easily put these back.
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.
A class/struct is about the only thing you should reference, what you shouldn't reference is scalars and arrays.
@@ -2759,8 +2752,6 @@ namespace FluidProperties { | |||
|
|||
int LoTempIndex = FindArrayIndex(Temperature, this->PsTemps, this->PsLowTempIndex, this->PsHighTempIndex); | |||
|
|||
auto &df = state.dataFluidProps; |
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.
Why undo this?
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 I'm seeing it right, it looks like this variable just got moved into a smaller scope, not undoing the reference usage.
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.
The references are staying in place (I put them all back in) and only moving if there was a CppCheck reduce scope suggestion. I do want to see CI results though because the Mac results are troubling.
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.
Just to be clear, Mac results are not reliable right now. There is something very odd going on that I'm trying to investigate. Gort and Tik-Tok are doing fine though.
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.
What I see in CppCheck
@@ -1035,7 +1035,7 @@ namespace FluidProperties { | |||
continue; | |||
} | |||
|
|||
auto &supTempArray = FluidTemps(supTempArrayNum); | |||
auto const &supTempArray = FluidTemps(supTempArrayNum); |
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.
[src/EnergyPlus/FluidProperties.cc:1038]:(style),[constVariable],Variable 'supTempArray' can be declared as reference to const
@@ -1441,7 +1441,7 @@ namespace FluidProperties { | |||
|
|||
if (!glycolRaw->CpTempArrayName.empty()) { | |||
int cpTempArrayNum = Util::FindItemInList(glycolRaw->CpTempArrayName, FluidTemps); | |||
auto &cpTempArray = FluidTemps(cpTempArrayNum); | |||
auto const &cpTempArray = FluidTemps(cpTempArrayNum); |
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.
[src/EnergyPlus/FluidProperties.cc:1444]:(style),[constVariable],Variable 'cpTempArray' can be declared as reference to const
@@ -1452,7 +1452,7 @@ namespace FluidProperties { | |||
|
|||
if (!glycolRaw->RhoTempArrayName.empty()) { | |||
int rhoTempArrayNum = Util::FindItemInList(glycolRaw->RhoTempArrayName, FluidTemps); | |||
auto &rhoTempArray = FluidTemps(rhoTempArrayNum); | |||
auto const &rhoTempArray = FluidTemps(rhoTempArrayNum); |
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.
[src/EnergyPlus/FluidProperties.cc:1455]:(style),[constVariable],Variable 'rhoTempArray' can be declared as reference to const
@@ -1463,7 +1463,7 @@ namespace FluidProperties { | |||
|
|||
if (!glycolRaw->CondTempArrayName.empty()) { | |||
int condTempArrayNum = Util::FindItemInList(glycolRaw->CondTempArrayName, FluidTemps); | |||
auto &condTempArray = FluidTemps(condTempArrayNum); | |||
auto const &condTempArray = FluidTemps(condTempArrayNum); |
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.
[src/EnergyPlus/FluidProperties.cc:1466]:(style),[constVariable],Variable 'condTempArray' can be declared as reference to const
@@ -1474,7 +1474,7 @@ namespace FluidProperties { | |||
|
|||
if (!glycolRaw->ViscTempArrayName.empty()) { | |||
int viscTempArrayNum = Util::FindItemInList(glycolRaw->ViscTempArrayName, FluidTemps); | |||
auto &viscTempArray = FluidTemps(viscTempArrayNum); | |||
auto const &viscTempArray = FluidTemps(viscTempArrayNum); |
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.
[src/EnergyPlus/FluidProperties.cc:1477]:(style),[constVariable],Variable 'viscTempArray' can be declared as reference to const
@@ -297,7 +296,6 @@ void GetStandAloneERV(EnergyPlusData &state) | |||
standAloneERV.ExhaustAirFanName = Alphas(5); | |||
GlobalNames::IntraObjUniquenessCheck( | |||
state, Alphas(5), CurrentModuleObject, cAlphaFields(5), state.dataHVACStandAloneERV->ExhaustAirFanUniqueNames, ErrorsFound); | |||
errFlag = 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.
[src/EnergyPlus/HVACStandAloneERV.cc:300]:(style),[redundantAssignment],Variable 'errFlag' is reassigned a value before the old one has been used.
@@ -1695,7 +1693,6 @@ int getEqIndex(EnergyPlusData &state, std::string_view CompName) | |||
for (int StandAloneERVNum = 1; StandAloneERVNum <= state.dataHVACStandAloneERV->NumStandAloneERVs; StandAloneERVNum++) { | |||
if (Util::SameString(CompName, state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).Name)) { | |||
return StandAloneERVNum; | |||
break; |
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.
[src/EnergyPlus/HVACStandAloneERV.cc:1698]:(style),[duplicateBreak],Consecutive return, break, continue, goto or throw statements are unnecessary.
@@ -330,7 +330,6 @@ namespace HVACUnitaryBypassVAV { | |||
bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine | |||
bool DXErrorsFound(false); // Set to true if errors in get coil input | |||
Array1D_int OANodeNums(4); // Node numbers of OA mixer (OA, EA, RA, MA) | |||
std::string HXDXCoolCoilName; // Name of DX cooling coil used with Heat Exchanger Assisted Cooling Coil |
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.
[src/EnergyPlus/HVACUnitaryBypassVAV.cc:333]:(style),[unusedVariable],Unused variable: HXDXCoolCoilName
@@ -754,7 +753,7 @@ namespace HVACUnitaryBypassVAV { | |||
ShowContinueError(state, format("...occurs in {} \"{}\"", thisCBVAV.UnitType, thisCBVAV.Name)); | |||
ErrorsFound = true; | |||
} else { | |||
auto &newCoil = state.dataCoilCooingDX->coilCoolingDXs[thisCBVAV.DXCoolCoilIndexNum]; | |||
auto const &newCoil = state.dataCoilCooingDX->coilCoolingDXs[thisCBVAV.DXCoolCoilIndexNum]; |
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.
[src/EnergyPlus/HVACUnitaryBypassVAV.cc:757]:(style),[constVariable],Variable 'newCoil' can be declared as reference to const
@@ -2444,7 +2443,7 @@ namespace HVACUnitaryBypassVAV { | |||
} | |||
// now find the speed ratio for the found speednum | |||
auto f = [&state, CBVAVNum, SpeedNum, DesOutTemp](Real64 const SpeedRatio) { | |||
auto &thisCBVAV = state.dataHVACUnitaryBypassVAV->CBVAV(CBVAVNum); | |||
auto const &thisCBVAV = state.dataHVACUnitaryBypassVAV->CBVAV(CBVAVNum); |
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.
[src/EnergyPlus/HVACUnitaryBypassVAV.cc:2447]:(style),[constVariable],Variable 'thisCBVAV' can be declared as reference to const
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 look like nice changes. Lots of additional const attributes and lots of reduced scope. 👍 Are you planning to go further on this PR? If not, it should be able to slide in without any major issues.
@@ -2759,8 +2752,6 @@ namespace FluidProperties { | |||
|
|||
int LoTempIndex = FindArrayIndex(Temperature, this->PsTemps, this->PsLowTempIndex, this->PsHighTempIndex); | |||
|
|||
auto &df = state.dataFluidProps; |
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 I'm seeing it right, it looks like this variable just got moved into a smaller scope, not undoing the reference usage.
@Myoldmopar I am not making any other changes on this branch. |
Looks like all the reasonable CI machines are reporting happily, and this removes 26 or so messages from the cppcheck results, cleaning up the code nicely without affecting functionality. Good stuff here, and I'm not waiting to merge. Thanks @rraustad |
Pull request overview
NOTE: ENHANCEMENTS MUST FOLLOW A SUBMISSION PROCESS INCLUDING A FEATURE PROPOSAL AND DESIGN DOCUMENT PRIOR TO SUBMITTING CODE
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Reviewer
This will not be exhaustively relevant to every PR.