refactor: Remove superfluous returns at the end of functions#2594
refactor: Remove superfluous returns at the end of functions#2594xezon merged 2 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| scripts/cpp/remove_return.py | New helper script that drives the mass refactoring; logic is sound but contains a superfluous return at the end of its own main(). |
| Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp | Removes two trailing return; statements from empty void stubs — correct and safe. |
| Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | Removes four trailing return ; statements from void methods; no logic change. |
| Core/Libraries/Source/WWVegas/WWLib/wwstring.h | Removes multiple trailing return ; statements from inline constructors and helpers in the header — all correctly identified as superfluous. |
| Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp | Single return; removal from buildUpgrade; straightforward and correct. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp | Removes trailing return; and its preceding blank line from disengageAndDepartAO; correct. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[remove_return.py] --> B[Glob cpp/h/inl files across Core, Generals, GeneralsMD]
B --> C{For each line}
C --> D{Starts with return-semicolon?}
D -- No --> E[Keep line as-is]
D -- Yes --> F{Next non-blank line starts with closing-brace at column 0?}
F -- No --> E
F -- Yes --> G[Remove return line and preceding blank lines]
G --> H[Write cleaned file]
E --> H
Prompt To Fix All With AI
This is a comment left during a code review.
Path: scripts/cpp/remove_return.py
Line: 63
Comment:
**Superfluous `return` in the script itself**
The script that removes superfluous `return` statements at the end of functions itself contains one at the end of `main()`. Since the script only processes C++ files it won't self-apply, but it's a minor irony worth noting.
```suggestion
main()
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "Remove a few more" | Re-trigger Greptile
|
Do you plan to get rid of the now empty lines as well? |
|
The script only removed empty lines above the return. Not below. I think it is fine. |
a46ae11 to
4fd5138
Compare
Skyaero42
left a comment
There was a problem hiding this comment.
I agree the extra lines are fine. Based on a small sample it seems to fit in the style of the respective file anyways.
This change removes superfluous returns at the end of functions.
Applied with python script and a bit of hand holding.