Skip to content

Enable more clippy lints (part 3/3) - #25081

Draft
emilk wants to merge 7 commits into
apache:mainfrom
emilk:emilk/enable-more-clippy-lints-4c
Draft

Enable more clippy lints (part 3/3)#25081
emilk wants to merge 7 commits into
apache:mainfrom
emilk:emilk/enable-more-clippy-lints-4c

Conversation

@emilk

@emilk emilk commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Part 3 of 3, split out of #24848. Stacked on parts 1 and 2, so review those first:

Turn on more clippy::pedantic lints from the opt-out list in Cargo.toml.

What changes are included in this PR?

Lint Sites Fix
if_not_else 141 positive condition first, so the reader does not have to negate mentally

Mostly cargo clippy --fix. Comments that described the negated branch moved to
the branch they describe, and thirteen sites in datafusion-sql were done by
hand because one suggestion there did not type-check, which made rustfix roll
back the whole crate.

Let me know if you disagree and I'll revert it.

What is the testing strategy for this PR?

Clippy is clean both with --all-features and with default features. The
changes are mechanical, so no new tests.

Are there any user-facing changes?

No

`String::new()` instead of `"".to_string()` / `"".to_owned()` / `"".into()`,
which skips the copy-from-empty-slice path. All sites fixed by
`cargo clippy --fix`.
`Ok(())` instead of `Ok(_)` where the payload is `()`, so the pattern stops
matching silently if the type ever gains a payload.
Dropped `else` blocks after a branch that already diverges, removing one
level of indentation at each site.
Nested the or-patterns, e.g.
`Time32(Microsecond) | Time32(Nanosecond)` -> `Time32(Microsecond | Nanosecond)`,
so the shared prefix is written once.
`if`/`else` instead of `match` on a bool. Two sites cascaded into
`redundant_else`, fixed in the same commit.
Manual `Debug` impls that skip a field now end in `finish_non_exhaustive()`,
so the output says a field was omitted instead of implying the struct only
has the ones listed. `Column` keeps `finish()` under an `#[expect]`: its
`Debug` output appears verbatim in user-facing error messages.
Prefer the positive condition first: `if x { .. } else { .. }` rather than
`if !x { .. } else { .. }`, so the reader does not have to negate mentally
to follow which branch runs.

Mostly `cargo clippy --fix`. Comments that described the negated branch were
moved to the branch they actually describe, and thirteen sites in
datafusion-sql were done by hand because one suggestion in that crate did not
type-check, which made rustfix roll back the whole crate.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.26572% with 165 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.74%. Comparing base (a5c809f) to head (df9c570).

Files with missing lines Patch % Lines
datafusion/physical-expr/src/expressions/binary.rs 53.84% 6 Missing ⚠️
datafusion/datasource/src/write/orchestration.rs 28.57% 5 Missing ⚠️
datafusion/expr/src/type_coercion/functions.rs 54.54% 5 Missing ⚠️
.../src/joins/sort_merge_join/materializing_stream.rs 90.19% 0 Missing and 5 partials ⚠️
datafusion/sql/src/select.rs 86.48% 2 Missing and 3 partials ⚠️
benchmarks/src/sql_benchmark.rs 84.61% 1 Missing and 3 partials ⚠️
datafusion/common/src/datatype.rs 0.00% 4 Missing ⚠️
datafusion/common/src/scalar/mod.rs 63.63% 4 Missing ⚠️
datafusion/datasource-parquet/src/sink.rs 86.66% 2 Missing and 2 partials ⚠️
datafusion/datasource/src/memory.rs 0.00% 3 Missing and 1 partial ⚠️
... and 72 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25081      +/-   ##
==========================================
- Coverage   81.74%   81.74%   -0.01%     
==========================================
  Files        1128     1128              
  Lines      416644   416626      -18     
  Branches   416644   416626      -18     
==========================================
- Hits       340592   340570      -22     
- Misses      55995    56003       +8     
+ Partials    20057    20053       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants