Skip to content

clippy: use is_multiple_of to replace % operator#5189

Merged
eval-exec merged 1 commit into
nervosnetwork:developfrom
eval-exec:exec/fix-clippy
Apr 28, 2026
Merged

clippy: use is_multiple_of to replace % operator#5189
eval-exec merged 1 commit into
nervosnetwork:developfrom
eval-exec:exec/fix-clippy

Conversation

@eval-exec
Copy link
Copy Markdown
Collaborator

@eval-exec eval-exec commented Apr 28, 2026

What problem does this PR solve?

make clippy
...
    Checking ckb-test v1.0.0 (/home/exec/Projects/github.com/nervosnetwork/ckb.develop/test)
    Checking ckb-sync v1.3.0 (/home/exec/Projects/github.com/nervosnetwork/ckb.develop/sync)
    Checking ckb-instrument v1.1.0 (/home/exec/Projects/github.com/nervosnetwork/ckb.develop/util/instrument)
    Checking tikv-jemalloc-ctl v0.5.4
    Checking tikv-jemallocator v0.5.4
    Checking ckb-memory-tracker v1.1.0 (/home/exec/Projects/github.com/nervosnetwork/ckb.develop/util/memory-tracker)
error: manual implementation of `.is_multiple_of()`
    --> sync/src/types/mod.rs:1133:12
     |
1133 |         if header_view.number() % 10000 == 0 {
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `header_view.number().is_multiple_of(10000)`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#manual_is_multiple_of
     = note: `-D clippy::manual-is-multiple-of` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::manual_is_multiple_of)]`

error: could not compile `ckb-sync` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `ckb-sync` (lib test) due to 1 previous error
make: *** [Makefile:190: clippy] Error 101

Related changes

  • fix clippy, use is_multiple_of to replace %

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • None

Copilot AI review requested due to automatic review settings April 28, 2026 06:20
@eval-exec eval-exec requested a review from a team as a code owner April 28, 2026 06:20
@eval-exec eval-exec requested review from chenyukang and doitian and removed request for a team April 28, 2026 06:20
@eval-exec eval-exec enabled auto-merge April 28, 2026 06:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates sync header insertion logging to use Rust’s is_multiple_of helper instead of a %-based modulus check, addressing a clippy lint in the sync module.

Changes:

  • Replaced header_view.number() % 10000 == 0 with header_view.number().is_multiple_of(10000) in SyncShared::insert_valid_header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@eval-exec eval-exec added this pull request to the merge queue Apr 28, 2026
Merged via the queue into nervosnetwork:develop with commit a6dffef Apr 28, 2026
49 checks passed
@nervos-bot nervos-bot Bot mentioned this pull request Apr 28, 2026
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.

3 participants