Skip to content

lint: enable unused_qualifications workspace-wide#783

Merged
strawgate merged 2 commits into
masterfrom
lint-unused-qualifications-workspace-wide-78d63757-8720157761045900515
Apr 3, 2026
Merged

lint: enable unused_qualifications workspace-wide#783
strawgate merged 2 commits into
masterfrom
lint-unused-qualifications-workspace-wide-78d63757-8720157761045900515

Conversation

@strawgate
Copy link
Copy Markdown
Owner

This PR enables the unused_qualifications lint at the workspace level and applies automated fixes using cargo clippy --fix. This reduces code noise by removing redundant fully-qualified paths (e.g., std::io::Error when Error is already in scope).

Steps taken:

  1. Ran RUSTC_WRAPPER="" cargo clippy --fix --allow-dirty --all-targets -- -W unused_qualifications to apply fixes.
  2. Verified that all warnings were resolved with RUSTC_WRAPPER="" cargo clippy --all-targets -- -D warnings.
  3. Added unused_qualifications = "warn" to [workspace.lints.rust] in Cargo.toml.
  4. Verified that the workspace still compiles and passes clippy with the new lint enabled.
  5. Ran cargo test --lib --bins to ensure no regressions were introduced.

Fixes #762


PR created automatically by Jules for task 8720157761045900515 started by @strawgate

- Enable `unused_qualifications = "warn"` in `[workspace.lints.rust]` in the root `Cargo.toml`.
- Run `cargo clippy --fix` to resolve redundant fully-qualified paths and other stylistic warnings across the workspace.
- Affected crates: logfwd, logfwd-arrow, logfwd-bench, logfwd-competitive-bench, logfwd-config, logfwd-core, logfwd-io, logfwd-output, logfwd-transform.

Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 3, 2026

Walkthrough

This PR enables the unused_qualifications lint rule in the workspace configuration and applies automated fixes across approximately 38 violation sites in 9 crates. The changes eliminate redundant fully-qualified type and function paths where shorter in-scope names are already available via existing use imports (e.g., std::io::ErrorError when io is imported). Additional formatting adjustments include simplifying raw string literals, streamlining async method signatures, and updating iteration patterns. All changes are code-quality refactors with no runtime behavior modifications.

Possibly related PRs


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
High-Quality Rust Practices ❌ Error PR introduces compilation errors by changing sonic-rs object iteration from .iter() to for loop syntax, which sonic-rs 0.5.8 does not support for borrowed references. Revert sonic-rs iteration changes in scanner_conformance.rs and benches/scanner.rs back to .iter() or use sonic_rs::to_object_iter_unchecked(). Verify with cargo build --tests --benches --all.
Maintainer Fitness ⚠️ Warning PR description lacks test output evidence, fails to address generator.rs review concern about inconsistent error handling, and provides no validation of sonic-rs 0.5.0 compatibility. Add actual test output (e.g., test count/pass rate), explicitly address generator.rs if/panic inconsistency, and confirm sonic-rs iteration compatibility or revert.
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed All code changes successfully remove redundant fully-qualified paths and enable the unused_qualifications lint as specified in issue #762.
Out of Scope Changes check ✅ Passed All changes are directly related to eliminating unused qualifications and enabling the workspace lint. No unrelated modifications detected.
Formal Verification Coverage ✅ Passed PR adds no new public functions, makes no logic/state changes, and requires no TLA+ updates. Purely stylistic cleanup of redundant path qualifications. VERIFICATION.md appropriately added.
Documentation Thoroughly Updated ✅ Passed PR enables Clippy lint with auto-fixes; no behavioral changes, public APIs, config fields, pipeline participants, crate boundaries, or verification status changes. None of the documented updates are applicable.
Crate Boundary And Dependency Integrity ✅ Passed PR maintains all crate boundaries and dependency integrity with only import qualification removals and formatting adjustments from cargo clippy --fix.

Comment @coderabbitai help to get the list of available commands and usage tips.

- Enable `unused_qualifications = "warn"` in `[workspace.lints.rust]` in the root `Cargo.toml`.
- Run `cargo clippy --fix` to resolve redundant fully-qualified paths and other stylistic warnings across the workspace.
- Run `cargo fmt --all` to ensure the workspace-wide changes adhere to the project's formatting standards.
- Affected crates: logfwd, logfwd-arrow, logfwd-bench, logfwd-competitive-bench, logfwd-config, logfwd-core, logfwd-io, logfwd-output, logfwd-transform.

Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/logfwd-core/tests/scanner_conformance.rs`:
- Line 87: The loop changed to "for (key_str, val) in obj" which fails with
sonic-rs 0.5.0 because Object does not implement IntoIterator for &Object;
revert to iterating via the provided method by using obj.iter() in the loop
header (i.e., change the loop in scanner_conformance.rs that currently uses "for
(key_str, val) in obj" back to using "for (key_str, val) in obj.iter()" so it
compiles with sonic-rs 0.5.0).

In `@crates/logfwd-io/src/generator.rs`:
- Around line 437-440: The test silently ignores non-Data InputEvent variants;
replace the `if let InputEvent::Data { bytes } = event { ... }` with explicit
handling so unexpected variants fail clearly — either use a `match event {
InputEvent::Data { bytes } => { /* existing logic updating total_lines */ },
other => panic!("expected Data event, got {:?}", other) }` or add a short
comment asserting the GeneratorInput invariant; reference the `InputEvent::Data`
pattern, the `event` variable, `GeneratorInput`, and the `total_lines` update
when locating the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: a88d9cce-254a-4ae3-91df-746cfc716938

📥 Commits

Reviewing files that changed from the base of the PR and between 0635dc2 and a2d07cd.

📒 Files selected for processing (40)
  • Cargo.toml
  • crates/logfwd-arrow/src/streaming_builder.rs
  • crates/logfwd-arrow/tests/allocation_regression.rs
  • crates/logfwd-bench/benches/elasticsearch_arrow.rs
  • crates/logfwd-bench/benches/pipeline.rs
  • crates/logfwd-competitive-bench/src/main.rs
  • crates/logfwd-competitive-bench/src/rate_bench.rs
  • crates/logfwd-competitive-bench/src/runner.rs
  • crates/logfwd-config/src/lib.rs
  • crates/logfwd-core/benches/scanner.rs
  • crates/logfwd-core/examples/arrow_ipc_roundtrip.rs
  • crates/logfwd-core/src/json_scanner.rs
  • crates/logfwd-core/src/pipeline/lifecycle.rs
  • crates/logfwd-core/tests/compliance_data.rs
  • crates/logfwd-core/tests/scanner_conformance.rs
  • crates/logfwd-io/src/diagnostics.rs
  • crates/logfwd-io/src/enrichment.rs
  • crates/logfwd-io/src/generator.rs
  • crates/logfwd-io/src/metric_history.rs
  • crates/logfwd-io/src/otlp_receiver.rs
  • crates/logfwd-io/src/span_exporter.rs
  • crates/logfwd-io/src/tail.rs
  • crates/logfwd-io/src/tcp_input.rs
  • crates/logfwd-io/tests/transport_e2e.rs
  • crates/logfwd-output/src/elasticsearch.rs
  • crates/logfwd-output/src/lib.rs
  • crates/logfwd-output/src/loki.rs
  • crates/logfwd-output/src/null.rs
  • crates/logfwd-output/src/otlp_sink.rs
  • crates/logfwd-output/tests/elasticsearch_arrow_ipc.rs
  • crates/logfwd-transform/src/lib.rs
  • crates/logfwd-transform/src/udf/grok.rs
  • crates/logfwd/src/main.rs
  • crates/logfwd/src/pipeline.rs
  • crates/logfwd/src/worker_pool.rs
  • crates/logfwd/tests/allocation_e2e.rs
  • crates/logfwd/tests/allocation_scaling.rs
  • crates/logfwd/tests/compliance.rs
  • crates/logfwd/tests/compliance_file.rs
  • crates/logfwd/tests/integration.rs

// Check each field from the sonic-rs parse
let mut seen_keys = std::collections::HashSet::new();
for (key_str, val) in obj.iter() {
for (key_str, val) in obj {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify sonic-rs Object supports direct iteration with same semantics as .iter()
rg -A 10 'impl.*IntoIterator.*for.*Object' --type rust

Repository: strawgate/memagent

Length of output: 44


🌐 Web query:

Does sonic-rs 0.5.0 Object type implement IntoIterator for &Object, and does iterating directly produce the same iterator as calling .iter()?

💡 Result:

No, the sonic-rs 0.5.0 Object type does not implement IntoIterator for &Object. There is a value::object::Iter type listed in the crate documentation, suggesting iteration is provided via an .iter method (similar to standard Rust collections), but no explicit evidence of IntoIterator impl for &Object. Direct iteration (for obj in &object {...}) would not work without that impl, and thus would not produce the same iterator as .iter. The presence of value::object::Iter and value::array::IntoIter (noted separately for arrays) supports that Object follows the pattern of providing .iter returning Iter, without blanket IntoIterator for &T.

Citations:


Revert iteration style: sonic-rs 0.5.0 Object does not implement IntoIterator for &Object.

The change from obj.iter() to direct iteration (for (key_str, val) in obj) is incompatible with sonic-rs 0.5.0. The Object type provides iteration only via the .iter() method, not through IntoIterator for borrowed references. This change will fail to compile.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/logfwd-core/tests/scanner_conformance.rs` at line 87, The loop changed
to "for (key_str, val) in obj" which fails with sonic-rs 0.5.0 because Object
does not implement IntoIterator for &Object; revert to iterating via the
provided method by using obj.iter() in the loop header (i.e., change the loop in
scanner_conformance.rs that currently uses "for (key_str, val) in obj" back to
using "for (key_str, val) in obj.iter()" so it compiles with sonic-rs 0.5.0).

Comment on lines +437 to 440
if let InputEvent::Data { bytes } = event {
let text = String::from_utf8_lossy(bytes);
total_lines += text.trim().lines().count() as u64;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider explicit handling of unexpected event types for test robustness.

The if let pattern silently ignores Rotated and Truncated events. While GeneratorInput only emits Data events by design, other tests in this file use explicit else { panic!("expected Data event") } branches (lines 212, 249) for clarity and early failure. This test would still catch issues (via the assertion at line 444) but with a less informative error message.

🛡️ Proposed fix for explicit event type checking
                 if let InputEvent::Data { bytes } = event {
                     let text = String::from_utf8_lossy(bytes);
                     total_lines += text.trim().lines().count() as u64;
+                } else {
+                    panic!("GeneratorInput must only emit Data events, got {event:?}");
                 }

Alternatively, add a comment explaining the invariant:

+                // GeneratorInput only emits Data events by design (see poll() line 186)
                 if let InputEvent::Data { bytes } = event {
                     let text = String::from_utf8_lossy(bytes);
                     total_lines += text.trim().lines().count() as u64;
                 }

Based on learnings: The relevant code snippet notes that although GeneratorInput never emits Rotated/Truncated variants, the if let pattern is fragile to future changes in InputEvent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/logfwd-io/src/generator.rs` around lines 437 - 440, The test silently
ignores non-Data InputEvent variants; replace the `if let InputEvent::Data {
bytes } = event { ... }` with explicit handling so unexpected variants fail
clearly — either use a `match event { InputEvent::Data { bytes } => { /*
existing logic updating total_lines */ }, other => panic!("expected Data event,
got {:?}", other) }` or add a short comment asserting the GeneratorInput
invariant; reference the `InputEvent::Data` pattern, the `event` variable,
`GeneratorInput`, and the `total_lines` update when locating the change.

@strawgate
Copy link
Copy Markdown
Owner Author

Reviewed: mechanical clippy --fix for unused_qualifications. All changes are removing redundant qualifiers, raw string literals, and static ref borrows. CI fully green. Ready to merge.

@strawgate strawgate merged commit 41f1ae3 into master Apr 3, 2026
8 of 9 checks passed
@strawgate strawgate deleted the lint-unused-qualifications-workspace-wide-78d63757-8720157761045900515 branch April 3, 2026 03:24
@google-labs-jules
Copy link
Copy Markdown
Contributor

Reviewed: mechanical clippy --fix for unused_qualifications. All changes are removing redundant qualifiers, raw string literals, and static ref borrows. CI fully green. Ready to merge.

Acknowledged. Thank you for the review.

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.

lint: enable unused_qualifications workspace-wide

1 participant