fix(conventions): check comments in GLSL shaders #5766

Merged
GalaxyGamingFR merged 2 commits from upstream-pr/5766 into main 2026-10-15 13:09:42 +00:00
GalaxyGamingFR commented 2026-10-14 09:54:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GalaxyGamingFR on 2026-10-14T09:54:42Z.


What

The comment rule in tools/check_conventions.py only scanned C++, Python and CMake files, so a comment added to a .comp, .frag or .vert shader passed the check, although CONVENTIONS.md allows comments only for technical debt. TextureDetile.comp and ColorTransfer.comp already carry such comments (both added before the checker existed). A new shaders() step masks shaders with the same C-style lexer as C++ (cpp_text, so // inside a string is not a comment) and reports comment on changed lines, with the same #endif allowance and the same technical-debt exemption as C++. Only changed lines are checked, so the existing shaders do not fail until they are edited.

Tested

Windows 11, Python 3.12. No C++ changes.

  • tools/tests/test_check_conventions_comments.py: new test_comment_in_a_shader_is_reported (4 subtests: // and /* */ in a .comp under Graphics/shaders and a .frag under tests/shaders) fails on main and passes with this change; new test_shader_without_comments_passes (a "a//b" string and #endif // X) passes.
  • the tests live in the tool's existing test file, so CMakeLists.txt is unchanged.
  • every tools/tests/test_*.py passes; python -I tools/check_conventions.py --base origin/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_012zyXkUzTZGh3nBwNMtrLaW

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4856094113 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5766). Originally posted by [GalaxyGamingFR](https://github.com/GalaxyGamingFR) on 2026-10-14T09:54:42Z. --- ### What The `comment` rule in `tools/check_conventions.py` only scanned C++, Python and CMake files, so a comment added to a `.comp`, `.frag` or `.vert` shader passed the check, although [CONVENTIONS.md](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) allows comments only for technical debt. `TextureDetile.comp` and `ColorTransfer.comp` already carry such comments (both added before the checker existed). A new `shaders()` step masks shaders with the same C-style lexer as C++ (`cpp_text`, so `//` inside a string is not a comment) and reports `comment` on changed lines, with the same `#endif` allowance and the same technical-debt exemption as C++. Only changed lines are checked, so the existing shaders do not fail until they are edited. ### Tested Windows 11, Python 3.12. No C++ changes. - `tools/tests/test_check_conventions_comments.py`: new `test_comment_in_a_shader_is_reported` (4 subtests: `//` and `/* */` in a `.comp` under `Graphics/shaders` and a `.frag` under `tests/shaders`) fails on `main` and passes with this change; new `test_shader_without_comments_passes` (a `"a//b"` string and `#endif // X`) passes. - the tests live in the tool's existing test file, so `CMakeLists.txt` is unchanged. - every `tools/tests/test_*.py` passes; `python -I tools/check_conventions.py --base origin/main` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012zyXkUzTZGh3nBwNMtrLaW
Dextroid17 commented 2026-10-14 22:02:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-14T22:02:16Z.


Checked on a worktree of this branch (Linux, Python 3), not a build:

  • python3 -m unittest tools.tests.test_check_conventions_comments: 55 tests OK. With tools/check_conventions.py reset to main and the new tests kept, 1 of the 55 tests fails (4 of its subtests: .comp and .frag, each with // and /* */), so the new tests exercise the rule.
  • check_conventions.py --base upstream/main --head <this branch>: passes.
  • Existing shaders on main already contain comments (for example TextureDetile.comp, ColorTransfer.comp). Touching one of them without adding a comment reports nothing; adding a // ... on a line reports [comment] for that line only. So the rule judges added lines, not whole files.

The branch was about 660 commits behind main when I checked, so the --base upstream/main pass compared against a much newer base.

Not checked: .glsl, .geom or other shader extensions (the rule covers .comp, .frag, .vert), and block comments that span several lines where only the middle line is added.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6179461855 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5766#issuecomment-6179461855). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-14T22:02:16Z. --- Checked on a worktree of this branch (Linux, Python 3), not a build: - `python3 -m unittest tools.tests.test_check_conventions_comments`: 55 tests OK. With `tools/check_conventions.py` reset to main and the new tests kept, 1 of the 55 tests fails (4 of its subtests: .comp and .frag, each with `//` and `/* */`), so the new tests exercise the rule. - `check_conventions.py --base upstream/main --head <this branch>`: passes. - Existing shaders on main already contain comments (for example `TextureDetile.comp`, `ColorTransfer.comp`). Touching one of them without adding a comment reports nothing; adding a `// ...` on a line reports `[comment]` for that line only. So the rule judges added lines, not whole files. The branch was about 660 commits behind main when I checked, so the `--base upstream/main` pass compared against a much newer base. Not checked: `.glsl`, `.geom` or other shader extensions (the rule covers .comp, .frag, .vert), and block comments that span several lines where only the middle line is added. AI-assisted: yes
github-actions[bot] commented 2026-10-15 12:09:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:09:23Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
#5780 tools/check_conventions.py
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191699609 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5766#issuecomment-6191699609). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:09:23Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | #5780 | `tools/check_conventions.py` |
adriadam10 commented 2026-10-15 12:45:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T12:45:19Z.


Checked on the PR merged onto current main: tools/tests pass, the new shader test fails without the change (4 subtests) and passes with it, no false positive on "a//b" strings or #endif // X.

One gap fixed in a follow-up commit on your branch (1b94074869): .glsl files (e.g. PqToSdr.glsl) were not covered, so the suffix list now includes .glsl, with a test case. Rebased on main as well. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6192376293 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5766#issuecomment-6192376293). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-15T12:45:19Z. --- Checked on the PR merged onto current main: `tools/tests` pass, the new shader test fails without the change (4 subtests) and passes with it, no false positive on `"a//b"` strings or `#endif // X`. One gap fixed in a follow-up commit on your branch (1b94074869): `.glsl` files (e.g. `PqToSdr.glsl`) were not covered, so the suffix list now includes `.glsl`, with a test case. Rebased on main as well. Merging once CI is green.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5766
No description provided.