-
Notifications
You must be signed in to change notification settings - Fork 1.9k
dev: Add a script to auto fix all lint violations #19560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")" | ||
| PRETTIER_VERSION="2.7.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to keep using this old version ?
Latest is https://www.npmjs.com/package/prettier/v/3.7.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think it's supposed to get updated manually.
We can do so separately since it might have a large code diff.
ci/scripts/rust_fmt.sh
Outdated
| else | ||
| echo "[${SCRIPT_NAME}] \`cargo fmt --all -- --check\`" | ||
| cargo fmt --all -- --check | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It seems there is no newline (\n) at the end here (non POSIX complaint).
It is recommended to have it otherwise "it may break some old tools".
Even Github UI marks it as a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, updated.
Perhaps we should introduce some lint tools to check the existing bash scripts, to prevent similar issues in the future 🤔
|
@martin-g Thank you for the review, all comments are addressed in ae7fc70 After the change, I have tested again the following step, and it's working as expected.
|
Which issue does this PR close?
Part of #19227
Rationale for this change
See issue for details.
The existing script
./dev/rust_lint.shdo checks for all non-functional tests include formater/clippy checks.Some check tools support auto fix options, so this PR add an option to the lint scripts to perform auto-fixes.
Now
./dev/rust_lint.sh --write --allow-dirtycan perform auto-fixes for all linter etc. violationsWhat changes are included in this PR?
[--write] [--allow-dirty]flag torust_lint.shto support auto fixesrust_lint.shconsists of several sub-scripts likerust_fmt.sh, they're all extended with auto-fix feature through--writeflag, and therust_lint.shis optionally calling them with an additional flag for auto fixes.rust_lint.shAre these changes tested?
Yes, commit 8c99417 intentionally introduced one violation for each available lint check, and the auto-fix command is able to fix all of them.
The test may not be comprehensive, but it provides a reasonable starting point. We can begin using this script now and iterate on it if we discover cases where the auto-fix does not behave correctly.
Are there any user-facing changes?
No