Skip to content
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 consts #10875

Merged
merged 21 commits into from
Jan 9, 2025
2 changes: 1 addition & 1 deletion src/EnergyPlus/CurveManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3002,7 +3002,7 @@ namespace Curve {
std::string_view curveFieldText)
{
// Returns true if errors found
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveIndex);
Curve const *thisCurve = state.dataCurveManager->PerfCurve(CurveIndex);
int curveDim = thisCurve->numDims;
if (std::find(validDims.begin(), validDims.end(), curveDim) != validDims.end()) return false;

Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/DataSizing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ Real64 OARequirementsData::calcOAFlowRate(EnergyPlusData &state,
Real64 curNumOccupants = 0.0;
Real64 maxOccupants = 0.0;
if (spaceNum > 0) {
auto &thisSpace = state.dataHeatBal->space(spaceNum);
auto const &thisSpace = state.dataHeatBal->space(spaceNum);
floorArea = thisSpace.FloorArea;
volume = thisSpace.Volume;
nomTotOccupants = thisSpace.TotOccupants;
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/EMSManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ namespace EMSManager {
}

auto const &thisErlVar = state.dataRuntimeLang->ErlVariable(ErlVariableNum);
auto &thisActuatorAvail = state.dataRuntimeLang->EMSActuatorAvailable(EMSActuatorVariableNum);
auto const &thisActuatorAvail = state.dataRuntimeLang->EMSActuatorAvailable(EMSActuatorVariableNum);

if (thisErlVar.Value.Type == DataRuntimeLanguage::Value::Null) {
*thisActuatorAvail.Actuated = false;
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/EconomicLifeCycleCost.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void GetInputLifeCycleCostParameters(EnergyPlusData &state)
AlphaArray.allocate(NumAlphas);
NumObj = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);

auto &elcc(state.dataEconLifeCycleCost);
auto const &elcc = state.dataEconLifeCycleCost;

if (NumObj == 0) {
elcc->LCCparamPresent = false;
Expand Down
8 changes: 4 additions & 4 deletions src/EnergyPlus/FluidProperties.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2776,7 +2776,7 @@ namespace FluidProperties {

if (!state.dataGlobal->WarmupFlag && ErrorFlag) {
++this->errors[(int)RefrigError::SatTemp].count;
auto &df = state.dataFluidProps;
auto const &df = state.dataFluidProps;

// send warning
if (this->errors[(int)RefrigError::SatTemp].count <= df->RefrigErrorLimitTest) {
Expand Down Expand Up @@ -2871,7 +2871,7 @@ namespace FluidProperties {

if (!state.dataGlobal->WarmupFlag && ErrorFlag) {
++this->errors[(int)RefrigError::SatPress].count;
auto &df = state.dataFluidProps;
auto const &df = state.dataFluidProps;

// send warning
if (this->errors[(int)RefrigError::SatPress].count <= df->RefrigErrorLimitTest) {
Expand Down Expand Up @@ -3043,7 +3043,7 @@ namespace FluidProperties {

if (!state.dataGlobal->WarmupFlag && ErrorFlag) {
++this->errors[(int)RefrigError::SatTempDensity].count;
auto &df = state.dataFluidProps;
auto const &df = state.dataFluidProps;

// send warning
if (this->errors[(int)RefrigError::SatTempDensity].count <= df->RefrigErrorLimitTest) {
Expand Down Expand Up @@ -3540,7 +3540,7 @@ namespace FluidProperties {
}

if (ErrCount > 0 && !state.dataGlobal->WarmupFlag) {
auto &df = state.dataFluidProps;
auto const &df = state.dataFluidProps;

// send near saturation warning if flagged
this->errors[(int)RefrigError::SatSupPress].count += CurSatErrCount;
Expand Down
6 changes: 3 additions & 3 deletions src/EnergyPlus/GroundHeatExchangers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ void GLHEVert::setupTimeVectors()

this->myRespFactors->LNTTS = tempLNTTS;
this->myRespFactors->time = tempLNTTS;
std::transform(this->myRespFactors->time.begin(), this->myRespFactors->time.end(), this->myRespFactors->time.begin(), [&t_s](auto &c) {
std::transform(this->myRespFactors->time.begin(), this->myRespFactors->time.end(), this->myRespFactors->time.begin(), [&t_s](auto const &c) {
return exp(c) * t_s;
});
this->myRespFactors->GFNC = std::vector<Real64>(tempLNTTS.size(), 0.0);
Expand Down Expand Up @@ -1323,7 +1323,7 @@ void GLHEVert::calcShortTimestepGFunctions(EnergyPlusData &state)

//******************************************************************************

std::vector<Real64> TDMA(std::vector<Real64> a, std::vector<Real64> b, std::vector<Real64> c, std::vector<Real64> d)
std::vector<Real64> TDMA(std::vector<Real64> const &a, std::vector<Real64> const &b, std::vector<Real64> &c, std::vector<Real64> &d)
{
// from: https://en.wikibooks.org/wiki/Algorithm_Implementation/Linear_Algebra/Tridiagonal_matrix_algorithm#C.2B.2B

Expand Down Expand Up @@ -1369,7 +1369,7 @@ void GLHEVert::combineShortAndLongTimestepGFunctions()
}

this->myRespFactors->time = LNTTS_combined;
std::transform(this->myRespFactors->time.begin(), this->myRespFactors->time.end(), this->myRespFactors->time.begin(), [&t_s](auto &c) {
std::transform(this->myRespFactors->time.begin(), this->myRespFactors->time.end(), this->myRespFactors->time.begin(), [&t_s](auto const &c) {
return exp(c) * t_s;
});

Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/GroundHeatExchangers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ namespace GroundHeatExchangers {

std::shared_ptr<GLHEVertArray> GetVertArray(EnergyPlusData &state, std::string const &objectName);

std::vector<Real64> TDMA(std::vector<Real64> a, std::vector<Real64> b, std::vector<Real64> c, std::vector<Real64> d);
std::vector<Real64> TDMA(std::vector<Real64> const &a, std::vector<Real64> const &b, std::vector<Real64> &c, std::vector<Real64> &d);

} // namespace GroundHeatExchangers

Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/HeatBalanceAirManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4954,11 +4954,11 @@ void ReportZoneMeanAirTemp(EnergyPlusData &state)
state.dataHeatBalAirMgr->CalcExtraReportVarMyOneTimeFlag = false;
}
for (int ZoneLoop = 1; ZoneLoop <= state.dataGlobal->NumOfZones; ++ZoneLoop) {
auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneLoop);
auto const &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneLoop);
calcMeanAirTemps(state, thisZoneHB.ZTAV, thisZoneHB.airHumRatAvg, thisZoneHB.MRT, state.dataHeatBal->ZnAirRpt(ZoneLoop), ZoneLoop);
if (state.dataHeatBal->doSpaceHeatBalanceSimulation) {
for (int spaceNum : state.dataHeatBal->Zone(ZoneLoop).spaceIndexes) {
auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum);
auto const &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum);
calcMeanAirTemps(
state, thisSpaceHB.ZTAV, thisSpaceHB.airHumRatAvg, thisSpaceHB.MRT, state.dataHeatBal->spaceAirRpt(spaceNum), ZoneLoop);
}
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/HeatBalanceSurfaceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3476,7 +3476,7 @@ void InitSolarHeatGains(EnergyPlusData &state)
// Exterior shade, screen or blind

} else if (ShadeFlag == DataSurfaces::WinShadingType::ExtBlind) { // Exterior blind
auto &surfShade = state.dataSurface->surfShades(SurfNum);
auto const &surfShade = state.dataSurface->surfShades(SurfNum);

int profIdxLo = surfShade.blind.profAngIdxLo;
int profIdxHi = surfShade.blind.profAngIdxHi;
Expand Down Expand Up @@ -4247,7 +4247,7 @@ void ComputeIntSWAbsorpFactors(EnergyPlusData &state)
// Window with shade, screen or blind

if (ConstrNumSh != 0) {
auto &constrSh = state.dataConstruction->Construct(ConstrNumSh);
auto const &constrSh = state.dataConstruction->Construct(ConstrNumSh);
if (ANY_SHADE_SCREEN(ShadeFlag)) {
TransDiffWin = constrSh.TransDiff;
DiffAbsShade = constrSh.AbsDiffBackShade;
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/HighTempRadiantSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ namespace HighTempRadiantSystem {
HeatBalanceSurfaceManager::CalcHeatBalanceInsideSurf(state, ZoneNum);

// Redetermine the current value of the controlling temperature
auto &thisZoneHBMod = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum);
auto const &thisZoneHBMod = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum);
switch (thisHTR.ControlType) {
case RadControlType::MATControl: {
ZoneTemp = thisZoneHBMod.MAT;
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/HybridEvapCoolingModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ namespace HybridEvapCoolingModel {
Real64 MassFlowDependentDenominator = 0;
Real64 value = 0;

for (auto &thisOperatingSettings : CurrentOperatingSettings) {
for (auto const &thisOperatingSettings : CurrentOperatingSettings) {
switch (val) {
case SYSTEMOUTPUTS::VENTILATION_AIR_V:
value = thisOperatingSettings.ScaledSupply_Air_Ventilation_Volume;
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/IceThermalStorage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,7 @@ namespace IceThermalStorage {
}
}

void UpdateIceFractions(EnergyPlusData &state)
void UpdateIceFractions(EnergyPlusData const &state)
{

// SUBROUTINE INFORMATION:
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/IceThermalStorage.hh
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ namespace IceThermalStorage {

Real64 TempIPtoSI(Real64 Temp);

void UpdateIceFractions(EnergyPlusData &state);
void UpdateIceFractions(EnergyPlusData const &state);

} // namespace IceThermalStorage

Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/IndoorGreen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace IndoorGreen {
// PURPOSE OF THIS SUBROUTINE:
// This subroutine simulates the thermal performance of indoor living walls including the grow lights.
// This subroutine interacts with inside surface heat balance, zone air heat balance and zone air moisture balance in EnergyPlus.
auto &lw = state.dataIndoorGreen;
auto const &lw = state.dataIndoorGreen;
if (lw->getInputFlag) {
bool ErrorsFound(false);
const char *RoutineName("IndoorLivingWall: "); // include trailing blank space
Expand Down Expand Up @@ -459,7 +459,7 @@ namespace IndoorGreen {
}
}

void InitIndoorGreen(EnergyPlusData &state)
void InitIndoorGreen(EnergyPlusData const &state)
{
// Set the reporting variables to zero at each timestep.
for (auto &ig : state.dataIndoorGreen->indoorGreens) {
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/IndoorGreen.hh
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ namespace IndoorGreen {
void SimIndoorGreen(EnergyPlusData &state);
void GetIndoorGreenInput(EnergyPlusData &state, bool &ErrorsFound);
void SetIndoorGreenOutput(EnergyPlusData &state);
void InitIndoorGreen(EnergyPlusData &state);
void InitIndoorGreen(EnergyPlusData const &state);
void ETModel(EnergyPlusData &state);
Real64 ETBaseFunction(EnergyPlusData &state, Real64 ZonePreTemp, Real64 ZonePreHum, Real64 ZonePPFD, Real64 VPD, Real64 LAI, Real64 SwitchF);

Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/InternalHeatGains.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3339,7 +3339,7 @@ namespace InternalHeatGains {
SetPointManager::GetSetPointManagerInputs(state);
for (auto *spm : state.dataSetPointManager->spms) {
if (spm->type != SetPointManager::SPMType::SZCooling) continue;
auto *spmSZC = dynamic_cast<SetPointManager::SPMSingleZoneTemp *>(spm);
auto const *spmSZC = dynamic_cast<SetPointManager::SPMSingleZoneTemp *>(spm);
assert(spmSZC != nullptr);
if (spmSZC->ctrlZoneNum == zoneNum) {
TAirInSizing = spmSZC->maxSetTemp;
Expand Down Expand Up @@ -8046,7 +8046,7 @@ namespace InternalHeatGains {
for (int Loop = 1; Loop <= state.dataHeatBal->TotITEquip; ++Loop) {
// Get schedules
int NZ = state.dataHeatBal->ZoneITEq(Loop).ZonePtr;
auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(NZ);
auto const &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(NZ);
int spaceNum = state.dataHeatBal->ZoneITEq(Loop).spaceIndex;
OperSchedFrac = GetCurrentScheduleValue(state, state.dataHeatBal->ZoneITEq(Loop).OperSchedPtr);
CPULoadSchedFrac = GetCurrentScheduleValue(state, state.dataHeatBal->ZoneITEq(Loop).CPULoadSchedPtr);
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/MixedAir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2022,9 +2022,9 @@ void ProcessOAControllerInputs(EnergyPlusData &state,
std::string_view const CurrentModuleObject,
int const OutAirNum,
Array1D_string const &AlphArray,
int &NumAlphas,
int const NumAlphas,
Array1D<Real64> const &NumArray,
int &NumNums,
int const NumNums,
Array1D_bool const &lNumericBlanks, // Unused
Array1D_bool const &lAlphaBlanks,
Array1D_string const &cAlphaFields,
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/MixedAir.hh
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ namespace MixedAir {
std::string_view CurrentModuleObject,
int OutAirNum,
Array1D_string const &AlphArray,
int &NumAlphas,
int const NumAlphas,
Array1D<Real64> const &NumArray,
int &NumNums,
int const NumNums,
Array1D_bool const &lNumericBlanks, // Unused
Array1D_bool const &lAlphaBlanks,
Array1D_string const &cAlphaFields,
Expand Down
22 changes: 11 additions & 11 deletions src/EnergyPlus/OutputProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ namespace OutputProcessor {
// Make sure that input has been read
GetReportVariableInput(state);

auto &op = state.dataOutputProcessor;
auto const &op = state.dataOutputProcessor;

for (int iReqVar = 0; iReqVar < (int)op->reqVars.size(); ++iReqVar) {
auto *reqVar = op->reqVars[iReqVar];
Expand Down Expand Up @@ -1701,7 +1701,7 @@ namespace OutputProcessor {
// Resets the accumulating meter values. Needed after warmup period is over to
// reset the totals on meters so that they are not accumulated over the warmup period

auto &op = state.dataOutputProcessor;
auto const &op = state.dataOutputProcessor;

for (auto *meter : op->meters) {
for (int iPeriod = (int)ReportFreq::Hour; iPeriod < (int)ReportFreq::Num; ++iPeriod) {
Expand Down Expand Up @@ -3725,7 +3725,7 @@ void UpdateMeterReporting(EnergyPlusData &state)
int NumReqMeterFOs;

bool ErrorsFound(false); // If errors detected in input
auto &op = state.dataOutputProcessor;
auto const &op = state.dataOutputProcessor;
auto &ipsc = state.dataIPShortCut;

GetCustomMeterInput(state, ErrorsFound);
Expand All @@ -3743,7 +3743,7 @@ void UpdateMeterReporting(EnergyPlusData &state)
name.erase(varnameLen);
}

auto &op = state.dataOutputProcessor;
auto const &op = state.dataOutputProcessor;

std::string::size_type wildCardPosition = index(name, '*');

Expand Down Expand Up @@ -4007,7 +4007,7 @@ Real64 GetInstantMeterValue(EnergyPlusData &state,

if (meterNum == -1) return InstantMeterValue;

auto &op = state.dataOutputProcessor;
auto const &op = state.dataOutputProcessor;
auto *meter = op->meters[meterNum];

if (meter->type == MeterType::Normal || meter->type == MeterType::Custom) {
Expand Down Expand Up @@ -4072,7 +4072,7 @@ Real64 GetInternalVariableValue(EnergyPlusData &state,
// Return value
Real64 resultVal; // value returned

auto &op = state.dataOutputProcessor;
auto const &op = state.dataOutputProcessor;

// Select based on variable type: integer, real, or meter
if (varType == VariableType::Invalid) { // Variable not a found variable
Expand Down Expand Up @@ -4123,7 +4123,7 @@ Real64 GetInternalVariableValueExternalInterface(EnergyPlusData &state,
// Return value
Real64 resultVal; // value returned

auto &op = state.dataOutputProcessor;
auto const &op = state.dataOutputProcessor;

// Select based on variable type: integer, REAL(r64), or meter
if (varType == VariableType::Invalid) { // Variable not a found variable
Expand Down Expand Up @@ -4281,7 +4281,7 @@ void GetVariableKeyCountandType(EnergyPlusData &state,
using ScheduleManager::GetScheduleType;

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
auto &op = state.dataOutputProcessor;
auto const &op = state.dataOutputProcessor;

varType = VariableType::Invalid;
numKeys = 0;
Expand Down Expand Up @@ -4410,7 +4410,7 @@ bool ReportingThisVariable(EnergyPlusData &state, std::string const &RepVarName)
// if user has requested this variable be reported.
using namespace OutputProcessor;

auto &op = state.dataOutputProcessor;
auto const &op = state.dataOutputProcessor;

std::string name = Util::makeUPPER(RepVarName);

Expand Down Expand Up @@ -4528,8 +4528,8 @@ void ProduceRDDMDD(EnergyPlusData &state)
bool DoReport;
bool SortByName;

auto &op = state.dataOutputProcessor;
auto &rf = state.dataResultsFramework->resultsFramework;
auto const &op = state.dataOutputProcessor;
auto const &rf = state.dataResultsFramework->resultsFramework;

// See if Report Variables should be turned on
SortByName = false;
Expand Down
6 changes: 3 additions & 3 deletions src/EnergyPlus/OutputReportTabular.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10687,7 +10687,7 @@ void WriteCompCostTable(EnergyPlusData &state)
// na

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
auto &ort = state.dataOutRptTab;
auto const &ort = state.dataOutRptTab;

if (!state.dataCostEstimateManager->DoCostEstimate) {
return;
Expand Down Expand Up @@ -12915,7 +12915,7 @@ void WriteSETHoursTableReportingPeriod(EnergyPlusData &state,
}
}

std::string RetrieveEntryFromTableBody(Array2D_string &tableBody, int const rowIndex, int const columnIndex)
std::string RetrieveEntryFromTableBody(Array2D_string const &tableBody, int const rowIndex, int const columnIndex)
{
return trimmed(ljustified(tableBody(columnIndex, rowIndex)));
}
Expand Down Expand Up @@ -14108,7 +14108,7 @@ void WriteSurfaceShadowing(EnergyPlusData &state)
// Using/Aliasing
using namespace DataShadowingCombinations;

auto &ort = state.dataOutRptTab;
auto const &ort = state.dataOutRptTab;

// displaySurfaceShadowing = false for debugging
if (!ort->displaySurfaceShadowing) {
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/OutputReportTabular.hh
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ namespace OutputReportTabular {
Real64 const unitConvMultiplier = 1.0);

// return the table entry of the rowIndex-th row and columnIndex-th col
std::string RetrieveEntryFromTableBody(Array2D_string &tableBody, int const rowIndex, int const columnIndex);
std::string RetrieveEntryFromTableBody(Array2D_string const &tableBody, int const rowIndex, int const columnIndex);

void WriteHourOfSafetyTable(EnergyPlusData &state,
int const columnNum,
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/Plant/LoopSide.cc
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ namespace DataPlant {
LoopFlowStatus FlowPriorityStatus = component.FlowPriority;

// reference
auto &node_with_request(state.dataLoopNodes->Node(NodeToCheckRequest));
auto const &node_with_request = state.dataLoopNodes->Node(NodeToCheckRequest);

if (!DataPlant::PlantEquipmentTypeIsPump[static_cast<int>(component.Type)]) {

Expand Down
Loading
Loading