devtools: Add fix-style-errors script by @sangbida.
A helper tool to fix code style errors using `ruff` and `clang-format` and correct spelling.
This commit is contained in:
18
devtools/fix-style-errors
Executable file
18
devtools/fix-style-errors
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Takes a list of files and applies style fixes for Python using `ruff` and C using
|
||||
# `clang-format`. Also corrects spelling using `codespell`. This tool is an auxiliary to the
|
||||
# `pre-commit` hooks found in:
|
||||
# `.pre-commit-config.yaml`
|
||||
#
|
||||
# WARNING: Changes are destructive. Ensure a clean working environment before running.
|
||||
#
|
||||
# By: @sangbida
|
||||
|
||||
for file in "$@"; do
|
||||
case "$file" in
|
||||
*.py) ruff check --fix "$file"; ruff format "$file" ;;
|
||||
*.c|*.h) clang-format -i "$file" 2>/dev/null ;;
|
||||
esac
|
||||
codespell -w "$file" 2>/dev/null
|
||||
done
|
||||
Reference in New Issue
Block a user