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

Some extra pedantic checks? #4655

Closed
Licenser opened this issue Oct 11, 2019 · 4 comments
Closed

Some extra pedantic checks? #4655

Licenser opened this issue Oct 11, 2019 · 4 comments
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. good-first-issue These issues are a good way to get started with Clippy T-AST Type: Requires working with the AST T-macros Type: Issues with macros and macro expansion T-middle Type: Probably requires verifiying types

Comments

@Licenser
Copy link
Contributor

Licenser commented Oct 11, 2019

Hey, I would love to add a few lints to that which are fairly super pedantic. We use them (or rather a shell script that checks for them :P) at the moment to ensure error handling/non crashy behaviour in our codebase they sum up to:

  • no unwrap
  • no unimplemented
  • no unreachable
  • no panic
  • no let _ on results.
  • no expect
  • no dbg!
  • no std::process::exit
  • no bracket access [....]

but before I go ahead I'd like to get an opinion of those would be accepted?

@flip1995
Copy link
Member

flip1995 commented Oct 11, 2019

Some of those lints already exist, most others are low hanging fruits. Have a look at the restriction lint group. For the lints that don't exist yet: Yes they would be accepted in exactly that restriction group.

Lints that already exist:


¹easy extension of unimplemented
²easy extension of unwrap lints
³should be fairly easy to implement (just a function path check)
⁴may be a bit harder to implement, dependent on how complicated it is to find out if a type is must_use


If you want to implement the other lints you're more than welcome! Have a look at https://github.com/rust-lang/rust-clippy/blob/master/doc/adding_lints.md first, and if you have any questions, don't hesitate to ask!

@flip1995 flip1995 added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. good-first-issue These issues are a good way to get started with Clippy A-lint Area: New lints T-AST Type: Requires working with the AST T-macros Type: Issues with macros and macro expansion T-middle Type: Probably requires verifiying types labels Oct 11, 2019
@Licenser
Copy link
Contributor Author

I opend #4697 for exit but I think the let _... = one is a bit too complex for me at the moment. Since all the rest is done, would it make sense to split that out into an extra, more focused, issue and close this?

@llogiq
Copy link
Contributor

llogiq commented Oct 19, 2019

We have a check for #[must_use] types in functions.rs already (IIRC is_must_use_ty(cx, ty), we best move this to utils/mod.rs), that you can call with the result of an expr_ty(cx, _) on the initializer.

flip1995 added a commit to flip1995/rust-clippy that referenced this issue Nov 7, 2019
restriction lint for `std::process::exit`

Addition to rust-lang#4655 - adds the lint checking for `std::process::exit`

changelog: add restriction lint for `std::process::exit`
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Nov 7, 2019
restriction lint for `std::process::exit`

Addition to rust-lang#4655 - adds the lint checking for `std::process::exit`

changelog: add restriction lint for `std::process::exit`
bors added a commit that referenced this issue Nov 7, 2019
restriction lint for `std::process::exit`

Addition to #4655 - adds the lint checking for `std::process::exit`

changelog: add restriction lint for `std::process::exit`
@flip1995
Copy link
Member

Since the let _ = ... lint is the only one missing in this issue, I moved it to #4812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. good-first-issue These issues are a good way to get started with Clippy T-AST Type: Requires working with the AST T-macros Type: Issues with macros and macro expansion T-middle Type: Probably requires verifiying types
Projects
None yet
Development

No branches or pull requests

3 participants