Clippy lints#6464
Conversation
|
Oh one thing I was unsure about: I put the |
|
Also, bear in mind that the line count includes several added detailed comments. I'm fairly certain that overall this PR removes lines of code or is very close to neutral. |
|
Thank you @LouisGariepy -- I plan to review this carefully tomorrow or Tuesday if no one beats me to it |
This fixes the doc build error in CI and seems more appropriate.
alamb
left a comment
There was a problem hiding this comment.
Thank you very much @LouisGariepy - I went through this PR carefully and I think it is a really nice cleanup and thus plan to merge it in.
I had some comments that might improve the code more, but I think this PR as it is is a great step forward and we can address the other items as follow on PRs.
Again, thank you for helping keep the codebase cleaner 🦾
| // TODO(clippy): The clippy `allow` could be removed by renaming this method to `next_batch`. | ||
| // This would also make the intent of the method clearer. | ||
| // | ||
| // Another option could be to rework `AvroArrowArrayReader::next_batch` so it returns an |
There was a problem hiding this comment.
I think this second option would be my preference
|
|
||
| // "YES if the column is possibly nullable, NO if it is known not nullable. " | ||
| let nullable_str = if is_nullable { "YES" } else { "NO" }; | ||
| let nullable_str = if field.is_nullable() { "YES" } else { "NO" }; |
| //! This module contains interfaces and default implementations | ||
| //! of table namespacing concepts, including catalogs and schemas. | ||
|
|
||
| // TODO(clippy): Having a `datasource::datasource` module path is unclear and ambiguous. |
| { | ||
| let left_changed = Arc::ptr_eq(left, &right_exec); | ||
| let right_changed = Arc::ptr_eq(right, &left_exec); | ||
| let left_changed = Arc::data_ptr_eq(left, &right_exec); |
There was a problem hiding this comment.
I like the fact that you have moved the (potentially dubious) pointer comparisons into a trait that has much better documentation about rationale. 🙏 thank you
| baseline_metrics, | ||
| context, | ||
| partition, | ||
| self, context, partition, |
There was a problem hiding this comment.
this certainly looks much nicer 😍
| }; | ||
| use std::sync::Arc; | ||
|
|
||
| struct PrimitiveTypeField<'a> { |
| use std::sync::Arc; | ||
|
|
||
| struct PrimitiveTypeField<'a> { | ||
| name: &'a str, |
There was a problem hiding this comment.
I don't think it is important but given that name seems to always be a constant string, you could do something like
| name: &'a str, | |
| name: &'static str, |
And avoid having to have the named lifetime 'a on this struct
| None, | ||
| )]); | ||
| let schema_descr = get_test_schema_descr(vec![PrimitiveTypeField { | ||
| name: "c1", |
There was a problem hiding this comment.
I am a big fan of explicit field names as a way to better document what is going on here.
| PrimitiveTypeField { | ||
| name: "c1", | ||
| physical_ty: PhysicalType::INT32, | ||
| logical_ty: None, | ||
| precision: None, | ||
| scale: None, | ||
| byte_len: None, | ||
| }, |
There was a problem hiding this comment.
When I was reading this, I was thinking these tests might be even more readable if they had a builder style, something like
PrimtiveTypeField::new("c1", PhysicalType::INT32)And then for tests that need other optional fields set:
PrimtiveTypeField::new("c1", PhysicalType::INT32)
.with_logical_type(LogicalType::Decimal {
scale: 0,
precision: 9,
});
| // TODO(clippy): This should probably be renamed to use a `with_*` prefix. Something | ||
| // like `with_template`, or `with_exprs_and_inputs`. | ||
| // | ||
| // Also, I think `ExtensionPlanNode` has been renamed to `UserDefinedLogicalNode` |
|
@alamb Thank you for the review 😃. I implemented your suggestions and fixed a typo that slipped in. Just to be sure, regarding the |
I think a separate one is better -- I don't see any reason to hold up the changes in this PR for technically unrelated other changes. THanks again @LouisGariepy |
| physical_ty: PhysicalType::INT32, | ||
| logical_ty: Some(LogicalType::Decimal { | ||
|
|
||
| let field = PrimitiveTypeField::new("c1", PhysicalType::INT32) |
Which issue does this PR close?
Closes #207.
Rationale for this change
This PR fixes most of the remaining clippy
allows remaining in the code base.Clippy
allows sometimes silence actually useful lints. Even if the lint was not useful at some point, it's easy to forget about them even after the code has been fixed.For these reasons it's good practice to clean them up once in a while.
What changes are included in this PR?
The bulk of the changes is simply removing
allowsthe were not needed at all.Some changes are slightly more involved, but should still be pretty localized and self-explanatory.
Are these changes tested?
This PR does not (and should not) introduce new features or modify existing features. Thus, existing test coverage should be sufficient.
I added one test to for the code I added for data pointer equality (related to the removal of vtable address comparison lints
Are there any user-facing changes?
No(*) (see the Notes section below)
Notes
All of the committed fixes are fairly straightforward and uncontroversial.
Some fixes would be breaking(*) or require maintainer input to get right. I documented these cases with
TODO(clippy)and gave ample details and potential solutions. I would appreciate if the reviewer could pay special attention to these so we can decide which ones should be fixed as part of this PR, which ones should be fixed as part of a separate PR, and which ones should not be fixed at all.The remaining
allows are all too many arguments lints whose fixes are not straightforward and might require some more in-depth redesign. I'm proposing to leave them as is for now and fix them on a case-by-case basis as solutions become more evident. I did not mark these withTODO(clippy)as I can't suggest solutions for them without some more careful examination. I will try to get to them in due time, in one or more future PRs.