Skip to content

fix clippy warnings#580

Merged
BusyJay merged 1 commit intotikv:masterfrom
ggirol-rc:fix_clippy
Feb 26, 2026
Merged

fix clippy warnings#580
BusyJay merged 1 commit intotikv:masterfrom
ggirol-rc:fix_clippy

Conversation

@ggirol-rc
Copy link
Contributor

@ggirol-rc ggirol-rc commented Feb 26, 2026

generated by

cargo clippy --all --all-targets --fix

Summary by CodeRabbit

  • Style
    • Standardized user-facing and diagnostic message formatting across the codebase to use consistent interpolation, improving readability of logs and error text.
  • Tests
    • Updated test output formatting for clearer and more consistent failure messages; no behavioral changes.

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

This diff replaces positional format placeholders with named placeholders across benchmarks, examples, tests, build scripts, and core source files; no logic, control flow, or public APIs were modified.

Changes

Cohort / File(s) Summary
Benchmarks & Examples
benches/suites/raft.rs, examples/five_mem_node/main.rs
Benchmark labels and example payload formatting changed from positional to named placeholders.
Build & Proto
proto/build.rs, proto/src/confchange.rs
Path and error-message string formatting updated to use named placeholders; behavior unchanged.
Config & Confchange
src/config.rs, src/confchange/changer.rs, src/confchange/datadriven_test.rs
Validation and confchange error/writeln! messages switched to named interpolation.
Core Raft & Quorum
src/raft.rs, src/raft_log.rs, src/quorum.rs, src/quorum/datadriven_test.rs
Display, panic, and test assertion strings updated from positional to named formatting; Index Display formatting adjusted to named fields.
Storage & Tracker
src/storage.rs, src/tracker/progress.rs
Assertion/panic messages and test data initializers adjusted; only formatting and test collection literals changed.
Utilities & Emitters
src/util.rs, datadriven/src/line_sparser.rs, harness/tests/test_util/mod.rs
write!/format!/panic! usages converted to named placeholders in helper and parsing utilities.
Integration Tests
harness/tests/integration_cases/...
harness/tests/integration_cases/test_raft.rs, harness/tests/integration_cases/test_raft_paper.rs, harness/tests/integration_cases/test_raw_node.rs
Many test logging, assertion, and sorting-related format strings replaced with named placeholders; no test behavior changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I nibble on braces, tidy each line,
From {} to {named} my whiskers align.
A hop through the code, neat placeholders bloom,
Tests still pass in the burrowed room,
Hooray for clarity — nibble, then zoom!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix clippy warnings' directly describes the primary change in the changeset, which consists entirely of automated Clippy fixes for string formatting across multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
harness/tests/integration_cases/test_raft.rs (1)

452-501: ⚠️ Potential issue | 🟠 Major

Resolve remaining clippy::useless_vec failures in fixed test tables

CI is still failing because these test-case collections are fixed-size and should be arrays, not vec![]. This currently blocks the PR objective (“fix clippy warnings”).

Suggested fix
-    let mut tests = vec![
+    let mut tests = [
         (
             Network::new_with_config(vec![None, None, None], &config, l),
             StateRole::Leader,
             1,
         ),
         ...
-    ];
+    ];

-    let mut tests = vec![
+    let mut tests = [
         (
             Network::new(vec![None, None, None], &l),
             vec![new_message(1, 1, MessageType::MsgPropose, 1)],
             2,
         ),
         ...
-    ];
+    ];

-    let mut tests = vec![
+    let mut tests = [
         Network::new(vec![None, None, None], &l),
         Network::new(vec![None, None, NOP_STEPPER], &l),
-    ];
+    ];

Also applies to: 766-781, 1118-1121

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

In `@harness/tests/integration_cases/test_raft.rs` around lines 452 - 501, The
tests variable uses fixed-size collections created with vec![] which triggers
clippy::useless_vec; change those test-case lists to fixed-size arrays (replace
vec![...] with [...] and adjust types if necessary) for each occurrence where
Network::new_with_config is called (including the block building tests and the
similar blocks at the other locations noted), leaving constructors like
Network::new_with_config(..., &config, l), NOP_STEPPER, and StateRole entries
unchanged; ensure the surrounding variable/type declarations accept arrays (or
use slices) so the test table compiles without heap-allocated Vecs.
src/tracker/progress.rs (1)

297-309: ⚠️ Potential issue | 🟠 Major

CI blocker: clippy::useless_vec is still present in this test table.

Pipeline reports this at Line 297-Line 308. Since this PR targets Clippy cleanup, this fixture should be an array literal to clear the lint and unblock CI.

♻️ Proposed fix
-        let mut tests = vec![
+        let mut tests = [
             (
                 new_progress(ProgressState::Replicate, matched, 5, 0, 256),
                 2,
             ),
             // snapshot finish
             (
                 new_progress(ProgressState::Snapshot, matched, 5, 10, 256),
                 11,
             ),
             // snapshot failure
             (new_progress(ProgressState::Snapshot, matched, 5, 0, 256), 2),
-        ];
+        ];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/tracker/progress.rs` around lines 297 - 309, Replace the temporary Vec
test fixture with an array literal to satisfy clippy::useless_vec: change the
declaration of tests (currently let mut tests = vec![ ... ]) to an array (for
example let tests = [ (new_progress(ProgressState::Replicate, matched, 5, 0,
256), 2), (new_progress(ProgressState::Snapshot, matched, 5, 10, 256), 11),
(new_progress(ProgressState::Snapshot, matched, 5, 0, 256), 2) ];), remove the
unnecessary mut if tests is not mutated, and keep the same tuple elements that
reference new_progress and ProgressState so behavior is unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@harness/tests/integration_cases/test_raft.rs`:
- Around line 452-501: The tests variable uses fixed-size collections created
with vec![] which triggers clippy::useless_vec; change those test-case lists to
fixed-size arrays (replace vec![...] with [...] and adjust types if necessary)
for each occurrence where Network::new_with_config is called (including the
block building tests and the similar blocks at the other locations noted),
leaving constructors like Network::new_with_config(..., &config, l),
NOP_STEPPER, and StateRole entries unchanged; ensure the surrounding
variable/type declarations accept arrays (or use slices) so the test table
compiles without heap-allocated Vecs.

In `@src/tracker/progress.rs`:
- Around line 297-309: Replace the temporary Vec test fixture with an array
literal to satisfy clippy::useless_vec: change the declaration of tests
(currently let mut tests = vec![ ... ]) to an array (for example let tests = [
(new_progress(ProgressState::Replicate, matched, 5, 0, 256), 2),
(new_progress(ProgressState::Snapshot, matched, 5, 10, 256), 11),
(new_progress(ProgressState::Snapshot, matched, 5, 0, 256), 2) ];), remove the
unnecessary mut if tests is not mutated, and keep the same tuple elements that
reference new_progress and ProgressState so behavior is unchanged.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1fd05e0 and ad126a6.

📒 Files selected for processing (19)
  • benches/suites/raft.rs
  • datadriven/src/line_sparser.rs
  • examples/five_mem_node/main.rs
  • harness/tests/integration_cases/test_raft.rs
  • harness/tests/integration_cases/test_raft_paper.rs
  • harness/tests/integration_cases/test_raw_node.rs
  • harness/tests/test_util/mod.rs
  • proto/build.rs
  • proto/src/confchange.rs
  • src/confchange/changer.rs
  • src/confchange/datadriven_test.rs
  • src/config.rs
  • src/quorum.rs
  • src/quorum/datadriven_test.rs
  • src/raft.rs
  • src/raft_log.rs
  • src/storage.rs
  • src/tracker/progress.rs
  • src/util.rs

mostly generated by
```
cargo clippy --all --all-targets --fix
```

Signed-off-by: Guillaume Girol <guillaume.girol@rubycat.eu>
Copy link

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

🧹 Nitpick comments (1)
src/config.rs (1)

186-189: Consider applying the same named placeholder style for consistency.

This nearby error message still uses positional placeholders while line 194 now uses named placeholders. For consistency within the validate function, consider updating this as well.

♻️ Optional consistency fix
         if min_timeout < self.election_tick {
             return Err(Error::ConfigInvalid(format!(
-                "min election tick {} must not be less than election_tick {}",
-                min_timeout, self.election_tick
+                "min election tick {min_timeout} must not be less than election_tick {}",
+                self.election_tick
             )));
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/config.rs` around lines 186 - 189, The error message in validate is using
positional placeholders; change it to named placeholders to match the style used
elsewhere: update the ConfigInvalid message in the branch that returns
Err(Error::ConfigInvalid(...)) so it references {min_timeout} and
{election_tick} by name (using the same identifiers min_timeout and
self.election_tick) instead of positional formatting, ensuring consistency with
the other named-placeholder messages in the validate function.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/config.rs`:
- Around line 186-189: The error message in validate is using positional
placeholders; change it to named placeholders to match the style used elsewhere:
update the ConfigInvalid message in the branch that returns
Err(Error::ConfigInvalid(...)) so it references {min_timeout} and
{election_tick} by name (using the same identifiers min_timeout and
self.election_tick) instead of positional formatting, ensuring consistency with
the other named-placeholder messages in the validate function.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad126a6 and 23e9ed8.

📒 Files selected for processing (19)
  • benches/suites/raft.rs
  • datadriven/src/line_sparser.rs
  • examples/five_mem_node/main.rs
  • harness/tests/integration_cases/test_raft.rs
  • harness/tests/integration_cases/test_raft_paper.rs
  • harness/tests/integration_cases/test_raw_node.rs
  • harness/tests/test_util/mod.rs
  • proto/build.rs
  • proto/src/confchange.rs
  • src/confchange/changer.rs
  • src/confchange/datadriven_test.rs
  • src/config.rs
  • src/quorum.rs
  • src/quorum/datadriven_test.rs
  • src/raft.rs
  • src/raft_log.rs
  • src/storage.rs
  • src/tracker/progress.rs
  • src/util.rs
✅ Files skipped from review due to trivial changes (1)
  • src/storage.rs
🚧 Files skipped from review as they are similar to previous changes (14)
  • src/raft_log.rs
  • src/raft.rs
  • src/confchange/changer.rs
  • benches/suites/raft.rs
  • harness/tests/integration_cases/test_raw_node.rs
  • harness/tests/integration_cases/test_raft.rs
  • proto/build.rs
  • harness/tests/integration_cases/test_raft_paper.rs
  • examples/five_mem_node/main.rs
  • src/quorum.rs
  • proto/src/confchange.rs
  • src/util.rs
  • src/quorum/datadriven_test.rs
  • datadriven/src/line_sparser.rs

@BusyJay BusyJay merged commit deb3ba3 into tikv:master Feb 26, 2026
7 checks passed
@BusyJay
Copy link
Member

BusyJay commented Feb 26, 2026

Thank you!

@ggirol-rc ggirol-rc deleted the fix_clippy branch February 26, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants