Skip to content

Add pre-commit hooks with Ruff and C++ formatting/linting support - #68

Merged
harryswift01 merged 6 commits into
mainfrom
67-general-add-pre-commit-hooks-with-ruff
Sep 28, 2026
Merged

harryswift01 merged 6 commits into
mainfrom
67-general-add-pre-commit-hooks-with-ruff

Conversation

@harryswift01

Copy link
Copy Markdown
Member

Summary

This PR adds pre-commit hooks to SIST, covering both Python (Ruff) and C++ (clang-format, clang-tidy) linting/formatting, applies them across the existing codebase, and enforces them in CI.

Changes

Add pre-commit configuration:

  • Added .pre-commit-config.yaml with ruff-check/ruff-format, general repository hygiene hooks (large file checks, merge conflict markers, YAML/TOML validation, end-of-file/trailing whitespace), rstcheck for docstrings, and a pre-push docs build gate
  • Added pre-commit, ruff, pylint, and rstcheck to pyproject.toml's new pre-commit extra

Add C++ formatting and static analysis:

  • Added clang-format and clang-tidy hooks, scoped so clang-tidy only runs against translation units (.cpp/.cc/.cxx/.c), not headers, since headers aren't independently compilable
  • clang-tidy runs a curated check set (clang-analyzer-*, bugprone-*) rather than the full default set, to keep findings focused on genuine correctness issues rather than legacy style noise
  • Added clang-format/clang-tidy to the pre-commit extra so both are pip-installable with no system dependency required
  • Reformatted all existing C++ source in src/trans_three/src/trans_compete with clang-format's built-in default style

Apply hooks across the existing repository:

  • Ran pre-commit run --all-files once to bring the whole repository into compliance (formatting/whitespace-only changes)

Enforce in CI and document setup:

  • Added a pre-commit job to pr.yaml, gated behind needs: unit, that fails the build with a diff if any hook doesn't pass
  • Documented the pre-commit setup and tooling stack in docs/source/development.rst

Impact

  • No behavioural change to SIST itself, the C++ reformatting is purely cosmetic
  • Verified after reformatting: both trans_three/trans_compete compile clean, tests/unit and tests/regression
  • PRs will now fail CI if pre-commit checks haven't been run, closing the gap where only contributors with the hook installed locally were covered

@harryswift01 harryswift01 self-assigned this Sep 28, 2026
@harryswift01 harryswift01 added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 28, 2026

@jimboid jimboid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good and seems to be doing the things it is meant to. Happy to merge

@harryswift01
harryswift01 merged commit cff7a51 into main Sep 28, 2026
15 checks passed
@harryswift01
harryswift01 deleted the 67-general-add-pre-commit-hooks-with-ruff branch September 28, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[General]: Add pre-commit hooks with Ruff and C++ formatting support

2 participants