feat: auto formatting & linting using pre-commit #1161
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As documented in the repo, many formatters & linters are used, which can be annoying to manage and execute.
To tackle this, I recommend using pre-commit to combine all formatting, lining, and checking tools into a single run.
Specifically, I added
.pre-commit-config.yaml
to configure all tools listed in the repo. One can then usein the repo root folder to execute all of them.
I ran the command locally and auto-fixed 402 files. Other linting problems have to be addressed manually, e.g., reinterpret_cast instead of C-style cast. The full log is available here.
Considering whether this automatic process would break the code correctness or not, at least it has passed all written tests (by running the test GitHub action here).
In the future, the pre-commit trigger can be added to GitHub action for checking & auto-fixing.