-
-
Notifications
You must be signed in to change notification settings - Fork 167
Add names of rust linter and formatter config files #539
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
Conversation
see also documentation of rustfmt: https://rust-lang.github.io/rustfmt/?version=v1.8.0
see also documentation of clippy: https://doc.rust-lang.org/clippy/configuration.html
Some further linter for rust, but focused on dependencies: https://embarkstudios.github.io/cargo-deny/checks/cfg.html
|
I don't see how this can be useful? why wouldn't this just use |
|
With that changes, for example I would use this for types_or: [cargo, rust, rustfmt]I am not sure, what your alternative approach with the same filtering would be. For example this would not match anymore the files: "\\.?rustfmt\\.toml"
types_or: [cargo, rust, toml]So everything, needs to be defined with files: "(\\.?rustfmt\\.toml|Cargo.toml|.+\\.rs)"which is not that readable. Only using types_or: [cargo, rust, toml] |
|
that doesn't really make sense, you would just use |
|
I call it on the whole repository: - id: rustfmt
name: rustfmt
description: The Rust default formatter (see .rustfmt.toml for config)
# Run via cargo to use edition from Cargo.toml
entry: cargo fmt --check --verbose
language: rust
types_or: [cargo, rust]
pass_filenames: falseRunning Similar is for the two linter, which are also called on the whole repository and config changes are relevant. - id: cargo-deny
name: cargo-deny
description: A Linter which checks Rust dependencies (e.g., regarding licenses)
entry: cargo deny check
language: rust
types_or: [cargo, cargo-lock]
pass_filenames: false
additional_dependencies: [cli:cargo-deny:0.18.*]
- id: clippy
name: clippy
description: The Rust default linter
entry: cargo clippy
language: rust
types_or: [cargo, rust]
pass_filenames: false
stages: [pre-push] |
yeah I'd say you're holding it wrong then. part of the point of pre-commit is to only run on the things that change |
|
Okay, so is the right way to run Furthermore, cargo-deny only process the config files (from cargo and from deny) as it only considers the dependencies of a project. For clippy as a normal linter, I would expect a support for processing single files, but that seems to be missing (see Issue). |
|
I reworked my pre-commit config, but I still see the need for these new types, even for rustfmt. These would allow using |
|
no I wouldn't bother with a "run everything" hook. just do that manually and you should be running everything in ci already anyway. |
|
In my CI (at Codeberg) I plan to use |
|
indeed so you don't really need this:
|
|
Okay, I understand your point of view now. The CI is enough to ensure that the project and its config fits together and the pre-commit checks for this is not necessary, and you do not need to spend computation time on them. The other perspective is to avoid CI fails as much as possible with pre-commit checks to fix issues earlier. Something like this is always a trade-off. |
In Rust there is a default formatter, called
rustfmt, and a default linter, calledclippy. This Pull Request adds the names (with and without leading dot) of their config files (see commit message for links to the respective documentations).Furthermore, the single file name for
cargo-deny, a linter focused on cargo / Rust dependencies.(Useful, when running them with
pre-commitand only want to run, if relevant files have changed, i.e., rust files,Cargo.tomlor the config file in the repository. Examplepre-commitconfig for a Rust project here)