admin管理员组文章数量:1421182
Executing cargo clippy --all --fix --allow-dirty --allow-staged
will automatically fix the code, but if you don't execute it, meaning you don't fix those codes, cargo clippy --all --tests -- -D warnings
can pass.
Is there a difference in how the former and the latter handle the rules?
I tried looking through various documents and source code but couldn't find the answer.
I guess it's because of different scanning ranges or rule requirements, but I don't have any documentation or evidence of clip source code.
Executing cargo clippy --all --fix --allow-dirty --allow-staged
will automatically fix the code, but if you don't execute it, meaning you don't fix those codes, cargo clippy --all --tests -- -D warnings
can pass.
Is there a difference in how the former and the latter handle the rules?
I tried looking through various documents and source code but couldn't find the answer.
I guess it's because of different scanning ranges or rule requirements, but I don't have any documentation or evidence of clip source code.
Share Improve this question edited Jan 17 at 19:12 heygsc asked Jan 17 at 18:31 heygscheygsc 1107 bronze badges 3- Can you provide an example? – kmdreko Commented Jan 17 at 19:00
- I meant can you provide a minimal reproducible example? Take one of the changes you're seeing and minimize it to only the code required to demonstrate it. Your examples are not trivial. – kmdreko Commented Jan 17 at 19:12
- It doesn't seem easy. It is known that the changes came from the examples folder, but it cannot be completely ruled out whether it was due to specific rules or the scope of the folder. Perhaps it is best to be able to clearly distinguish the difference from the command:) – heygsc Commented Jan 17 at 19:14
1 Answer
Reset to default 1From the Clippy documentation:
Clippy can automatically apply some lint suggestions, just like the compiler. Note that
--fix
implies--all-targets
, so it can fix as much code as it can.
Thus, in order to get the same behavior without --fix
, you should pass the --all-targets
option.
You should also not use the --tests
option, because that is a narrower target filter than --all-targets
— it selects all targets that are tested by default; fromthe Target Selection section of the similar cargo check
command:
Check all targets that have the
test = true
manifest flag set. By default this includes the library and binaries built as unittests, and integration tests.
Note that this set does not include examples. So, your command cargo clippy --all --tests -- -D warnings
will fail only if Clippy finds a warning or error in any of your tested-by-default targets, and all other targets, including examples, are not checked at all.
--all-targets --tests
is in practice equivalent to just --all-targets
, but the --tests
part is redundant, so you should leave it out.
本文标签:
版权声明:本文标题:rust - Difference Between `cargo clippy --all --fix --allow-dirty --allow-staged` and `cargo clippy --all --tests -- -D warnings 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745348540a2654620.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论