Skip to content
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

consider passing --cfg test by default #1436

Closed
oli-obk opened this issue Jan 11, 2017 · 6 comments
Closed

consider passing --cfg test by default #1436

oli-obk opened this issue Jan 11, 2017 · 6 comments
Labels
S-needs-discussion Status: Needs further discussion before merging or work can be started

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Jan 11, 2017

Posted by @durka in arcnmx/cargo-clippy#12

Regular cargo clippy doesn't check #[test] functions because it can't (the code is gone by the time the lints run). But if you do cargo clippy -- --cfg test it works. I wonder if there are any downsides to making this the default behavior.

I guess this breaks people who have #[cfg(not(test))] on things. But perhaps cargo-clippy can support a --test flag which would be a bit shorter than -- --cfg test.

@oli-obk oli-obk added the S-needs-discussion Status: Needs further discussion before merging or work can be started label Jan 11, 2017
@llogiq
Copy link
Contributor

llogiq commented Jan 11, 2017

I think test code needs not by necessity follow the same strict guidelines that clippy requires of other code. On the other hand there is certainly value in having clippy check tests, too, so I wouldn't rule it out.

The best way would be to somehow run both with and without --cfg test, collect the reports and quell duplicates before output. This would also reduce duplicates due to the library/binary divide.

@mathstuf
Copy link
Contributor

mathstuf commented Nov 8, 2017

Note that -- --cfg test fails if there are dev-dependencies since they aren't available with just the flag.

@kurnevsky
Copy link

It seems there is no good way to run clippy on tests anymore? Compiler plugin is deprecated and --cfg test won't work with dev-dependencies.

@elichai
Copy link
Contributor

elichai commented Nov 13, 2018

Are there any news about this?
I don't think it should be enabled by default but I do thing that --cfg test should use dev-dependencies

@ghost
Copy link

ghost commented Feb 9, 2019

Try invoking clippy as cargo clippy --tests.

@mathstuf
Copy link
Contributor

@oli-obk This can be closed now I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-discussion Status: Needs further discussion before merging or work can be started
Projects
None yet
Development

No branches or pull requests

5 participants