Skip to content

Commit 4d3a8d6

Browse files
committed
Merge remote-tracking branch 'origin/develop' into FixDebugTests
2 parents 59769b7 + c94e83c commit 4d3a8d6

309 files changed

Lines changed: 19542 additions & 7785 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,3 +528,6 @@ fec99239575da7f77999cf82f4140f38a8026b80
528528
# [chore] Typo cooing -> cooling [Julien Marrec, 2025-01-23]
529529
ab5c96312d0cddec395e9616f23a8bd5f433ac6e
530530
# 25 files changed, 132 insertions(+), 131 deletions(-)
531+
532+
# Apply clang-format-19 and clang-tidy --checks=-*,readability-braces-around-statements [Julien Marrec, 2025-05-23]
533+
9985a5f1a0f9e6fbb59033996f2d17f2a8eaf6fb

.github/workflows/test_code_integrity.yml

Lines changed: 132 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,141 @@ jobs:
1212
runs-on: ubuntu-24.04
1313
steps:
1414
- uses: actions/checkout@v4
15-
16-
- name: Run clang-format style check for C/C++ source code.
17-
uses: jidicula/clang-format-action@v4.15.0
18-
if: always()
1915
with:
20-
clang-format-version: '10'
21-
check-path: 'src/EnergyPlus'
16+
fetch-depth: 2
2217

23-
- name: Run clang-format style check for C/C++ unit test code.
24-
uses: jidicula/clang-format-action@v4.15.0
25-
if: always()
18+
- name: Install clang-format-19
19+
shell: bash
20+
run: |
21+
# 14s to install from apt, getting 19.1.1
22+
# Getting it from LLVM takes 1min13s
23+
# sudo apt-get update && apt-get install -y wget gnupg lsb-release software-properties-common
24+
# wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
25+
# echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-19 main" | sudo tee /etc/apt/sources.list.d/llvm.list
26+
sudo apt-get update -qq
27+
sudo apt-get install -y -q clang-format-19
28+
clang-format-19 --version
29+
30+
- name: Run clang-format against C++ files touched by the PR
31+
if: ${{ github.event_name == 'pull_request' }}
32+
shell: bash
33+
run: |
34+
clang-format-19 --version
35+
begin_group() { echo -e "::group::\033[93m$1\033[0m"; }
36+
37+
begin_group "Find changed files"
38+
echo "GITHUB_REF=$GITHUB_REF GITHUB_BASE_REF=$GITHUB_BASE_REF GITHUB_HEAD_REF=$GITHUB_HEAD_REF"
39+
# too slow on E+: git fetch --all --quiet
40+
# first find if any files changed
41+
# HEAD^ works in PRs because actions/checkout checks out a merge commit by default in PR contexts
42+
# and I specified a fetch-depth of 2
43+
changed_files=$(git diff --name-only HEAD^ HEAD src/ tst/ | /bin/grep -E '\.(cpp|cc|c|hpp|hh|h)$')
44+
file_count=$(echo "$changed_files" | wc -l)
45+
if [ $file_count -eq 0 ]; then
46+
echo "No files of type (cpp, c, hpp, h) changed. Skipping clang-formatting"
47+
exit 0
48+
else
49+
begin_group "Found $file_count C/C++ changed files"
50+
echo "$changed_files"
51+
echo "::endgroup::"
52+
fi
53+
echo "::endgroup::"
54+
55+
begin_group "Run clang-format for changes files"
56+
# Using \0 as a terminator in case we'd ever have files with spaces
57+
git diff -z --name-only HEAD^ HEAD src/ tst/ \
58+
| /bin/grep -z -E '\.(cpp|cc|c|hpp|hh|h)$' \
59+
| xargs -0 -P "$(nproc)" -n 1 clang-format-19 -style=file -i -fallback-style=none --verbose
60+
61+
# clang-format will auto correct files so prepare the diff and use this as artifact
62+
git diff > clang_format.patch
63+
echo "::endgroup::"
64+
65+
# Delete if nothhing otherwise exit 1 to indicate a failed job
66+
if [ ! -s clang_format.patch ]; then
67+
rm clang_format.patch
68+
exit 0
69+
else
70+
incorrect_count=$(git diff --name-only | wc -l)
71+
incorrect_percent=$(awk "BEGIN { printf \"%.2f\", ($incorrect_count/$file_count)*100 }")
72+
begin_group "clang-format auto corrected $incorrect_count files:"
73+
git diff --name-only
74+
echo "::endgroup::"
75+
echo "::error title=Clang Format Check Failed::Formatting issues detected in $incorrect_count files"
76+
echo -e "\nPlease correct these files by running clang-format-19 locally, or download the artifact "
77+
echo 'and run `patch -p1 < /path/to/clang_format.patch`'
78+
{
79+
echo "| Item | Value |"
80+
echo "|---------------------------------------|-----------|"
81+
echo "| Number of Files Analyzed | $file_count |"
82+
echo "| Number of Files Incorrectly Formatted | $incorrect_count |"
83+
echo "| % Files Incorrectly Formatted | ${incorrect_percent}% |"
84+
} >> "$GITHUB_STEP_SUMMARY"
85+
exit 1
86+
fi
87+
88+
- name: Run clang-format for entire codebase
89+
if: ${{ github.event_name == 'push' }}
90+
shell: bash
91+
run: |
92+
clang-format-19 --version
93+
begin_group() { echo -e "::group::\033[93m$1\033[0m"; }
94+
95+
begin_group "Run clang-format"
96+
find src tst \( -name "*.hpp" -o -name "*.h" -o -name "*.hh" -o -name "*.cc" -o -name "*.cpp" -o -name "*.c" \) \
97+
-print0 | xargs -0 -P "$(nproc)" -n 1 clang-format-19 -style=file -i -fallback-style=none --verbose
98+
99+
# clang-format will auto correct files so prepare the diff and use this as artifact
100+
git diff > clang_format.patch
101+
echo "::endgroup::"
102+
103+
# Delete if nothing otherwise exit 1 to indicate a failed job
104+
if [ ! -s clang_format.patch ]; then
105+
rm clang_format.patch
106+
exit 0
107+
else
108+
file_count=$(find src tst \( -name "*.hpp" -o -name "*.h" -o -name "*.hh" -o -name "*.cc" -o -name "*.cpp" -o -name "*.c" \) | wc -l)
109+
incorrect_count=$(git diff --name-only | wc -l)
110+
incorrect_percent=$(awk "BEGIN { printf \"%.2f\", ($incorrect_count/$file_count)*100 }")
111+
begin_group "clang-format auto corrected $incorrect_count files:"
112+
git diff --name-only
113+
echo "::endgroup::"
114+
echo "::error title=Clang Format Check Failed::Formatting issues detected in $incorrect_count files"
115+
{
116+
echo "| Item | Value |"
117+
echo "|---------------------------------------|-----------|"
118+
echo "| Number of Files Analyzed | $file_count |"
119+
echo "| Number of Files Incorrectly Formatted | $incorrect_count |"
120+
echo "| % Files Incorrectly Formatted | ${incorrect_percent}% |"
121+
} >> "$GITHUB_STEP_SUMMARY"
122+
exit 1
123+
fi
124+
125+
- name: Upload clang-format patch as artifact
126+
if: ${{ failure() }}
127+
uses: actions/upload-artifact@v4
26128
with:
27-
clang-format-version: '10'
28-
check-path: 'tst/EnergyPlus/unit'
129+
name: EnergyPlus-${{ github.sha }}-clang_format.patch
130+
path: clang_format.patch
131+
132+
- name: Commit Auto-corrections
133+
shell: bash
134+
if: ${{ always() && github.event_name == 'push' }}
135+
run: |
136+
git add -u
137+
if [[ $(git diff --cached --exit-code) ]]; then
138+
echo "Commiting Lint Autocorrects"
139+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
140+
git config --global user.name 'github-actions[bot]'
141+
git commit -m "[chore] Commit clang-format autocorrects"
142+
echo '' >> .git-blame-ignore-revs
143+
git log -n1 --pretty='format:# %C(auto)%s [%an, %as]%n%H%n' >> .git-blame-ignore-revs
144+
git add .git-blame-ignore-revs
145+
git commit -m "Add clang-format autocorrects to git-blame-ignore-revs"
146+
git push
147+
else
148+
echo "No Autocorrect needed"
149+
fi
29150
30151
- name: Custom Check
31152
if: always()

idd/Energy+.idd.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53664,6 +53664,7 @@ Coil:Cooling:DX:VariableSpeed,
5366453664
\type alpha
5366553665
\reference CoolingCoilsDXVariableSpeed
5366653666
\reference DesuperHeatingCoilSources
53667+
\reference AFNCoilNames
5366753668
A2, \field Indoor Air Inlet Node Name
5366853669
\required-field
5366953670
\type node
@@ -56528,6 +56529,7 @@ Coil:Heating:DX:VariableSpeed,
5652856529
\required-field
5652956530
\type alpha
5653056531
\reference HeatingCoilsDXVariableSpeed
56532+
\reference AFNCoilNames
5653156533
A2, \field Indoor Air Inlet Node Name
5653256534
\required-field
5653356535
\type node
@@ -57599,6 +57601,7 @@ Coil:Cooling:WaterToAirHeatPump:EquationFit,
5759957601
\reference-class-name validBranchEquipmentTypes
5760057602
\reference validBranchEquipmentNames
5760157603
\reference DesuperHeatingWaterOnlySources
57604+
\reference AFNCoilNames
5760257605
A2, \field Water Inlet Node Name
5760357606
\required-field
5760457607
\type node
@@ -57746,6 +57749,7 @@ Coil:Cooling:WaterToAirHeatPump:VariableSpeedEquationFit,
5774657749
\reference-class-name validBranchEquipmentTypes
5774757750
\reference validBranchEquipmentNames
5774857751
\reference DesuperHeatingWaterOnlySources
57752+
\reference AFNCoilNames
5774957753
A2, \field Water-to-Refrigerant HX Water Inlet Node Name
5775057754
\required-field
5775157755
\type node
@@ -58602,6 +58606,7 @@ Coil:Heating:WaterToAirHeatPump:EquationFit,
5860258606
\reference HeatingCoilsWaterToAirHP
5860358607
\reference-class-name validBranchEquipmentTypes
5860458608
\reference validBranchEquipmentNames
58609+
\reference AFNCoilNames
5860558610
A2, \field Water Inlet Node Name
5860658611
\required-field
5860758612
\type node
@@ -58693,6 +58698,7 @@ Coil:Heating:WaterToAirHeatPump:VariableSpeedEquationFit,
5869358698
\reference HeatingCoilsWaterToAirVSHP
5869458699
\reference-class-name validBranchEquipmentTypes
5869558700
\reference validBranchEquipmentNames
58701+
\reference AFNCoilNames
5869658702
A2, \field Water-to-Refrigerant HX Water Inlet Node Name
5869758703
\required-field
5869858704
\type node
@@ -75740,6 +75746,8 @@ HeatPump:AirToWater:FuelFired:Heating,
7574075746
\min-fields 31
7574175747
A1 , \field Name
7574275748
\required-field
75749+
\reference-class-name validBranchEquipmentTypes
75750+
\reference validBranchEquipmentNames
7574375751
\reference HeatPumpAirToWaterFuelFiredHeatingNames
7574475752
\note Name of the fuel fired absorption heat pump system system
7574575753
A2 , \field Water Inlet Node Name
@@ -75920,6 +75928,8 @@ HeatPump:AirToWater:FuelFired:Cooling,
7592075928
\min-fields 26
7592175929
A1 , \field Name
7592275930
\required-field
75931+
\reference-class-name validBranchEquipmentTypes
75932+
\reference validBranchEquipmentNames
7592375933
\reference HeatPumpAirToWaterFuelFiredCoolingNames
7592475934
\note Name of the fuel fired absorption heat pump system system
7592575935
A2 , \field Water Inlet Node Name

src/.clang-format

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
1-
# Commented out lines are those which are not yet valid
2-
# in clang-3.8 which ships with Ubuntu
3-
4-
IndentWidth: 4
1+
---
2+
Standard: c++17
53
AccessModifierOffset: -4
6-
ColumnLimit: 150
7-
CommentPragmas: '^ IWYU pragma:'
8-
UseTab: Never
9-
SpacesInParentheses: false
10-
# SpaceBeforeParens: 'Control'
11-
SpaceInEmptyParentheses: false
12-
SpacesInAngles: false
13-
# CompactNamespaces: false
14-
NamespaceIndentation: 'Inner'
15-
# FixNamespaceComments: true
16-
BreakBeforeBraces: 'Custom'
17-
# BreakConstructorInitializers: 'AfterColon'
18-
AllowShortFunctionsOnASingleLine: 'None'
4+
AllowShortBlocksOnASingleLine: Never
195
AllowShortCaseLabelsOnASingleLine: false
20-
AllowShortIfStatementsOnASingleLine: true
21-
AllowShortBlocksOnASingleLine: false
6+
AllowShortFunctionsOnASingleLine: None
7+
AllowShortIfStatementsOnASingleLine: Never
228
BinPackArguments: false
239
BinPackParameters: false
24-
Standard: Cpp11
2510
BraceWrapping:
11+
AfterCaseLabel: false
2612
AfterClass: true
27-
AfterControlStatement: false
13+
AfterControlStatement: Never
2814
AfterEnum: true
15+
AfterExternBlock: false # Original config wanted to use "true"
2916
AfterFunction: true
3017
AfterNamespace: false
3118
AfterStruct: true
3219
AfterUnion: true
33-
# AfterExternBlock: true
3420
BeforeCatch: false
3521
BeforeElse: false
22+
BeforeLambdaBody: false
23+
BeforeWhile: false
3624
IndentBraces: false
37-
# SplitEmptyFunction: true
38-
# SplitEmptyRecord: true
39-
# SplitEmptyNamespace: true
25+
SplitEmptyFunction: true
26+
SplitEmptyNamespace: true
27+
SplitEmptyRecord: true
28+
BreakBeforeBraces: Custom
29+
BreakConstructorInitializers: BeforeColon # Original config wanted to use "AfterColon"
30+
ColumnLimit: 150
31+
CommentPragmas: '^ IWYU pragma:'
32+
CompactNamespaces: false
33+
FixNamespaceComments: true
4034
IndentPPDirectives: AfterHash
35+
IndentWidth: 4
36+
InsertBraces: true
37+
NamespaceIndentation: Inner
38+
SpaceBeforeParens: ControlStatements
39+
SpaceInEmptyParentheses: false
40+
SpacesInAngles: Never
41+
SpacesInParentheses: false
42+
UseTab: Never

src/ConvertInputFormat/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static constexpr std::array<std::string_view, static_cast<int>(OutputTypes::Num)
8888

8989
static constexpr auto outputTypeExperimentalStart = OutputTypes::CBOR;
9090

91-
template <typename... Args> void displayMessage(std::string_view str_format, Args &&... args)
91+
template <typename... Args> void displayMessage(std::string_view str_format, Args &&...args)
9292
{
9393
fmt::print(std::cout, str_format, args...);
9494
std::cout.write("\n", 1);

src/EnergyPlus/AirLoopHVACDOAS.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,9 @@ namespace AirLoopHVACDOAS {
10141014
void AirLoopDOAS::GetDesignDayConditions(EnergyPlusData &state)
10151015
{
10161016
for (auto &env : state.dataWeather->Environment) {
1017-
if (env.KindOfEnvrn != Constant::KindOfSim::DesignDay && env.KindOfEnvrn != Constant::KindOfSim::RunPeriodDesign) continue;
1017+
if (env.KindOfEnvrn != Constant::KindOfSim::DesignDay && env.KindOfEnvrn != Constant::KindOfSim::RunPeriodDesign) {
1018+
continue;
1019+
}
10181020
if (env.maxCoolingOATSizing > this->SizingCoolOATemp) {
10191021
this->SizingCoolOATemp = env.maxCoolingOATSizing;
10201022
// DesignDayNum = 0 for KindOfSim == RunPeriodDesign

src/EnergyPlus/AirTerminalUnit.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected: // Data
121121
int ctrlZoneInNodeIndex = 0; // which controlled zone inlet node number corresponds with this unit
122122
int airLoopNum = 0; // index to airloop that this terminal unit is connected to
123123
int termUnitSizingNum = 0; // index to TermUnitSizing, TermUnitFinalZoneSizing, and more for this air distribution unit
124-
}; // AirTerminalUnit
124+
}; // AirTerminalUnit
125125

126126
} // namespace EnergyPlus
127127

0 commit comments

Comments
 (0)