-
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 WindowManager #10836
base: develop
Are you sure you want to change the base?
CppCheck WindowManager #10836
Changes from 22 commits
d6ac95b
e25bb12
f572379
29389f5
d12b3b2
aee0843
bd3b594
67c733d
ab34c27
e10d04f
c3bacc7
9873f78
41aad69
e326fc4
74b8e82
4693caf
a875a81
107c7b4
ef9c0f1
172f09c
52f4ce2
939ac42
bc5c096
c053711
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2983,12 +2983,14 @@ namespace UnitarySystems { | |
if (this->m_CoolCoilExists && this->m_MaxCoolAirVolFlow < 0.0) { | ||
if (!state.dataSize->SysSizingRunDone) { | ||
int BranchNum = BranchInputManager::GetAirBranchIndex(state, "AirloopHVAC:UnitarySystem", this->Name); | ||
std::string FanType = ""; | ||
std::string m_FanName = ""; // the notation m_ implies member variables, and this is a local | ||
BranchFanFlow = 0.0; | ||
if (BranchNum > 0.0) BranchInputManager::GetBranchFanTypeName(state, BranchNum, FanType, m_FanName, ErrFound); | ||
if (!ErrFound && BranchNum > 0) { | ||
BranchFanFlow = state.dataFans->fans(this->m_FanIndex)->maxAirFlowRate; | ||
if (BranchNum > 0.0) { | ||
std::string FanType = ""; | ||
std::string FanName = ""; | ||
BranchInputManager::GetBranchFanTypeName(state, BranchNum, FanType, FanName, ErrFound); | ||
if (!ErrFound) { | ||
BranchFanFlow = state.dataFans->fans(this->m_FanIndex)->maxAirFlowRate; | ||
} | ||
} | ||
if (BranchFanFlow > 0.0) { | ||
this->m_MaxCoolAirVolFlow = BranchFanFlow; | ||
|
@@ -6618,10 +6620,7 @@ namespace UnitarySystems { | |
this->m_MSHeatingSpeedRatio[i] = 1.0; | ||
} | ||
if (this->m_HeatingCoilType_Num == HVAC::Coil_HeatingWaterToAirHPVSEquationFit) { | ||
std::string MultispeedType = "UnitarySystemPerformance:Multispeed"; | ||
if (this->m_DesignSpecMSHPIndex == -1) { | ||
std::string MultispeedType = "Fan:SystemModel"; | ||
} | ||
std::string MultispeedType = (this->m_DesignSpecMSHPIndex == -1) ? "Fan:SystemModel" : "UnitarySystemPerformance:Multispeed"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [src/EnergyPlus/UnitarySystem.cc:6621]:(style),[variableScope],The scope of the variable 'MultispeedType' can be reduced. |
||
int NumOfSpeed = VariableSpeedCoils::GetVSCoilNumOfSpeeds(state, this->m_HeatingCoilName, errorsFound); | ||
if (errorsFound) { | ||
ShowSevereError(state, | ||
|
@@ -6664,10 +6663,7 @@ namespace UnitarySystems { | |
this->m_MSCoolingSpeedRatio[i] = 1.0; | ||
} | ||
if (this->m_CoolingCoilType_Num == HVAC::Coil_CoolingWaterToAirHPVSEquationFit) { | ||
std::string MultispeedType = "UnitarySystemPerformance:Multispeed"; | ||
if (this->m_DesignSpecMSHPIndex == -1) { | ||
std::string MultispeedType = "Fan:SystemModel"; | ||
} | ||
std::string MultispeedType = (this->m_DesignSpecMSHPIndex == -1) ? "Fan:SystemModel" : "UnitarySystemPerformance:Multispeed"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [src/EnergyPlus/UnitarySystem.cc:6667]:(style),[variableScope],The scope of the variable 'MultispeedType' can be reduced. |
||
int NumOfSpeed = VariableSpeedCoils::GetVSCoilNumOfSpeeds(state, this->m_CoolingCoilName, errorsFound); | ||
if (errorsFound) { | ||
ShowSevereError(state, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,6 @@ namespace UserDefinedComponents { | |
|
||
void UserPlantComponentStruct::onInitLoopEquip(EnergyPlusData &state, const PlantLocation &calledFromLocation) | ||
{ | ||
bool anyEMSRan; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [src/EnergyPlus/UserDefinedComponents.cc:117]:(style),[variableScope],The scope of the variable 'anyEMSRan' can be reduced. |
||
Real64 myLoad = 0.0; | ||
int thisLoop = 0; | ||
|
||
|
@@ -128,6 +127,7 @@ namespace UserDefinedComponents { | |
|
||
if (thisLoop > 0) { | ||
if (this->Loop(thisLoop).ErlInitProgramMngr > 0) { | ||
bool anyEMSRan; | ||
EMSManager::ManageEMS(state, EMSManager::EMSCallFrom::UserDefinedComponentModel, anyEMSRan, this->Loop(thisLoop).ErlInitProgramMngr); | ||
} else if (this->Loop(thisLoop).initPluginLocation > -1) { | ||
state.dataPluginManager->pluginManager->runSingleUserDefinedPlugin(state, this->Loop(thisLoop).initPluginLocation); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,8 +110,7 @@ Real64 AreaPolygon(int const n, Array1D<Vector> &p) | |
{ | ||
|
||
// PURPOSE OF THIS SUBROUTINE: | ||
// This subroutine calculates the area of a polygon defined by the | ||
// input vectors. | ||
// This subroutine calculates the area of a polygon defined by the input vectors. | ||
|
||
// REFERENCE: | ||
// Graphic Gems. | ||
|
@@ -189,8 +188,7 @@ Vector VecNormalize(Vector const &vec) | |
{ | ||
|
||
// PURPOSE OF THIS SUBROUTINE: | ||
// This subroutine normalizes the input vector and returns the normalized | ||
// vector | ||
// This subroutine normalizes the input vector and returns the normalized vector | ||
|
||
// REFERENCE: | ||
// Graphic Gems. | ||
|
@@ -295,8 +293,7 @@ void PlaneEquation(Array1D<Vector> &verts, // Structure of the surface | |
{ | ||
|
||
// PURPOSE OF THIS SUBROUTINE: | ||
// This subroutine calculates the plane equation for a given | ||
// surface (which should be planar). | ||
// This subroutine calculates the plane equation for a given surface (which should be planar). | ||
|
||
// REFERENCE: | ||
// Graphic Gems | ||
|
@@ -336,9 +333,7 @@ Real64 Pt2Plane(Vector const &pt, // Point for determining the distance | |
{ | ||
|
||
// PURPOSE OF THIS SUBROUTINE: | ||
// This subroutine calculates the distance from a point | ||
// to the plane (of a surface). Used to determine the reveal | ||
// of a heat transfer subsurface. | ||
// This subroutine calculates the distance from a point to the plane (of a surface). Used to determine the reveal of a heat transfer subsurface. | ||
|
||
// REFERENCE: | ||
// Graphic Gems | ||
|
@@ -358,8 +353,7 @@ void CreateNewellAreaVector(Array1D<Vector> const &VList, int const NSides, Vect | |
// DATE WRITTEN May 2004 | ||
|
||
// PURPOSE OF THIS SUBROUTINE: | ||
// This subroutine creates a "Newell" vector from the vector list for a surface | ||
// face. Also the Newell Area vector. | ||
// This subroutine creates a "Newell" vector from the vector list for a surface face. Also the Newell Area vector. | ||
|
||
// REFERENCES: | ||
// Collaboration with Bill Carroll, LBNL. | ||
|
@@ -384,8 +378,7 @@ void CreateNewellSurfaceNormalVector(Array1D<Vector> const &VList, int const NSi | |
// DATE WRITTEN Jan 2011 | ||
|
||
// PURPOSE OF THIS SUBROUTINE: | ||
// This subroutine creates a "Newell" surface normal vector from the vector list | ||
// for a surface face. | ||
// This subroutine creates a "Newell" surface normal vector from the vector list for a surface face. | ||
|
||
// REFERENCES: | ||
// September 2010: from OpenGL.org | ||
|
@@ -401,14 +394,10 @@ void CreateNewellSurfaceNormalVector(Array1D<Vector> const &VList, int const NSi | |
// Returning Normalize(Normal) | ||
// End Function | ||
|
||
Real64 xvalue; | ||
Real64 yvalue; | ||
Real64 zvalue; | ||
|
||
OutNewellSurfaceNormalVector = 0.0; | ||
xvalue = 0.0; | ||
yvalue = 0.0; | ||
zvalue = 0.0; | ||
Real64 xvalue = 0.0; | ||
Real64 yvalue = 0.0; | ||
Real64 zvalue = 0.0; | ||
|
||
// IF (NSides > 3) THEN | ||
for (int Side = 1; Side <= NSides; ++Side) { | ||
|
@@ -438,8 +427,7 @@ void CompareTwoVectors(Vector const &vector1, // standard vector | |
// DATE WRITTEN February 2012 | ||
|
||
// PURPOSE OF THIS SUBROUTINE: | ||
// This routine will provide the ability to compare two vectors (e.g. surface normals) | ||
// to be the same within a specified tolerance. | ||
// This routine will provide the ability to compare two vectors (e.g. surface normals) to be the same within a specified tolerance. | ||
|
||
// METHODOLOGY EMPLOYED: | ||
// compare each element (x,y,z) | ||
|
@@ -458,8 +446,7 @@ void CalcCoPlanarNess(Array1D<Vector> &Surf, int const NSides, bool &IsCoPlanar, | |
// DATE WRITTEN June 2004 | ||
|
||
// PURPOSE OF THIS SUBROUTINE: | ||
// This subroutine provides the calculation to determine if the | ||
// surface is planar or not. | ||
// This subroutine provides the calculation to determine if the surface is planar or not. | ||
|
||
// REFERENCES: | ||
// Eric W. Weisstein. "Coplanar." From MathWorld--A Wolfram Web Resource. | ||
|
@@ -489,7 +476,8 @@ void CalcCoPlanarNess(Array1D<Vector> &Surf, int const NSides, bool &IsCoPlanar, | |
if (std::abs(MaxDist) > Constant::SmallDistance) IsCoPlanar = false; | ||
} | ||
|
||
std::vector<int> PointsInPlane(Array1D<Vector> &BaseSurf, int const BaseSides, Array1D<Vector> &QuerySurf, int const QuerySides, bool &ErrorFound) | ||
std::vector<int> | ||
PointsInPlane(Array1D<Vector> &BaseSurf, int const BaseSides, Array1D<Vector> const &QuerySurf, int const QuerySides, bool &ErrorFound) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [src/EnergyPlus/Vectors.cc:492]:(style),[constParameterReference],Parameter 'QuerySurf' can be declared as reference to const |
||
{ | ||
std::vector<int> pointIndices; | ||
|
||
|
@@ -505,31 +493,27 @@ std::vector<int> PointsInPlane(Array1D<Vector> &BaseSurf, int const BaseSides, A | |
return pointIndices; | ||
} | ||
|
||
Real64 CalcPolyhedronVolume(EnergyPlusData &state, Polyhedron const &Poly) | ||
Real64 CalcPolyhedronVolume(EnergyPlusData const &state, Polyhedron const &Poly) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [src/EnergyPlus/Vectors.cc:508]:(style),[constParameterReference],Parameter 'state' can be declared as reference to const |
||
{ | ||
|
||
// SUBROUTINE INFORMATION: | ||
// AUTHOR Linda Lawrie | ||
// DATE WRITTEN June 2004 | ||
|
||
// PURPOSE OF THIS SUBROUTINE: | ||
// This subroutine provides the volume calculation for a polyhedron | ||
// (i.e. Zone). | ||
// This subroutine provides the volume calculation for a polyhedron (i.e. Zone). | ||
|
||
// REFERENCES: | ||
// Conversations with Bill Carroll, LBNL. | ||
|
||
// SUBROUTINE LOCAL VARIABLE DECLARATIONS: | ||
Real64 PyramidVolume; | ||
|
||
// Object Data | ||
Vector p3FaceOrigin; | ||
|
||
Real64 Volume = 0.0; | ||
|
||
for (int NFace = 1; NFace <= Poly.NumSurfaceFaces; ++NFace) { | ||
p3FaceOrigin = Poly.SurfaceFace(NFace).FacePoints(2); | ||
PyramidVolume = dot(Poly.SurfaceFace(NFace).NewellAreaVector, (p3FaceOrigin - state.dataVectors->p0)); | ||
Real64 PyramidVolume = dot(Poly.SurfaceFace(NFace).NewellAreaVector, (p3FaceOrigin - state.dataVectors->p0)); | ||
Volume += PyramidVolume / 3.0; | ||
} | ||
return Volume; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,7 +278,6 @@ namespace WaterUse { | |
int IOStatus; // Used in GetObjectItem | ||
int NumAlphas; // Number of Alphas for each GetObjectItem call | ||
int NumNumbers; // Number of Numbers for each GetObjectItem call | ||
int AlphaNum; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [src/EnergyPlus/WaterUse.cc:281]:(style),[variableScope],The scope of the variable 'AlphaNum' can be reduced. |
||
|
||
constexpr std::array<std::string_view, static_cast<int>(HeatRecovHX::Num)> HeatRecoverHXNamesUC{"IDEAL", "COUNTERFLOW", "CROSSFLOW"}; | ||
|
||
|
@@ -525,7 +524,7 @@ namespace WaterUse { | |
|
||
waterConnection.myWaterEquipArr.allocate(NumAlphas - 9); | ||
|
||
for (AlphaNum = 10; AlphaNum <= NumAlphas; ++AlphaNum) { | ||
for (int AlphaNum = 10; AlphaNum <= NumAlphas; ++AlphaNum) { | ||
int WaterEquipNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(AlphaNum), state.dataWaterUse->WaterEquipment); | ||
|
||
if (WaterEquipNum == 0) { | ||
|
@@ -1658,7 +1657,7 @@ namespace WaterUse { | |
// PURPOSE OF THIS SUBROUTINE: | ||
// Calculates the zone internal gains due to water use sensible and latent loads. | ||
|
||
bool MyEnvrnFlagLocal(true); | ||
static bool MyEnvrnFlagLocal = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [src/EnergyPlus/WaterUse.cc:1665]:(style),[knownConditionTrueFalse],Condition 'MyEnvrnFlagLocal' is always true |
||
|
||
if (state.dataWaterUse->numWaterEquipment == 0) return; | ||
|
||
|
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/UnitarySystem.cc:2986]:(style),[variableScope],The scope of the variable 'FanType' can be reduced.
[src/EnergyPlus/UnitarySystem.cc:2987]:(style),[variableScope],The scope of the variable 'm_FanName' can be reduced.