Skip to content

Fix all clippy warnings and improve code quality - #24

Merged
Danconnolly merged 1 commit into
mainfrom
fix/clippy-warnings
Oct 5, 2025
Merged

Danconnolly merged 1 commit into
mainfrom
fix/clippy-warnings

Conversation

@Danconnolly

Copy link
Copy Markdown
Owner

Summary

This PR resolves all clippy warnings and improves code quality across the codebase:

Key Changes

Deprecated API Updates:

  • Replaced SecretKey::from_slice with SecretKey::from_byte_array
  • Replaced rng.gen() with rng.random()
  • Updated legacy numeric methods (u16::max_value() → u16::MAX, etc.)

Idiomatic Rust Patterns:

  • Used matches! macro instead of verbose match expressions
  • Converted single-arm match statements to if let patterns
  • Replaced while let loops with for loops where appropriate
  • Fixed range contains implementation to use RangeInclusive::contains

API Improvements:

  • Changed function signatures from &Vec<u8> to &[u8] for better performance
  • Changed &String to &str for string parameters
  • Added missing is_empty() method to ByteSequence struct
  • Changed AtomicU64 constants to static items (correct for interior mutability)

Code Cleanup:

  • Fixed documentation formatting (empty lines and list indentation)
  • Removed needless borrows and unnecessary operations
  • Used proper assertion patterns in tests (assert! vs assert_eq!(x, true))
  • Replaced assert!(false) with descriptive panic! messages

Files Modified (17 files, +104/-78 lines)

  • bsv/src/bitcoin/address.rs
  • bsv/src/bitcoin/base58ck.rs
  • bsv/src/bitcoin/block.rs
  • bsv/src/bitcoin/crypto.rs
  • bsv/src/bitcoin/hash.rs
  • bsv/src/bitcoin/merkle.rs
  • bsv/src/bitcoin/proptest_tests.rs
  • bsv/src/bitcoin/rules.rs
  • bsv/src/bitcoin/script/byte_seq.rs
  • bsv/src/bitcoin/script/interpreter.rs
  • bsv/src/bitcoin/script/op.rs
  • bsv/src/bitcoin/script/signature.rs
  • bsv/src/bitcoin/tx.rs
  • bsv/src/bitcoin/var_int.rs
  • bsv/src/bitcoin/var_int_edge_tests.rs
  • bsv/src/lib.rs
  • bsv/src/p2p/protocol.rs

Test plan

  • All code formatted with cargo fmt
  • All clippy warnings resolved (verified with cargo clippy)
  • CI tests pass (unit tests, property tests, build)
  • No behavioral changes, only code quality improvements

All changes follow Rust best practices and idioms. The code is more maintainable and follows current Rust conventions.

🤖 Generated with Claude Code

This commit resolves all clippy warnings and improves code quality across the codebase:

- Replace deprecated methods (SecretKey::from_slice, rng.gen, numeric max_value)
- Use idiomatic Rust patterns (matches! macro, if let, for loops)
- Fix function signatures (&Vec<u8> → &[u8], &String → &str)
- Add missing is_empty() method to ByteSequence
- Change AtomicU64 constants to static items
- Fix documentation formatting
- Remove needless borrows and unnecessary operations
- Use proper assertion patterns in tests

All changes follow Rust best practices and idioms.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 5, 2025

Copy link
Copy Markdown

Test Results

116 tests  ±0   116 ✅ ±0   0s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 7ad00b0. ± Comparison against base commit 5e226fe.

@codacy-production

Copy link
Copy Markdown

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
✅ -0.04% (target: -1.00%) ✅ 72.88%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (5e226fe) 4453 3536 79.41%
Head commit (7ad00b0) 4453 (+0) 3534 (-2) 79.36% (-0.04%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#24) 59 43 72.88%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@Danconnolly
Danconnolly merged commit e5f8e61 into main Oct 5, 2025
8 checks passed
@Danconnolly
Danconnolly deleted the fix/clippy-warnings branch October 5, 2025 13:45
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.

1 participant