Skip to content

chore: Remove trailing commas in braced initializers to help clang-format - #3274

Open
mirelle7 wants to merge 1 commit into
TheSuperHackers:mainfrom
mirelle7:fix/remove-trailing-commas
Open

chore: Remove trailing commas in braced initializers to help clang-format#3274
mirelle7 wants to merge 1 commit into
TheSuperHackers:mainfrom
mirelle7:fix/remove-trailing-commas

Conversation

@mirelle7

Copy link
Copy Markdown

In preparation for the clang-format PR. This removes all trailing commas inside braced initializers to avoid unwanted multi-line formatting.

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 10, 2026

Copy link
Copy Markdown

PR Summary by Qodo

Remove trailing commas from braced initializers for clang-format

✨ Enhancement 🕐 Less than 10 minutes

Grey Divider

AI Description

• Remove trailing commas from braced initializers across engine, game, and tool code.
• Prevent clang-format from forcing unchanged initializers into unwanted multi-line layouts.
High-Level Assessment

The targeted source cleanup is appropriate because it directly prevents clang-format's unwanted initializer expansion without changing runtime behavior. A broader formatter configuration change was considered, but it could alter formatting rules beyond these specific initializers.

Files changed (19) +89 / -89

Refactor (19) +89 / -89
BezierSegment.cppRemove trailing commas from coordinate initializers +9/-9

Remove trailing commas from coordinate initializers

• Removes final commas from Coord3D initializers used by Bezier length and segment-splitting calculations without changing their values.

Core/GameEngine/Source/Common/Bezier/BezierSegment.cpp

GameMemoryInitPools_Generals.inlNormalize Generals memory pool records +4/-4

Normalize Generals memory pool records

• Removes trailing commas from selected pool-size records, including conditionally compiled surrender and demoralize entries.

Core/GameEngine/Source/Common/System/GameMemoryInitPools_Generals.inl

GameMemoryInitPools_GeneralsMD.inlNormalize GeneralsMD memory pool records +4/-4

Normalize GeneralsMD memory pool records

• Removes trailing commas from selected GeneralsMD pool-size records without changing pool names or capacities.

Core/GameEngine/Source/Common/System/GameMemoryInitPools_GeneralsMD.inl

Chat.cppNormalize the GameSpy color array terminator +1/-1

Normalize the GameSpy color array terminator

• Removes the trailing comma from the final GameSpy chat color entry.

Core/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp

GameSpyOverlay.cppNormalize the GameSpy overlay array terminator +1/-1

Normalize the GameSpy overlay array terminator

• Removes the trailing comma from the final overlay menu path.

Core/GameEngine/Source/GameNetwork/GameSpyOverlay.cpp

Win32DIMouse.cppNormalize the mouse buffer enum initializer +1/-1

Normalize the mouse buffer enum initializer

• Removes the trailing comma from the single-value mouse buffer size enum.

Core/GameEngineDevice/Source/Win32Device/GameClient/Win32DIMouse.cpp

formconv.cppNormalize the depth-format conversion array +1/-1

Normalize the depth-format conversion array

• Removes the trailing comma from the final Direct3D depth-format mapping.

Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp

GETCD.cppNormalize CD volume label arrays +2/-2

Normalize CD volume label arrays

• Removes trailing commas from the final CD volume labels in both mission-disk and base-game configurations.

Core/Tools/Autorun/GETCD.cpp

BFISH.cppNormalize nested Blowfish S-box initializers +3/-3

Normalize nested Blowfish S-box initializers

• Removes trailing commas from the final values of the first three nested Blowfish S-box arrays.

Core/Tools/Launcher/BFISH.cpp

GameMtl.cppNormalize material parameter descriptor arrays +6/-6

Normalize material parameter descriptor arrays

• Removes trailing commas from the final descriptors in the main and versioned material parameter blocks.

Core/Tools/WW3D/max2w3d/GameMtl.cpp

PS2GameMtlShaderDlg.cppNormalize PS2 shader preset initialization +1/-1

Normalize PS2 shader preset initialization

• Removes the trailing comma from the final PS2 shader blend preset.

Core/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.cpp

BorderColors.hNormalize Generals border color records +8/-8

Normalize Generals border color records

• Removes trailing commas inside all Generals border color record initializers.

Generals/Code/GameEngine/Include/Common/BorderColors.h

Scripts.cppNormalize Generals script lookup arrays +2/-2

Normalize Generals script lookup arrays

• Removes final trailing commas from the shell hook names and surface names arrays.

Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp

Properties.cppNormalize the Generals color control record +1/-1

Normalize the Generals color control record

• Removes the trailing comma from the button color control initializer.

Generals/Code/Tools/GUIEdit/Source/Properties.cpp

TeamGeneric.cppNormalize Generals team control mappings +17/-17

Normalize Generals team control mappings

• Removes trailing commas from all team script control pairs and the terminating sentinel record.

Generals/Code/Tools/WorldBuilder/src/TeamGeneric.cpp

BorderColors.hNormalize GeneralsMD border color records +8/-8

Normalize GeneralsMD border color records

• Removes trailing commas inside all GeneralsMD border color record initializers.

GeneralsMD/Code/GameEngine/Include/Common/BorderColors.h

Scripts.cppNormalize GeneralsMD script lookup arrays +2/-2

Normalize GeneralsMD script lookup arrays

• Removes final trailing commas from the shell hook names and surface names arrays.

GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp

Properties.cppNormalize the GeneralsMD color control record +1/-1

Normalize the GeneralsMD color control record

• Removes the trailing comma from the button color control initializer.

GeneralsMD/Code/Tools/GUIEdit/Source/Properties.cpp

TeamGeneric.cppNormalize GeneralsMD team control mappings +17/-17

Normalize GeneralsMD team control mappings

• Removes trailing commas from all team script control pairs and the terminating sentinel record.

GeneralsMD/Code/Tools/WorldBuilder/src/TeamGeneric.cpp

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 10, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Generals builds fail on border color initialization 🐞 Bug ≡ Correctness
Description
The updated BORDER_COLORS entries omit the commas separating adjacent array elements. The compiler
reaches the next braced initializer immediately after each element, so both Generals and its
consumers fail to compile.
Code

Generals/Code/GameEngine/Include/Common/BorderColors.h[R32-35]

+	{ "Orange",					0xFFFF8700 },
+	{ "Green",					0xFF00FF00 },
+	{ "Blue",						0xFF0000FF },
+	{ "Cyan",						0xFF00FFFF },
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `BORDER_COLORS` array entries no longer have commas after their closing braces, so adjacent braced initializers are not separated and the file cannot compile.
### Fix Focus Areas
- Generals/Code/GameEngine/Include/Common/BorderColors.h[32-39]
- GeneralsMD/Code/GameEngine/Include/Common/BorderColors.h[32-39]
### Recommended Fix
Keep the trailing comma inside each inner initializer removed, but add a comma after each closing brace except where the array ends, for example `{ "Orange", 0xFFFF8700 },`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can turn these tips off under Display preferences

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread Generals/Code/GameEngine/Include/Common/BorderColors.h
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR removes trailing commas from nested C++ braced initializers to prevent unwanted clang-format expansion.

  • Preserves all initializer values, element counts, ordering, and sentinel entries.
  • Applies equivalent cleanup across the Generals and GeneralsMD variants.
  • Retains outer array-element trailing commas where appropriate.

Confidence Score: 5/5

The PR appears safe to merge because the changes are syntactic cleanup that preserves initializer contents and behavior.

No actionable correctness, security, build, or repository-rule violations remain in the reviewed changes.

Important Files Changed

Filename Overview
Core/GameEngine/Source/Common/Bezier/BezierSegment.cpp Removes trailing commas from local Coord3D initializers without changing their values.
Core/Tools/Launcher/BFISH.cpp Removes trailing commas from nested Blowfish S-box rows while preserving every constant and array boundary.
Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp Cleans up the Surfaces initializer while retaining the valid outer trailing comma in TheShellHookNames.
GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp Mirrors the safe initializer cleanup and outer-array comma handling in the Zero Hour variant.
Generals/Code/Tools/WorldBuilder/src/TeamGeneric.cpp Removes inner row-ending commas without changing control ID pairs or the terminating sentinel.
GeneralsMD/Code/Tools/WorldBuilder/src/TeamGeneric.cpp Applies the equivalent non-behavioral initializer cleanup to the Zero Hour WorldBuilder table.

Reviews (5): Last reviewed commit: "chore: Remove trailing commas that break..." | Re-trigger Greptile

@mirelle7
mirelle7 marked this pull request as draft September 10, 2026 17:21
@mirelle7
mirelle7 marked this pull request as ready for review September 10, 2026 17:43
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f502b38

@Caball009

Copy link
Copy Markdown

If the second commit is necessary to avoid the same issue, doesn't that mean there are many more instances of this issue? I'd expect all cases that match these queries to be the same:
,\s*\n\s*}
,\s*//.*\n\s*}

@mirelle7

mirelle7 commented Sep 10, 2026

Copy link
Copy Markdown
Author

,\s*//.\n\s} not needed.

added ,\s*\n\s*}

@Skyaero42

Copy link
Copy Markdown

What is the modern C++ convention on using trailing comma's on the last line?

C#'s Stylecop enforced it (SA1413 - Use trailing comma in multi-line initializers). Python, Javascript and Typescript have similar rules that can be enabled.

There are pro- and cons for using trailing comma's, but removing shouldn't be based on formatting only

@mirelle7
mirelle7 force-pushed the fix/remove-trailing-commas branch from 69e3fca to f6dc518 Compare September 10, 2026 20:42
Scoped to comment-free array/struct literals (BorderColors, TeamGeneric,
BezierSegment, GameMemoryInitPools, BFISH, Properties, Scripts) where
clang-format explodes each element onto its own line without this.
Enums are left alone; EnumTrailingComma: Remove in .clang-format handles
those automatically instead of needing manual edits.
@mirelle7
mirelle7 force-pushed the fix/remove-trailing-commas branch from f6dc518 to 55c7d6b Compare September 10, 2026 20:48
@mirelle7

mirelle7 commented Sep 10, 2026

Copy link
Copy Markdown
Author

I'm adding looking into "EnumTrailingComma" in the clang format PR.
Reverted all changes that weren't actually affected by clang-format but found by the regex.

0x83260376U,0x6295CFA9U,0x11C81968U,0x4E734A41U,0xB3472DCAU,0x7B14A94AU,0x1B510052U,0x9A532915U,
0xD60F573FU,0xBC9BC6E4U,0x2B60A476U,0x81E67400U,0x08BA6FB5U,0x571BE91FU,0xF296EC6BU,0x2A0DD915U,
0xB6636521U,0xE7B9F9B6U,0xFF34052EU,0xC5855664U,0x53B02D5DU,0xA99F8FA1U,0x08BA4799U,0x6E85076AU,
0xB6636521U,0xE7B9F9B6U,0xFF34052EU,0xC5855664U,0x53B02D5DU,0xA99F8FA1U,0x08BA4799U,0x6E85076AU

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe do clang-format off instead

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason: see #2820 (comment)

@xezon xezon changed the title chore: Remove trailing commas in braced initializers to help clang-fomat chore: Remove trailing commas in braced initializers to help clang-format Sep 12, 2026
@CryoTheRenegade

Copy link
Copy Markdown

What is the modern C++ convention on using trailing comma's on the last line?

C#'s Stylecop enforced it (SA1413 - Use trailing comma in multi-line initializers). Python, Javascript and Typescript have similar rules that can be enabled.

There are pro- and cons for using trailing comma's, but removing shouldn't be based on formatting only

Looks like its still in the proposal stages for c++ std
https://lists.isocpp.org/std-proposals/2025/08/14829.php

But google and LLVM coding standards allow it
https://releases.llvm.org/20.1.0/docs/CodingStandards.html
https://google.github.io/styleguide/cppguide.html

@xezon

xezon commented Sep 12, 2026

Copy link
Copy Markdown

I think the main reason why trailing comma exists is for unrolling type of macros (a macro that unrolls a list). It cannot omit the last trailing comma, because the macro is not that clever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants