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 clippy lint dead_code #1324

Merged
merged 1 commit into from
Feb 17, 2022
Merged

Fix clippy lint dead_code #1324

merged 1 commit into from
Feb 17, 2022

Conversation

gsserge
Copy link
Contributor

@gsserge gsserge commented Feb 16, 2022

Which issue does this PR close?

Closes #1255

Rationale for this change

It's beneficial to run clippy and compiler lints as strict as possible.

What changes are included in this PR?

This PR drops #![allow(dead_code)], which is the last top level allow attribute in the arrow crate. Unfortunately, it's the most difficult one to deal with, because there's a lot of code that exists and sometimes even has tests, but it's neither pub exported nor used anywhere. I don't feel comfortable removing it (except for the obvious cases like the unused time consts), that's why I've decided to use local #[allow(dead_code)] instead. The existing code is left intact, because it might be needed in the future, while overall the linting process gets more strict.

Are there any user-facing changes?

No.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Feb 16, 2022
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping things moving forward @gsserge !

arrow/src/ipc/writer.rs Outdated Show resolved Hide resolved
@@ -97,6 +97,7 @@ pub struct Writer<W: Write> {
/// The object to write to
writer: csv_crate::Writer<W>,
/// Column delimiter. Defaults to `b','`
#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bug (not to use the delimiter option) . I think we should add a note or fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this time the delimiter is configured via the builder, but gets completely ignored

impl<W: Write> Writer<W> {
    /// Create a new CsvWriter from a writable object, with default options
    pub fn new(writer: W) -> Self {
        let delimiter = b',';
        let mut builder = csv_crate::WriterBuilder::new();
        let writer = builder.delimiter(delimiter).from_writer(writer);
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1055,6 +1056,7 @@ pub struct ReaderBuilder {
/// The default batch size when using the `ReaderBuilder` is 1024 records
batch_size: usize,
/// The bounds over which to scan the reader. `None` starts from 0 and runs until EOF.
#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it looks more like an omission in the builder. Reader::from_csv_reader() correctly processes the bounds parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsserge
Copy link
Contributor Author

gsserge commented Feb 16, 2022

Cool that enabling this lint reveals real issues, so it is actually very beneficial for everyone to be careful with allow's and use them sparingly. However, I'd prefer not to expand the scope of this PR, and fix the issues in separate PRs.

@codecov-commenter
Copy link

Codecov Report

Merging #1324 (3b07835) into master (827cc3e) will increase coverage by 0.02%.
The diff coverage is 100.00%.

❗ Current head 3b07835 differs from pull request most recent head f8d90fd. Consider uploading reports for the commit f8d90fd to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1324      +/-   ##
==========================================
+ Coverage   83.00%   83.03%   +0.02%     
==========================================
  Files         180      180              
  Lines       52919    52919              
==========================================
+ Hits        43924    43939      +15     
+ Misses       8995     8980      -15     
Impacted Files Coverage Δ
arrow/src/array/array_dictionary.rs 91.89% <ø> (+3.60%) ⬆️
arrow/src/array/array_primitive.rs 94.69% <ø> (ø)
arrow/src/array/builder.rs 86.73% <ø> (ø)
arrow/src/array/data.rs 83.30% <ø> (ø)
arrow/src/array/transform/mod.rs 84.65% <ø> (+0.26%) ⬆️
arrow/src/compute/util.rs 98.90% <ø> (ø)
arrow/src/csv/reader.rs 88.12% <ø> (ø)
arrow/src/csv/writer.rs 72.13% <ø> (ø)
arrow/src/ffi.rs 84.53% <ø> (ø)
arrow/src/ipc/writer.rs 83.45% <ø> (-0.04%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 827cc3e...f8d90fd. Read the comment docs.

@alamb
Copy link
Contributor

alamb commented Feb 17, 2022

Cool that enabling this lint reveals real issues, so it is actually very beneficial for everyone to be careful with allow's and use them sparingly. However, I'd prefer not to expand the scope of this PR, and fix the issues in separate PRs.

I think this is a great strategy. Thank you @gsserge for filing the follow on issues

@@ -536,6 +536,7 @@ mod tests {
assert!(iter.next().is_none());
}

#[test]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice fix

@@ -107,6 +108,7 @@ pub struct Writer<W: Write> {
/// The timestamp format for timestamp arrays
timestamp_format: String,
/// The timestamp format for timestamp (with timezone) arrays
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi @sum12

@alamb alamb changed the title Enable dead_code lint Fix clippy lint dead_code Feb 17, 2022
@alamb alamb merged commit 9870533 into apache:master Feb 17, 2022
@alamb
Copy link
Contributor

alamb commented Feb 17, 2022

Here is a PR that removes some more of this discovered dead code: #1331

@gsserge gsserge deleted the dead_code branch February 17, 2022 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix all clippy lints in arrow crate
4 participants