Skip to content

Implement style check script and CI#2670

Merged
ribbanya merged 9 commits into
doldecomp:masterfrom
itsgrimetime:pr/jobj-hidden-sweep
Jun 13, 2026
Merged

Implement style check script and CI#2670
ribbanya merged 9 commits into
doldecomp:masterfrom
itsgrimetime:pr/jobj-hidden-sweep

Conversation

@itsgrimetime

@itsgrimetime itsgrimetime commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Tooling for the style-check series. Both source sweeps merged separately (#2675 jobj 0x10JOBJ_HIDDEN, #2676 assert macros), so this PR is tooling only.

Adds tools/check/ — a small, extensible style checker:

  • two checks, both enabled by default and disabled with --no-<check> (mirrors clang -Wno-): jobj-flags (raw 0x10 where JOBJ_HIDDEN is meant) and assert-macros (direct __assert calls expressible with the HSD assert macros; @todo-annotated sites exempt)
  • --msg-style std (default) mirrors melee-issues (tools/issues): a severity > category > [option] > file hierarchy and an Issues: OK / Issues: N summary, with the same exit codes (0 / 65 EX_DATAERR / 74 EX_IOERR). --msg-style actions emits GitHub Actions annotations.
  • comment/string-aware scanning that handles calls split across lines
  • fixtures per check under tools/check/tests/ (run: python3 -m unittest discover -s tools/check/tests -t tools -p '*.py')

CI (style-check.yml) lints src on push and pull_request — findings fail the job with inline annotations, mirroring melee-issues. The unit tests are a development tool and are not run in CI.

Incorporates @ribbanya's review (module layout; opt-out per-check flags; --msg-style; std mirrors melee-issues + exit codes; type annotations; line-break handling; precompiled regex; tests as a separate module; lint src in CI, not the unit tests).

🤖 Generated with Claude Code

@itsgrimetime itsgrimetime marked this pull request as draft June 12, 2026 21:13
@decomp-dev

decomp-dev Bot commented Jun 12, 2026

Copy link
Copy Markdown

Report for GALE01 (3a7df8e - 5896c57)

No changes

itsgrimetime added a commit to itsgrimetime/melee that referenced this pull request Jun 12, 2026
Scans all of src/ at the PR merge ref and warns (non-blocking, inline
file/line annotations) on any HSD_JObj{Set,Clear}Flags[All] call passing
raw 0x10/0x10U/16 instead of JOBJ_HIDDEN. The scanner is comment- and
string-literal-aware and paren-walks calls, so wrapped/multi-line calls
are detected; since doldecomp#2670 sweeps the tree to zero, any finding is newly
introduced. The workflow only reads source text and never executes
PR-controlled code.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@itsgrimetime itsgrimetime force-pushed the pr/jobj-hidden-sweep branch from 937c247 to d9abccf Compare June 12, 2026 21:24
@itsgrimetime

itsgrimetime commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

actually gonna move it into the issues checker/repo tools script as @ribbanya suggested in discord
Actually just a separate python script because editing a script sitting inline in yaml sucks

@itsgrimetime itsgrimetime force-pushed the pr/jobj-hidden-sweep branch from d9abccf to e97b985 Compare June 12, 2026 21:50
@itsgrimetime itsgrimetime marked this pull request as ready for review June 12, 2026 21:56
Comment thread tools/jobj_flags_check.py Outdated
itsgrimetime and others added 2 commits June 12, 2026 20:59
Syntax-aware sweep of HSD_JObj{Set,Clear}Flags[All] call sites replacing
raw hidden-flag literals (0x10 / 0x10U / 16 / 16U) in the flag argument
with the named JOBJ_HIDDEN: 505 sites across 73 files. Composite masks
and other flag values are untouched.

All 1046 compiled objects verified byte-identical before and after the
change (per-object sha1); main.dol sha1 unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A small, extensible style checker for the source tree. Each check is
enabled by default and can be disabled with --no-<check> (mirroring
clang's -Wno- flags); --msg-style {std,actions} selects human-readable
or GitHub Actions annotation output (mirroring configure.py and mwcc).

The first check, jobj-flags, flags HSD_JObj{Set,Clear}Flags[All] calls
passing a raw hidden-flag literal instead of JOBJ_HIDDEN. The flag
argument is matched with a precompiled regex covering the integer forms
whose value is 16 (hex/decimal/octal, optional suffix); the call scanner
is comment- and string-aware and handles calls split across lines.

tools/test_check.py holds the fixtures (run: python3 tools/test_check.py).
The style-check workflow runs the tests, then the checker over src/ as
non-blocking inline warnings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ribbanya ribbanya changed the title Replace raw 0x10 with JOBJ_HIDDEN in JObj flag calls Implement style check script and CI Jun 13, 2026
ribbanya and others added 3 commits June 13, 2026 14:44
Move the single-file checker into a package: tools/check/main.py (the
driver and checks) and tools/check/__init__.py, with per-check fixtures
under tools/check/tests/. Both checks (jobj-flags, assert-macros) live in
the module; each is enabled by default and disabled with --no-<check>.

std output now mirrors melee-issues (tools/issues): a
severity > category > [option] > file hierarchy and a final Issues: OK /
Issues: N summary, with matching exit codes (0, 65 EX_DATAERR, 74
EX_IOERR). --msg-style actions still emits GitHub Actions annotations.

Remove the style-check CI workflow; the checker is a development tool run
on demand (python3 tools/check/main.py), not part of CI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread tools/check/main.py

@ribbanya ribbanya left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Did the CI check get lost?

@itsgrimetime

Copy link
Copy Markdown
Contributor Author

Both checks are already in — tools/check/main.py registers jobj-flags and assert-macros, with fixtures in tools/check/tests/jobj_flags.py and tools/check/tests/assert_macros.py. Folded the #2671 check in during the restructure, so this should be ready to merge?

Or maybe I misunderstood what you meant by "Remove the CI check, it's for development of the tool only."

@ribbanya

ribbanya commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Oh I see, the bot interpreted "don't run the self-tests during CI" as "remove the source checks from CI." It should definitely be linting src on pull requests. Just not the unit tests.

@itsgrimetime

Copy link
Copy Markdown
Contributor Author

Oh I see, the bot interpreted "don't run the self-tests during CI" as "remove the source checks from CI." It should definitely be linting src on pull requests. Just not the unit tests.

Ah gotchya - that was misunderstanding on both claude & I's part lol

Run the checker over src on push and pull_request. Findings fail the
job (exit 65) with inline annotations (--msg-style actions); an internal
error fails it (74). The unit tests under tools/check/tests are a
development tool and are intentionally not run in CI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@itsgrimetime

Copy link
Copy Markdown
Contributor Author

okay should be good now? lmk if you want anything else adjusted

Comment thread .github/workflows/style-check.yml Outdated
Comment thread .github/workflows/style-check.yml Outdated
Comment thread .github/workflows/style-check.yml Outdated
@ribbanya

ribbanya commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

It would be useful to also have a CLI option that applies the fixes (to be run locally), instead of relying on an LLM to interpret and implement them. But that can be done later, or never, up to you.

Comment thread .github/workflows/style-check.yml Outdated
@ribbanya ribbanya force-pushed the pr/jobj-hidden-sweep branch from 5896c57 to dcae43a Compare June 13, 2026 21:23
@ribbanya ribbanya enabled auto-merge (squash) June 13, 2026 21:28
@ribbanya ribbanya merged commit 65cdc5f into doldecomp:master Jun 13, 2026
11 checks passed
@itsgrimetime

Copy link
Copy Markdown
Contributor Author

It would be useful to also have a CLI option that applies the fixes (to be run locally), instead of relying on an LLM to interpret and implement them. But that can be done later, or never, up to you.

love that idea - im gonna be continuing to do some tooling improvements like this so will fold that in in some upcoming PRs. thanks for the help on this one

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants