-
Notifications
You must be signed in to change notification settings - Fork 565
treewide: further tighten clippy lints #7493
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
treewide: further tighten clippy lints #7493
Conversation
e834007 to
0a578c2
Compare
Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
0a578c2 to
ce3cc6c
Compare
|
@rbradford @likebreath I thoroughly went through all the |
f9e6b8f to
b749ca9
Compare
This removes cognitive load when reading if statements. All changes were applied by clippy via `--fix`. Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
This helps to uncover expensive and needless clones in the code base. For example, I prevented extensive clones in the snapshot path where (nested) BTreeMap's have been cloned over and over again. Further, the lint helps devs to much better reason about the ownership of parameters. All of these changes have been done manually with the necessary caution. A few structs that are cheap to clone are now `copy` so that this lint won't trigger for them. I didn't enable the lint so far as it is a massive rabbit hole and needs much more fixes. Nevertheless, it is very useful. Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
b749ca9 to
048cfd2
Compare
rbradford
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these changes move the code base to more idiomatic Rust which is probably a good thing! (Even though I often need to double check what these clever functional programming style methods do!.)
Follow-up of #7483 and currently my last effort regarding clippy lints to improve developer experience and code quality. We now reached a point where the low-hanging fruits are harvested and the world of rabbit-holes begin.
I actively decided against lints
missing_const_for_fn,must_use_candidate, andmissing_panics_doc. The first two are very invasive with little benefit for CHV. They might make sense in finer-grained scopes (i.e., not treewide).missing_panics_docis helpful but very invasive and I didn't want to spend the time so far on that. Further, as we are shipping a binary rather than a (Set of) librarie(s), it is okay to not have that.Explanation for the lints I've selected (IMHO):
map_unwrap_orimprove code readabilityredundant_elseimproves code readabilityif_not_elsereduces cognitive complexity/mental load when reading codeneedless_pass_by_valueuncovers costly clones and makes it easier to reason about ownership of variablesHints for Reviewers
#7489