Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d6a75bc
try running cppcheck on DXCoils, RefrigeratedCase, and SolarShading
mitchute Nov 4, 2025
61bc36b
delete comments?
mitchute Nov 4, 2025
270103a
clamp so cppcheck doesn't throw containerOutOfBounds errors
mitchute Nov 4, 2025
8a4e521
cleanup cppcheck warnings
mitchute Nov 4, 2025
c40ef31
cppcheck performance fixes
mitchute Nov 4, 2025
7e98d30
cppcheck style_variableScope
dareumnam Nov 23, 2025
011884c
pull develop and merge conflicts
dareumnam Nov 23, 2025
a7f2b51
fix error
dareumnam Nov 23, 2025
1e3c22b
fix error 2
dareumnam Nov 23, 2025
78860cc
fix error 3
dareumnam Nov 23, 2025
907b6e0
fix error
dareumnam Nov 24, 2025
334ab6f
style - variableScope 2
dareumnam Dec 1, 2025
a12526d
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into cod…
dareumnam Dec 1, 2025
78decf6
remove unused variables
dareumnam Dec 2, 2025
8c5e976
remove unused variables 2
dareumnam Dec 2, 2025
4fe2225
move declarations outside of for loops to prevent recreating on every…
dareumnam Dec 5, 2025
8be0258
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into cod…
dareumnam Dec 5, 2025
3e60d15
fix-up some local var usages
mitchute Dec 5, 2025
4d0a1c8
fix error 1
dareumnam Dec 7, 2025
0f5eb74
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into cod…
dareumnam Dec 7, 2025
f585416
pull recent code-integrity
dareumnam Dec 7, 2025
bb5ae1f
move declaration out of for loop
dareumnam Dec 10, 2025
99729f6
fix test errors
dareumnam Dec 11, 2025
1efa267
fix errors 2
dareumnam Dec 11, 2025
c1f633d
fix errors 3
dareumnam Dec 11, 2025
18e8325
fix errors 4
dareumnam Dec 12, 2025
a9dc037
fix errors 5
dareumnam Dec 12, 2025
6bbb212
suppress a few cppcheck warnings that are throwing false positives
mitchute Dec 17, 2025
f6bc99e
remaning variable scopes
dareumnam Jan 6, 2026
3a0670d
remaning variable scopes 2
dareumnam Jan 6, 2026
c5eb8f2
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into cod…
dareumnam Jan 6, 2026
30d1300
Merge branch 'code-integrity' of github.com:NREL/EnergyPlus into code…
mitchute Jan 6, 2026
26630bf
fix build errors
mitchute Jan 6, 2026
b312eb3
address more cppcheck variableScope warnings
mitchute Jan 7, 2026
d52eeb6
Merge branch 'develop' into code-integrity
mitchute Jan 7, 2026
ee9aec7
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into cod…
dareumnam Jan 7, 2026
4abe242
Merge branch 'code-integrity' of https://github.com/NREL/EnergyPlus i…
dareumnam Jan 7, 2026
c3485f5
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into cod…
dareumnam Jan 9, 2026
3eea010
rest of variable scope fixes
dareumnam Jan 9, 2026
ead0597
fix build errors, a few more last cleanups
mitchute Jan 9, 2026
5b047b8
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into cod…
dareumnam Jan 13, 2026
ece10e4
suppress other warnings for now
mitchute Jan 14, 2026
b773b2c
final touchups
mitchute Jan 14, 2026
067da92
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into cod…
dareumnam Jan 20, 2026
377391c
fix diffs
mitchute Jan 21, 2026
f539a4e
fix diffs
mitchute Jan 21, 2026
3cf34c7
Merge branch 'develop' into code-integrity
mitchute Jan 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions .github/workflows/test_code_integrity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,37 @@ jobs:
--suppress=unusedFunction:src/EnergyPlus/api/state.cc
--suppress=unusedFunction:src/EnergyPlus/Psychrometrics.cc
--enable=all
-i EnergyPlus/DXCoils.cc
-i EnergyPlus/RefrigeratedCase.cc
-i EnergyPlus/SolarShading.cc
Comment on lines -216 to -218
Copy link
Collaborator Author

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.

-j $(nproc)
--template='[{file}:{line}]:({severity}),[{id}],{message}'
--suppress="uninitvar:*"
--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:*" \
Comment on lines +218 to +246
Copy link
Collaborator Author

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.

./src
3>&1 1>&2 2>&3 | tee cppcheck.txt

Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/AirflowNetwork/src/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,6 @@ namespace AirflowNetwork {
int count;
bool NodeFound;
bool found;
int NumAPL;
Array1D_string CompName(2);
std::string SimAirNetworkKey;

Expand Down Expand Up @@ -2030,6 +2029,7 @@ namespace AirflowNetwork {

// Check the number of primary air loops
if (!simulation_control.DuctLoss) {
int NumAPL;
if (distribution_simulated) {
NumAPL = m_state.dataInputProcessing->inputProcessor->getNumObjectsFound(m_state, "AirLoopHVAC");
if (NumAPL > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/Autosizing/Base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -775,10 +775,10 @@ void BaseSizer::calcCoilWaterFlowRates(EnergyPlusData &state,
}
}
auto &plntComps = state.dataPlnt->PlantLoop(loopNum).plantCoilObjectNames;
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;
Comment on lines -778 to +781
Copy link
Collaborator Author

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.

for (size_t i = 0; i < plntComps.size(); ++i) {
if (plntComps[i] == compName &&
cmpType[i] == static_cast<DataPlant::PlantEquipmentType>(getEnumValue(DataPlant::PlantEquipTypeNames, compType))) {
Expand Down
4 changes: 1 addition & 3 deletions src/EnergyPlus/BaseboardElectric.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ namespace BaseboardElectric {
int constexpr iHeatFracOfAutosizedCapacityNumericNum(
3); // get input index to baseboard heating capacity sizing as fraction of autosized heating capacity

auto &s_ipsc = state.dataIPShortCut;

auto &baseboard = state.dataBaseboardElectric;
std::string_view cCurrentModuleObject = cCMO_BBRadiator_Electric;

Expand All @@ -190,8 +188,8 @@ namespace BaseboardElectric {
int NumNums = 0;
int IOStat = 0;
int BaseboardNum = 0;
auto &s_ipsc = state.dataIPShortCut;
for (int ConvElecBBNum = 1; ConvElecBBNum <= NumConvElecBaseboards; ++ConvElecBBNum) {

state.dataInputProcessing->inputProcessor->getObjectItem(state,
cCurrentModuleObject,
ConvElecBBNum,
Expand Down
4 changes: 3 additions & 1 deletion src/EnergyPlus/Construction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,9 @@ void ConstructionProps::calculateExponentialMatrix()

// Note With change to row-major arrays "row" here now means "column"

AMatRowNormMax = 0.0; // Start of Step 1 ...
// Start of Step 1 ...
// set to tiny value to avoid log(0) below
AMatRowNormMax = 1e-12;
Comment on lines +1193 to +1195
Copy link
Collaborator Author

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.


for (i = 1; i <= this->rcmax; ++i) {

Expand Down
85 changes: 35 additions & 50 deletions src/EnergyPlus/DXCoils.cc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/EnergyPlus/DataHeatBalance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ int AssignReverseConstructionNumber(EnergyPlusData &state,
// METHODOLOGY EMPLOYED:
// Create reverse layers. Look in current constructions to see if match. If no match, create a new one.

auto &s_mat = state.dataMaterial;
// Return value
int NewConstrNum; // Reverse Construction Number

Expand Down Expand Up @@ -861,6 +860,7 @@ int AssignReverseConstructionNumber(EnergyPlusData &state,
// replace others...
state.dataConstruction->Construct(state.dataHeatBal->TotConstructs).Name = "iz-" + state.dataConstruction->Construct(ConstrNum).Name;
state.dataConstruction->Construct(state.dataHeatBal->TotConstructs).TotLayers = state.dataConstruction->Construct(ConstrNum).TotLayers;
auto &s_mat = state.dataMaterial;
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) {
Expand Down
17 changes: 9 additions & 8 deletions src/EnergyPlus/DataSurfaces.hh
Original file line number Diff line number Diff line change
Expand Up @@ -829,14 +829,15 @@ namespace DataSurfaces {

// Default Constructor
SurfaceData()
: Construction(0), RepresentativeCalcSurfNum(-1), ConstructionStoredInputValue(0), Class(SurfaceClass::None), Shape(SurfaceShape::None),
Sides(0), Area(0.0), GrossArea(0.0), NetAreaShadowCalc(0.0), Perimeter(0.0), Azimuth(0.0), Height(0.0), Reveal(0.0), Tilt(0.0),
Width(0.0), shapeCat(ShapeCat::Invalid), plane(0.0, 0.0, 0.0, 0.0), Centroid(0.0, 0.0, 0.0), lcsx(0.0, 0.0, 0.0), lcsy(0.0, 0.0, 0.0),
lcsz(0.0, 0.0, 0.0), NewellAreaVector(0.0, 0.0, 0.0), NewellSurfaceNormalVector(0.0, 0.0, 0.0), OutNormVec(0.0, 0.0, 0.0), SinAzim(0.0),
CosAzim(0.0), SinTilt(0.0), CosTilt(0.0), IsConvex(true), IsDegenerate(false), VerticesProcessed(false), XShift(0.0), YShift(0.0),
HeatTransSurf(false), HeatTransferAlgorithm(HeatTransferModel::Invalid), BaseSurf(0), NumSubSurfaces(0), Zone(0), spaceNum(0),
ExtBoundCond(0), ExtSolar(false), ExtWind(false), hasIncSolMultiplier(false), IncSolMultiplier(1.0), ViewFactorGround(0.0),
ViewFactorSky(0.0), ViewFactorGroundIR(0.0), ViewFactorSkyIR(0.0), OSCPtr(0), OSCMPtr(0), MirroredSurf(false), IsShadowing(false),
: Construction(0), RepresentativeCalcSurfNum(-1), ConstructionStoredInputValue(0), Class(SurfaceClass::None), OriginalClass(),
Shape(SurfaceShape::None), Sides(0), Area(0.0), GrossArea(0.0), NetAreaShadowCalc(0.0), Perimeter(0.0), Azimuth(0.0), Height(0.0),
Reveal(0.0), Tilt(0.0), Width(0.0), shapeCat(ShapeCat::Invalid), plane(0.0, 0.0, 0.0, 0.0), Centroid(0.0, 0.0, 0.0),
lcsx(0.0, 0.0, 0.0), lcsy(0.0, 0.0, 0.0), lcsz(0.0, 0.0, 0.0), NewellAreaVector(0.0, 0.0, 0.0),
NewellSurfaceNormalVector(0.0, 0.0, 0.0), OutNormVec(0.0, 0.0, 0.0), SinAzim(0.0), CosAzim(0.0), SinTilt(0.0), CosTilt(0.0),
IsConvex(true), IsDegenerate(false), VerticesProcessed(false), XShift(0.0), YShift(0.0), HeatTransSurf(false),
HeatTransferAlgorithm(HeatTransferModel::Invalid), BaseSurf(0), NumSubSurfaces(0), Zone(0), spaceNum(0), ExtBoundCond(0),
ExtSolar(false), ExtWind(false), hasIncSolMultiplier(false), IncSolMultiplier(1.0), ViewFactorGround(0.0), ViewFactorSky(0.0),
ViewFactorGroundIR(0.0), ViewFactorSkyIR(0.0), OSCPtr(0), OSCMPtr(0), MirroredSurf(false), IsShadowing(false),
IsShadowPossibleObstruction(false), IsTransparent(false), SchedMinValue(0.0), activeWindowShadingControl(0), HasShadeControl(false),
activeShadedConstruction(0), activeShadedConstructionPrev(0), FrameDivider(0), Multiplier(1.0), SolarEnclIndex(0),
SolarEnclSurfIndex(0), IsAirBoundarySurf(false), IsSurfPropertyGndSurfacesDefined(false), SurfPropertyGndSurfIndex(0),
Expand Down
5 changes: 2 additions & 3 deletions src/EnergyPlus/DemandManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ void GetDemandManagerListInput(EnergyPlusData &state)
static constexpr std::string_view routineName = "GetDemandManagerListInput";
constexpr std::string_view cCurrentModuleObject = "DemandManagerAssignmentList";

auto &s_ipsc = state.dataIPShortCut;
auto const &s_ip = state.dataInputProcessing->inputProcessor;

state.dataDemandManager->NumDemandManagerList = s_ip->getNumObjectsFound(state, cCurrentModuleObject);
Expand All @@ -326,13 +325,13 @@ void GetDemandManagerListInput(EnergyPlusData &state)
int NumNums; // Number of elements in the numeric array
int IOStat; // IO Status when calling get input subroutine
bool ErrorsFound = false;
auto &s_ipsc = state.dataIPShortCut;

state.dataDemandManager->DemandManagerList.allocate(state.dataDemandManager->NumDemandManagerList);

for (int ListNum = 1; ListNum <= state.dataDemandManager->NumDemandManagerList; ++ListNum) {

auto &thisDemandMgrList = state.dataDemandManager->DemandManagerList(ListNum);

s_ip->getObjectItem(state,
cCurrentModuleObject,
ListNum,
Expand Down Expand Up @@ -544,7 +543,6 @@ void GetDemandManagerInput(EnergyPlusData &state)

static constexpr std::string_view routineName = "GetDemandManagerInput";

auto &s_ipsc = state.dataIPShortCut;
auto const &s_ip = state.dataInputProcessing->inputProcessor;

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
Expand Down Expand Up @@ -602,6 +600,7 @@ void GetDemandManagerInput(EnergyPlusData &state)
AlphArray.dimension(MaxAlphas, std::string());
NumArray.dimension(MaxNums, 0.0);
int IOStat; // IO Status when calling get input subroutine
auto &s_ipsc = state.dataIPShortCut;

DemandMgr.allocate(state.dataDemandManager->NumDemandMgr);
state.dataDemandManager->UniqueDemandMgrNames.reserve(state.dataDemandManager->NumDemandMgr);
Expand Down
12 changes: 3 additions & 9 deletions src/EnergyPlus/DuctLoss.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ namespace DuctLoss {

auto instances = state.dataInputProcessing->inputProcessor->epJSON.find(CurrentModuleObject);
if (instances != state.dataInputProcessing->inputProcessor->epJSON.end()) {
std::string cFieldName;
int DuctLossCondNum = 0;
auto &instancesValue = instances.value();
for (auto instance = instancesValue.begin(); instance != instancesValue.end(); ++instance) {
Expand Down Expand Up @@ -291,7 +290,6 @@ namespace DuctLoss {

instances = state.dataInputProcessing->inputProcessor->epJSON.find(CurrentModuleObject);
if (instances != state.dataInputProcessing->inputProcessor->epJSON.end()) {
std::string cFieldName;
int DuctLossLeakNum = 0;
auto &instancesValue = instances.value();
for (auto instance = instancesValue.begin(); instance != instancesValue.end(); ++instance) {
Expand Down Expand Up @@ -328,7 +326,6 @@ namespace DuctLoss {

instances = state.dataInputProcessing->inputProcessor->epJSON.find(CurrentModuleObject);
if (instances != state.dataInputProcessing->inputProcessor->epJSON.end()) {
std::string cFieldName;
int DuctLossMakeNum = 0;
auto &instancesValue = instances.value();
for (auto instance = instancesValue.begin(); instance != instancesValue.end(); ++instance) {
Expand Down Expand Up @@ -597,7 +594,6 @@ namespace DuctLoss {
Real64 CpAir;
int NodeNum1;
int NodeNum2;
int NodeNum;
NodeNum1 = state.afn->AirflowNetworkLinkageData(this->LinkageNum).NodeNums[0];
NodeNum2 = state.afn->AirflowNetworkLinkageData(this->LinkageNum).NodeNums[1];

Expand Down Expand Up @@ -660,7 +656,7 @@ namespace DuctLoss {
state.afn->AirflowNetworkNodeSimu(NodeNum2).WZ = Wout;
} break;
case DuctLossSubType::RetLeakBranch: {
NodeNum = state.afn->DisSysNodeData(NodeNum2).EPlusNodeNum;
int NodeNum = state.afn->DisSysNodeData(NodeNum2).EPlusNodeNum;
MassFlowRate = state.dataLoopNodes->Node(NodeNum).MassFlowRate;
Tout = state.dataLoopNodes->Node(this->RetLeakZoneNum).Temp * (1.0 - LeakRatio) +
state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.afn->AirflowNetworkNodeData(NodeNum1).EPlusZoneNum).MAT * LeakRatio;
Expand Down Expand Up @@ -718,14 +714,12 @@ namespace DuctLoss {

void InitDuctLoss(EnergyPlusData &state)
{
bool errorsFound(false);
std::string CurrentModuleObject;

if (state.dataDuctLoss->AirLoopConnectionFlag) {
bool errorsFound(false);
std::string CurrentModuleObject;

for (int DuctLossNum = 1; DuctLossNum <= state.dataDuctLoss->NumOfDuctLosses; DuctLossNum++) {
auto &thisDuctLoss(state.dataDuctLoss->ductloss(DuctLossNum));

thisDuctLoss.AirLoopNum = Util::FindItemInList(thisDuctLoss.AirLoopName, state.dataAirSystemsData->PrimaryAirSystems);
if (thisDuctLoss.LossType == DuctLossType::Conduction) {
CurrentModuleObject = cCMO_DuctLossConduction;
Expand Down
44 changes: 15 additions & 29 deletions src/EnergyPlus/EconomicTariff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,6 @@ void warnIfNativeVarname(

// Issue a warning if the variable name (usually the object name) is
// one of the names of native variables
auto &s_econ = state.dataEconTariff;

bool throwError = false;
if (getEnumValue(nativeNamesUC, objName) != -1) {
Expand All @@ -1930,6 +1929,7 @@ void warnIfNativeVarname(
}

if (throwError) {
auto &s_econ = state.dataEconTariff;
ErrorsFound = true;
if (curTariffIndex >= 1 && curTariffIndex <= s_econ->numTariff) {
ShowSevereError(state, format("UtilityCost:Tariff=\"{}\" invalid referenced name", s_econ->tariff(curTariffIndex).tariffName));
Expand Down Expand Up @@ -1957,10 +1957,10 @@ int AssignVariablePt(EnergyPlusData &state,
// the variable using the string as its name.
// Return the index of the variable.

auto &s_econ = state.dataEconTariff;
int AssignVariablePt;

if (flagIfNotNumeric && (len(stringIn) >= 1)) {
auto &s_econ = state.dataEconTariff;
std::string inNoSpaces = RemoveSpaces(state, stringIn);
int found = 0;
if (allocated(s_econ->econVar)) {
Expand Down Expand Up @@ -2445,9 +2445,9 @@ void addOperand(EnergyPlusData &state, int const varMe, int const varOperand)
// relationship in the EconVar array

int constexpr sizeIncrement(100);
auto &s_econ = state.dataEconTariff;

if (varOperand != 0) {
auto &s_econ = state.dataEconTariff;
// increment the numOperand and allocate/reallocate the array
// if necessary
if (!allocated(s_econ->operands)) {
Expand Down Expand Up @@ -3864,11 +3864,10 @@ void LEEDtariffReporting(EnergyPlusData &state)
DemandWindow distHeatSteamDemWindowUnits;
DemandWindow othrDemWindowUnits;

auto &s_orp = state.dataOutRptPredefined;

auto &s_econ = state.dataEconTariff;

if (s_econ->numTariff > 0) {
auto &s_orp = state.dataOutRptPredefined;
int distCoolFacilMeter = GetMeterIndex(state, "DISTRICTCOOLING:FACILITY");
int distHeatWaterFacilMeter = GetMeterIndex(state, "DISTRICTHEATINGWATER:FACILITY");
int distHeatSteamFacilMeter = GetMeterIndex(state, "DISTRICTHEATINGSTEAM:FACILITY");
Expand Down Expand Up @@ -4085,8 +4084,6 @@ void WriteTabularTariffReports(EnergyPlusData &state)
}

if (s_econ->numTariff > 0) {
auto &econVar = s_econ->econVar;

if (state.dataOutRptTab->displayEconomicResultSummary) {
DisplayString(state, "Writing Tariff Reports");
showWarningsBasedOnTotal(state);
Expand Down Expand Up @@ -4252,6 +4249,7 @@ void WriteTabularTariffReports(EnergyPlusData &state)
// Tariff Report
//---------------------------------
if (state.dataOutRptTab->displayTariffReport) {
auto &econVar = s_econ->econVar;
for (auto &currentStyle : state.dataOutRptTab->tabularReportPasses) {
// Clear this for each style pass
for (auto &e : econVar) {
Expand Down Expand Up @@ -4541,23 +4539,15 @@ void ReportEconomicVariable(EnergyPlusData &state,
Array2D_string tableBody;
Real64 sumVal;
Real64 maximumVal;
Real64 curVal;
int curIndex;
int curCatPt;
int curCategory;

int iVar;
int jMonth;
int cntOfVar;
int nCntOfVar;
int curCatPt = 0;

auto const &s_econ = state.dataEconTariff;
auto const &econVar = s_econ->econVar;
auto const &chargeBlock = s_econ->chargeBlock;
auto const &chargeSimple = s_econ->chargeSimple;

cntOfVar = 0;
for (iVar = 1; iVar <= s_econ->numEconVar; ++iVar) {
int cntOfVar = 0;
for (int iVar = 1; iVar <= s_econ->numEconVar; ++iVar) {
if (econVar(iVar).activeNow) {
++cntOfVar;
}
Expand Down Expand Up @@ -4591,9 +4581,9 @@ void ReportEconomicVariable(EnergyPlusData &state,
if (includeCategory) {
columnHead(15) = "Category";
}
nCntOfVar = 0;
int nCntOfVar = 0;
// row names
for (iVar = 1; iVar <= s_econ->numEconVar; ++iVar) {
for (int iVar = 1; iVar <= s_econ->numEconVar; ++iVar) {
if (econVar(iVar).activeNow) {
++nCntOfVar;
if (showCurrencySymbol) {
Expand All @@ -4605,11 +4595,12 @@ void ReportEconomicVariable(EnergyPlusData &state,
}
// fill the body
nCntOfVar = 0;
for (iVar = 1; iVar <= s_econ->numEconVar; ++iVar) {
for (int iVar = 1; iVar <= s_econ->numEconVar; ++iVar) {
if (econVar(iVar).activeNow) {
++nCntOfVar;
for (jMonth = 1; jMonth <= 12; ++jMonth) { // note not all months get printed out if more than 12 are used.- need to fix this later
curVal = econVar(iVar).values(jMonth);
for (int jMonth = 1; jMonth <= 12; ++jMonth) {
// note not all months get printed out if more than 12 are used.- need to fix this later
const Real64 curVal = econVar(iVar).values(jMonth);
if ((curVal > 0) && (curVal < 1)) {
tableBody(jMonth, nCntOfVar) = OutputReportTabular::RealToStr(style.formatReals, curVal, 4);
} else {
Expand All @@ -4621,8 +4612,7 @@ void ReportEconomicVariable(EnergyPlusData &state,
tableBody(14, nCntOfVar) = OutputReportTabular::RealToStr(style.formatReals, maximumVal, 2);
if (includeCategory) {
// first find category
curCategory = 0;
curIndex = econVar(iVar).index;
const int curIndex = econVar(iVar).index;

switch (econVar(iVar).kindOfObj) {
case ObjType::ChargeSimple:
Expand All @@ -4639,10 +4629,6 @@ void ReportEconomicVariable(EnergyPlusData &state,
break;
}

if ((curCatPt >= 1) && (curCatPt <= s_econ->numEconVar)) {
curCategory = econVar(curCatPt).specific;
}

// In this specific table, "NotIncluded" is written as "none" so need a special case for that
tableBody(15, nCntOfVar) =
(econVar(curCatPt).kindOfObj == ObjType::Category)
Expand Down
Loading