Conversation
…into cppCheck_redundantAssignment
…into cppCheck_redundantAssignment
| } else { | ||
| S1PLR = 0.0; | ||
| } | ||
|
|
There was a problem hiding this comment.
S1PLR gets set right after the stage-1 full-load calc, but that value is never used before S1PLR is recomputed in the “Determine run-time fractions” block, line 545 - 550 (develop). We can just drop the first S1PLR = PartLoadRatio or 0.0 assignment (no behavior change, since it was overwritten before use).
|
|
||
| // Stage 1 | ||
| } else if (CycRatio > 0.0 || (CycRatio > 0.0 && SingleMode == 1)) { | ||
| } else if (CycRatio > 0.0 || (CycRatio > 0.0 && SingleMode == 1)) { // cppCheck Redundant Condition flag |
There was a problem hiding this comment.
If the intent was to include SingleMode in the logic, this might need to be CycRatio > 0.0 || SingleMode == 1 or CycRatio > 0.0 && SingleMode == 1; otherwise it can be simplified to CycRatio > 0.0.
There was a problem hiding this comment.
SingleMode (1 = Yes, 0 = No) does operate just like a cycling coil except that at speeds > 1 the cycling is between capacity at speed = x and off. There are other logic conditionals like this in code and I think testing would be required to know for sure but your suggestion of CycRatio > 0.0 may be correct since line 14070 says "Stage 1" and at stage 1 it wouldn't matter what SingleMode was.
if (SpeedNum > 1 && SingleMode == 0) {
} else if (CycRatio > 0.0) {
There was a problem hiding this comment.
@rraustad Thanks for your input and for confirming the fix.
| lineIn = statFile.readLine(); | ||
| } | ||
| lineIn = statFile.readLine(); | ||
| lineAvg = lineIn.data; |
There was a problem hiding this comment.
The last lineIn = readLine() inside the 7-line skip loop is immediately overwritten by the next readLine() before it’s ever used. Easiest fix is to discard the skipped lines without assigning to lineIn, then read the actual avg line once into lineAvg.
| } | ||
|
|
||
| // no unshaded run for now | ||
| NeedUnshadedRun = false; |
There was a problem hiding this comment.
NeedUnshadedRun is possibly set true a few lines before, but then immediately forced to false before it’s ever used, so the earlier assignments are dead. Either drop the unconditional NeedUnshadedRun = false; (to keep the logic), or remove the previous NeedUnshadedRun = true lines would be the fix. As the comment said "no unshaded run for now", I left NeedUnshadedRun = false and erased two NeedUnshadedRun = true lines.
…into cppCheck_redundantAssignment
| // Get Water System tank connections | ||
| // A8, \field Name of Water Storage Tank for Supply | ||
| cFieldName = "Supply Water Storage Tank Name"; // cAlphaFields(8) | ||
| // cFieldName = "Supply Water Storage Tank Name"; // cAlphaFields(8) |
There was a problem hiding this comment.
I avoided re-declaring cFieldName in inner scopes (like in the previous commit) since that caused a mac build issue. Instead, I commented out the two cFieldName assignments that were never used before being overwritten.
There was a problem hiding this comment.
Agreed. This is fine to leave like this for reference.
src/EnergyPlus/WeatherManager.cc
Outdated
| lineIn = statFile.readLine(); | ||
| lineAvg = lineIn.data; | ||
| auto lineAvgIn = statFile.readLine(); | ||
| lineAvg = lineAvgIn.data; |
There was a problem hiding this comment.
The last lineIn = statFile.readLine(); inside the 7-line skip loop is immediately overwritten by the next readLine() before it’s ever used. Easiest fix is to discard the skipped lines without assigning to lineIn, then read the actual avg line once into lineAvg.
There was a problem hiding this comment.
I believe the intent of this was just to cycle through until they have read enough lines to get to the one they do want. I'll push a tiny cleanup here.
|
|
||
| cFieldName = "Condenser Type"; // cAlphaFields(6) | ||
| std::string const condenserType = s_ip->getAlphaFieldValue(fields, schemaProps, "condenser_type"); | ||
| if ((Util::SameString(condenserType, "AirCooled")) || cFieldName.empty()) { |
There was a problem hiding this comment.
I also spotted what looks like a bug in this line:
|| cFieldName.empty() in the Condenser Type check probably meant condenserType.empty() I guess, as cFieldName has always have a value due to line 842 (2 lines above).
There was a problem hiding this comment.
Yes, this does look like a bug. Feel free to submit an issue and PR separately.
| // get current total capacity, SHR, EIR | ||
| if (SpeedRatio >= 1.0) { | ||
| TotCap = TotCapHS; | ||
| SHR = SHRHS; |
There was a problem hiding this comment.
Cppcheck is flagging SHR here because it gets assigned in the SpeedRatio >= 1.0 path, then reassigned again later in the UserSHRCurveExists block before the earlier value is actually used. This looks more like a redundant intermediate assignment than a functional issue.
In if (thisDXCoil.UserSHRCurveExists) - else block (line 11817 in this branch), SHR is assigned on all paths, so the warning is about this SHR assignment here being overwritten before use.
…into cppCheck_redundantAssignment
Pull request overview
Description of the purpose of this PR
Pull Request Author
Reviewer