style: Convert leading spaces to tabs in Core and Dependencies#2561
style: Convert leading spaces to tabs in Core and Dependencies#2561bobtista wants to merge 7 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| scripts/cpp/convert_leading_spaces_to_tabs.py | New utility script using tree-sitter to convert spaces→tabs; PR description says it should not be merged but the file is included in the diff. |
| Core/GameEngine/Source/GameNetwork/Network.cpp | Whitespace-only conversion; braceless else bodies (6 instances) were under-indented — return 0.0; left at depth 1 instead of depth 2. |
| Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp | Whitespace-only conversion; 5 braceless else return 0.0; bodies share the same under-indentation regression as Network.cpp. |
| Core/GameEngine/Source/Common/System/AsciiString.cpp | Whitespace-only conversion; mixed-whitespace va_start/va_end lines correctly normalized to 1 tab. |
| Core/GameEngine/Include/Common/AudioEventInfo.h | Whitespace-only conversion; 2-space indented member declarations correctly converted to 1-tab indentation. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Read source file\ncp1252 encoding] --> B[Preprocess macros\nfor tree-sitter]
B --> C[Parse with\ntree-sitter C++]
C --> D{Too many\nparse errors?}
D -->|yes| E[Skip file]
D -->|no| F[For each line]
F --> G{In block\ncomment?}
G -->|yes| H[Keep as-is]
G -->|no| I{Has leading\nspaces?}
I -->|no| H
I -->|yes| J[Find AST node\nat line start]
J --> K{Continuation\nline or ERROR?}
K -->|yes| H
K -->|no| L[Compute indent\ndepth via AST walk]
L --> M{Sanity check:\ndepth=0 but 4+ spaces?}
M -->|fail| H
M -->|pass| N[Replace leading ws\nwith N tabs]
N --> O[Write converted file]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Core/GameEngine/Source/GameNetwork/Network.cpp
Line: 831
Comment:
**Braceless `else` body under-indented**
The `return 0.0;` inside a braceless `else` clause was converted to depth 1 (one tab) but should be at depth 2 (two tabs), matching the indentation of the `if`-branch body above it. This pattern appears 6 times in this file and 5 more times in `ConnectionManager.cpp`. The resulting layout is visually ambiguous — the `return 0.0` line sits at the same column as `else`, making it look like it's outside the `else` branch.
```suggestion
return 0.0;
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: scripts/cpp/convert_leading_spaces_to_tabs.py
Line: 1
Comment:
**Script included in PR despite PR description saying it shouldn't be merged**
The PR description states: *"The formatting script is included in the PR for reference but is not intended to be merged."* However, `scripts/cpp/convert_leading_spaces_to_tabs.py` is a new file in this diff and will be committed to the repository. If the intent is to keep it out of the codebase, it should be removed from this branch. If the intent is to keep it as a reference utility in `scripts/`, the PR description should be updated to reflect that.
How can I resolve this? If you propose a fix, please make it concise.Reviews (3): Last reviewed commit: "style: Fix indentation regressions flagg..." | Re-trigger Greptile
xezon
left a comment
There was a problem hiding this comment.
By what rules are these whitespaces edited? How can it be reviewed?
| //using the IMC_SETCOMPOSITIONWINDOW message. | ||
| // | ||
| //I'm not sure what to do here. | ||
| m_result = 1; |
| return SEISMIC_STATUS_ACTIVE; | ||
| } | ||
| else | ||
| return SEISMIC_STATUS_ZERO_ENERGY; |
|
|
||
| // sanity | ||
| if( wallPiece == nullptr ) | ||
| if( wallPiece == nullptr ) |
Leading whitespace is regenerated from the C++ AST, not counted from spaces. For more details on how it's done, check scripts/cpp/convert_leading_spaces_to_tabs.py it will:
It skips a bunch of things eg block comments, and things that are addressed in later PRs to make review easier. To review it, I'd make sure you like the approach in the script, then spot check the results. |
Summary
git diff -wis empty)Access specifiers (
public:/private:/protected:) are placed at the classbrace level, matching the existing codebase convention.
Script
The formatting script is included in the PR for reference but is not intended
to be merged — it shows how the changes were generated.
See
scripts/cpp/convert_leading_spaces_to_tabs.pyfor details.Part 1 of 4 — Core/ and Dependencies/ (499 files).
See also: #2562, #2563, #2564.