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

Fix all clippy lints in parquet crate #1254

Closed
alamb opened this issue Feb 1, 2022 · 8 comments · Fixed by #2377
Closed

Fix all clippy lints in parquet crate #1254

alamb opened this issue Feb 1, 2022 · 8 comments · Fixed by #2377
Labels
bug good first issue Good for newcomers parquet Changes to the parquet crate

Comments

@alamb
Copy link
Contributor

alamb commented Feb 1, 2022

Describe the bug
Due to "historical reasons" there are several clippy lints that are disabled in the parquet crate
https://github.com/apache/arrow-rs/blob/master/parquet/src/lib.rs#L18-L36

#![allow(incomplete_features)]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(
    clippy::approx_constant,
    clippy::cast_ptr_alignment,
    clippy::float_cmp,
    clippy::float_equality_without_abs,
    clippy::from_over_into,
    clippy::many_single_char_names,
    clippy::needless_range_loop,
    clippy::new_without_default,
    clippy::or_fun_call,
    clippy::same_item_push,
    clippy::too_many_arguments,
    clippy::transmute_ptr_to_ptr,
    clippy::upper_case_acronyms,
    clippy::vec_init_then_push
)]

It would be great to clean up the code to pass these lints for tidiness

To Reproduce
Remove one of the #[allow] lines above, run clippy

Expected behavior
Clippy runs cleanly without blank #allow across the whole crate

Additional context
Add any other context about the problem here.

@alamb alamb added good first issue Good for newcomers bug parquet Changes to the parquet crate labels Feb 1, 2022
@HaoYang670
Copy link
Contributor

I'd like to have a try if no one else has been doing it!
Rust Clippy is really interesting!

@HaoYang670
Copy link
Contributor

There are many dead code and unused public functions. I am not sure whether to clean them up.

@alamb
Copy link
Contributor Author

alamb commented Feb 4, 2022

There are many dead code and unused public functions. I am not sure whether to clean them up.

I recommend doing this issue in a few PRs -- in the first take care of the easier lints, and then in follow ons we can sort out dead code / public function nonsense together

@HaoYang670
Copy link
Contributor

Lots of pub members are detected as dead code. I am not sure whether to clean them up. For example:

warning: enum is never used: `LevelDecoder`
   --> parquet/src/encodings/levels.rs:151:10
    |
151 | pub enum LevelDecoder {
    |          ^^^^^^^^^^^^

warning: associated function is never used: `v1`
   --> parquet/src/encodings/levels.rs:165:12
    |
165 |     pub fn v1(encoding: Encoding, max_level: i16) -> Self {
    |            ^^

warning: associated function is never used: `v2`
   --> parquet/src/encodings/levels.rs:180:12
    |
180 |     pub fn v2(max_level: i16) -> Self {
    |            ^^

warning: associated function is never used: `set_data`
   --> parquet/src/encodings/levels.rs:194:12
    |
194 |     pub fn set_data(&mut self, num_buffered_values: usize, data: ByteBufferPtr) -> usize {
    |            ^^^^^^^^

warning: associated function is never used: `set_data_range`
   --> parquet/src/encodings/levels.rs:221:12
    |
221 |     pub fn set_data_range(
    |            ^^^^^^^^^^^^^^

warning: associated function is never used: `is_data_set`
   --> parquet/src/encodings/levels.rs:242:12
    |
242 |     pub fn is_data_set(&self) -> bool {
    |            ^^^^^^^^^^^

warning: associated function is never used: `get`
   --> parquet/src/encodings/levels.rs:254:12
    |
254 |     pub fn get(&mut self, buffer: &mut [i16]) -> Result<usize> {
    |            ^^^

warning: associated function is never used: `buffer`
   --> parquet/src/encodings/rle.rs:171:12
    |
171 |     pub fn buffer(&self) -> &[u8] {
    |            ^^^^^^

warning: associated function is never used: `get`
   --> parquet/src/encodings/rle.rs:358:12
    |
358 |     pub fn get<T: FromBytes>(&mut self) -> Result<Option<T>> {

@alamb
Copy link
Contributor Author

alamb commented Feb 28, 2022

Sorry for the late reply @HaoYang670

Lots of pub members are detected as dead code. I am not sure whether to clean them up. For example:

If the code is dead I think we should remove it. One way for pub functions to be dead is if the module they are defined in is not pub.

I am not sure how you are running clippy, but it may also be that some of these structs are only used when certain features of the parquet crate are enabled.

I believe our CI system has good coverage so feel free to try removing them and if the CI passes I think it is a good change

@HaoYang670
Copy link
Contributor

HaoYang670 commented Mar 3, 2022

but it may also be that some of these structs are only used when certain features of the parquet crate are enabled.

Thank you @alamb. There are some experimental mods under parquet. And I have to run cargo clippy --features experimental to make them public. But I am not sure whether our CI adds this flag.

@alamb
Copy link
Contributor Author

alamb commented Mar 3, 2022

Clippy is run like this:

https://github.com/apache/arrow-rs/blob/master/.github/workflows/rust.yml#L211-L250

          cargo clippy --features test_common --features prettyprint  --features=async --all-targets --workspace -- -D warnings

Perhaps we can also add the experimental features to this list?

@alamb
Copy link
Contributor Author

alamb commented Jul 27, 2022

After #2190 clippy is run just for the parquet crate (which now includes the --experimental flag)

So once that is merged, the first order of business will be to make this command run cleanly:

cargo clippy -p parquet --all-targets --all-features -- -D warnings

And then we can move on to removing the additional lints

tustvold added a commit to tustvold/arrow-rs that referenced this issue Aug 8, 2022
tustvold added a commit that referenced this issue Aug 8, 2022
* Fix parquet clippy lints (#1254)

* Fix MapArrayReader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Good for newcomers parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants