Skip to content

Enable more lints - #24066

Open
emilk wants to merge 14 commits into
apache:mainfrom
emilk:emilk/workspace-lints
Open

Enable more lints#24066
emilk wants to merge 14 commits into
apache:mainfrom
emilk:emilk/workspace-lints

Conversation

@emilk

@emilk emilk commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

There are a lot of lints we can enable to, which different abilities to:

  • Simplify the code
  • Write more efficient code
  • Catch bugs
  • etc

What changes are included in this PR?

One commit per new lint (maybe easiest to review commit by commit!).

I hope to add even more lints in later PRsq

Are these changes tested?

Covered by existing tests plus the clippy CI job.

Are there any user-facing changes?

No.

@github-actions github-actions Bot added proto Related to proto crate functions Changes to functions implementation datasource Changes to the datasource crate ffi Changes to the ffi crate physical-plan Changes to the physical-plan crate labels Aug 3, 2026
@emilk
emilk marked this pull request as ready for review August 3, 2026 19:59
@github-actions github-actions Bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates core Core DataFusion crate common Related to common crate optimizer Optimizer rules spark labels Aug 3, 2026
@codecov-commenter

codecov-commenter commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.91304% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.91%. Comparing base (31ffab1) to head (d3e857a).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/datasource-arrow/src/source.rs 50.00% 0 Missing and 4 partials ⚠️
datafusion/functions-nested/src/range.rs 50.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #24066   +/-   ##
=======================================
  Coverage   80.90%   80.91%           
=======================================
  Files        1102     1102           
  Lines      376807   376798    -9     
  Branches   376807   376798    -9     
=======================================
- Hits       304874   304868    -6     
- Misses      53775    53777    +2     
+ Partials    18158    18153    -5     

☔ 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.

@2010YOUY01

Copy link
Copy Markdown
Contributor

Thank you. I suggest including only the first two commits in this PR to make it easier to verify.

For any additional rules, I think we should first confirm that they are useful, so it would be better to add them in separate PRs.

@emilk

emilk commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

I can do that - but I've tested out all these lints (and more) myself over the last couple of years in both https://github.com/rerun-io/rerun and https://github.com/emilk/egui and can vouch for their usefulness

@emilk

emilk commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Just the two first commits:

@emilk
emilk marked this pull request as draft August 4, 2026 07:31
@2010YOUY01

Copy link
Copy Markdown
Contributor

I can do that - but I've tested out all these lints (and more) myself over the last couple of years in both https://github.com/rerun-io/rerun and https://github.com/emilk/egui and can vouch for their usefulness

Splitting them into separate PRs can make them easier to review. I suggest to do the following steps

  1. chore: apply workspace lints to all crates #24076 LGTM, I'll merge it shortly
  2. Open a separate PR for commit feat: enable a batch of non-default clippy lints workspace-wide
  3. I will review the extra lint rule list later (that list is really helpful!), if there is no issue, we could do that in another PR.

pull Bot pushed a commit to TCeason/arrow-datafusion that referenced this pull request Aug 5, 2026
## Which issue does this PR close?

- Part of apache#18467
- Broken out of apache#24066
- Sibling PR: apache/arrow-rs#10533

## Rationale for this change
The workspace already has a `[workspace.lints]` table, but it was
missing from three crates

## What changes are included in this PR?
Inheriting the workspace lints in all crates, and fixing the resulting
violations

## Are these changes tested?
Yes, by existing tests and CI

## Are there any user-facing changes?
No

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
emilk and others added 9 commits August 5, 2026 09:06
All of these are already violation-free across the workspace, so this is
pure future-proofing: they only fire on newly written code.

They are a subset of the lint set used by https://github.com/emilk/egui,
picked because they trigger no (or almost no) violations in DataFusion today.

The single existing violation is a deliberate `mem::forget` in an FFI test
helper, now marked with `#[expect]`.

Part of apache#18467

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`HashTable::find_entry` takes `&mut self`; `find` does the same lookup
through `&self`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Gating the `include_str!` docs on `cfg(doc)` means touching the included
markdown no longer forces a rebuild of the crate for non-doc builds.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
emilk and others added 5 commits August 5, 2026 09:06
`SAFETY:` comments should sit next to the `unsafe` block they justify. The
existing ones either documented safe code (reworded) or were attached to the
enclosing `if` rather than the `unsafe` block (moved).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Enables the rustc lint groups and individual lints from
https://github.com/emilk/egui/blob/main/Cargo.toml that DataFusion violates
at most 10 times today:

* `future_incompatible`, `nonstandard_style`, `rust_2018_idioms` (groups)
* `rust_2021_prelude_collisions`, `semicolon_in_expressions_from_macros`,
  `unsafe_op_in_unsafe_fn`, `unused_extern_crates`, `unused_import_braces`,
  `unused_lifetimes`

`elided_lifetimes_in_paths` is part of `rust_2018_idioms` but has ~800
violations, so it is explicitly allowed for now. `trivial_numeric_casts` (31
violations) and `unsafe_code` are left out entirely.

The violations fixed here are vestigial `extern crate` items, redundant import
braces, and two `rstest` helpers whose lifetime is unused after macro expansion.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Enables the `rustdoc::all` group. Two of its lints have more than 10
violations today and are explicitly allowed for now:
`missing_crate_level_docs` (18) and `unescaped_backticks` (28).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Removing it made `libc` an unused dependency (`cargo machete` CI failure): the
crate has no path references, it is only linked so the `fesetround`/`fegetround`
symbols declared in this module resolve.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Keep the `LogicalPlanType::` prefix on the `CustomScan` match arm so it
  matches its sibling arms; drop the variant import instead.
* Restore a `SAFETY:` comment on the second `unsafe` block in `cursor.rs`.
* Drop `rustdoc::broken_intra_doc_links`, already covered by `rustdoc::all`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@emilk
emilk force-pushed the emilk/workspace-lints branch from c159311 to d3e857a Compare August 5, 2026 07:06
@emilk emilk changed the title chore: introduce a broader set of workspace clippy lints Enable more lints Aug 5, 2026
@emilk
emilk marked this pull request as ready for review August 5, 2026 07:08
@emilk

emilk commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

The first two commits have been merged to main, so I have rebased this PR now!

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

Labels

common Related to common crate core Core DataFusion crate datasource Changes to the datasource crate ffi Changes to the ffi crate functions Changes to functions implementation logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Changes to the physical-expr crates physical-plan Changes to the physical-plan crate proto Related to proto crate spark

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants