[WIP] Add getter prefix name lint #3616
Add a lint to detect getter methods prefixed with
The basic lint is implemented in this pull request, but there are still a couple things I'd like to add/finalize before I feel this is ready to merge. I wanted to open a pull request as soon as possible to collect and start incorporating feedback though, so this is currently a WIP.
Since this is my first contribution to Clippy, I would really appreciate your feedback! I found the
I also have a few specific items I would appreciate some guidance on:
Add a lint to detect getter methods prefixed with `get_` which do not follow the Rust convention for getter names as described in the [naming section] of the Rust API Guidelines. The `get_` prefix is not used unless there is a single and obvious thing that could be gotten by a getter, including: - `get` - `get_mut` - `get_unchecked` - `get_unchecked_mut` - `get_ref` Closes #1673. : https://rust-lang-nursery.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter
The current WIP looks good, so I'll just answer your questions.
With 5+6 answered, this lint won't trigger on
Hey @flip1995 thanks for the ping, I lost track of this with the start of the new year. I should have more time to revisit this at the end of the week.
As for 1/5/6 that's interesting! I was just running through on the basis of the function names (
Maybe I've misunderstood, but aren't associated functions the ones in the
I probably haven't implemented it to look at Trait
I'll need to verify if it lints Trait definitions, and add some more test cases to document that behaviour along with updating the doc comment.
@oli-obk any opinions on that, as you created the original issue?
Sure! With Trait impls I mean thinks like
The author of the crate which includes the Trait has influence on the names of the function names. So the Trait definition (
TL;DR: Lint on