Skip to content

Fix workspace clippy lints#4617

Draft
Abeeujah wants to merge 4 commits into
lightningdevkit:mainfrom
Abeeujah:pedantic
Draft

Fix workspace clippy lints#4617
Abeeujah wants to merge 4 commits into
lightningdevkit:mainfrom
Abeeujah:pedantic

Conversation

@Abeeujah
Copy link
Copy Markdown
Contributor

Running cargo clippy --all-features --all-targets --locked -- -D warnings triggers common places code could be improved. This PR fixes the lightning-macros and lightning-invoice crate.

Abeeujah added 4 commits May 18, 2026 14:49
- Use rust's Doc comment preferred 4 spaces over tabs.
- Use `nth` iterator method instead of combining `skip` and `next`.
- Remove needless borrows.
- Collapse collapsible if expression.
- Use Rust's Doc comments preferred 4 spaces over tabs.
- Properly indent list items in Rust Doc comments.
- Use `Option` API methods correctly, e.g., `map().flatten()` to `flat_map()`.
- Use `matches!` macro for match semantics that evals to bool.
- Remove needless borrowing.
- Remove needless closures.
- Use `u64::MAX` over `u64::max_value()`.
- Allow type complexity for `FilterMap`.
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented May 18, 2026

👋 I see @wpaulino was un-assigned.
If you'd like another reviewer assignment, please click here.

/// Returns an iterator over all tagged fields with known semantics.
///
/// This is not exported to bindings users as there is not yet a manual mapping for a FilterMap
#[allow(clippy::type_complexity)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This #[allow(clippy::type_complexity)] is redundant — ci/check-lint.sh already globally suppresses clippy::type_complexity with -A clippy::type_complexity (line 99). Adding per-function #[allow] attributes just adds noise without any effect under the project's CI configuration.

@ldk-claude-review-bot
Copy link
Copy Markdown
Collaborator

Review Summary

Every clippy lint fixed in this PR is already suppressed in ci/check-lint.sh. The author ran cargo clippy -- -D warnings without the project's standard allow flags, so all these warnings appeared — but under the actual CI configuration, none of these lints are enforced.

Cross-referencing each change against ci/check-lint.sh:

Change Clippy lint CI line
Doc comment tabs → spaces tabs_in_doc_comments line 95
#[allow(clippy::type_complexity)] additions type_complexity line 99
.map(|tf| Ctor(tf)).map(Ctor) redundant_closure line 83
match { => true, _ => false }matches!() match_like_matches_macro line 61
.map().flatten().flat_map() / .and_then() map_flatten line 60
&vecvec, &chunkchunk, etc. needless_borrow line 66
u64::max_value()u64::MAX legacy_numeric_constants line 47
.skip(2).next().nth(2) iter_skip_next line 45
Nested if → combined condition collapsible_if line 29

None of these changes affect CI pass/fail. The individual transformations are logically correct (no bugs introduced), but they create unnecessary code churn — particularly the doc comment whitespace changes which touch many lines across multiple files.

Inline comments posted:

  • lightning-invoice/src/lib.rs:1144#[allow(clippy::type_complexity)] is redundant since the lint is already globally suppressed in CI

Cross-cutting concern: If the goal is to clean up these lints, the proper approach would be to fix ALL instances of a given lint workspace-wide, then remove the corresponding -A clippy::... entry from ci/check-lint.sh so the lint is enforced going forward. Partially fixing suppressed lints in a few crates doesn't improve CI coverage and risks merge conflicts with other in-flight work.

@ldk-reviews-bot ldk-reviews-bot requested a review from wpaulino May 18, 2026 15:03
@Abeeujah Abeeujah marked this pull request as draft May 18, 2026 15:08
@TheBlueMatt
Copy link
Copy Markdown
Collaborator

I mean, sure, seems fine to fix modulo claude's above comment.

@TheBlueMatt TheBlueMatt removed the request for review from wpaulino May 18, 2026 15:26
@Abeeujah
Copy link
Copy Markdown
Contributor Author

If the goal is to clean up these lints, the proper approach would be to fix ALL instances of a given lint workspace-wide, then remove the corresponding -A clippy::... entry from ci/check-lint.sh so the lint is enforced going forward.

I mean, sure, seems fine to fix modulo claude's above comment.

The goal is to clean up workspace-wide, but in lightning crate alone:

warning: `lightning` (lib) generated 1951 warnings (123 duplicates)
error: could not compile `lightning` (lib) due to 5 previous errors; 1951 warnings emitted

Before investing effort into that, I think it would be important to know if these lints were supressed intentionally for DX?

@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

❌ Patch coverage is 78.26087% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.43%. Comparing base (71fdc27) to head (2932ee7).

Files with missing lines Patch % Lines
lightning-invoice/src/lib.rs 78.57% 2 Missing and 1 partial ⚠️
lightning-types/src/features.rs 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4617      +/-   ##
==========================================
- Coverage   86.44%   86.43%   -0.02%     
==========================================
  Files         159      159              
  Lines      109823   109803      -20     
  Branches   109823   109803      -20     
==========================================
- Hits        94941    94903      -38     
- Misses      12340    12356      +16     
- Partials     2542     2544       +2     
Flag Coverage Δ
fuzzing-fake-hashes 5.08% <0.00%> (+<0.01%) ⬆️
fuzzing-real-hashes 22.78% <0.00%> (+<0.01%) ⬆️
tests 86.16% <78.26%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@TheBlueMatt
Copy link
Copy Markdown
Collaborator

There's a few that were suppressed cause clippy is outright wrong, but most of them are because clippy wasn't run until way after this repo existed and most clippy lints aren't really worth fixing. I don't think it makes sense to go through the repo and fix 1951 places where clippy is complaining about whitespace (or other unimportant issues). There's probably some individual lints that are worth fixing, but I haven't looked in a while at what we're ignoring that might be worth it.

@Abeeujah
Copy link
Copy Markdown
Contributor Author

There's a few that were suppressed cause clippy is outright wrong

Seen those, wouldn't be bothering with that.

I don't think it makes sense to go through the repo and fix 1951 places where clippy is complaining about whitespace (or other unimportant issues).

I wouldn't be prioritizing these, but the goal here, is it helps me grok the codebase, while also improving what's could be improved upon.

There's probably some individual lints that are worth fixing, but I haven't looked in a while at what we're ignoring that might be worth it.

Yeah, going through the allowed lints, there's a couple cases worth fixing that could impact performance and code quality. would start from those.

@TheBlueMatt Please I tried pinging you on Discord (Abeeujah).

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.

4 participants