Skip to content

Conversation

@baerwang
Copy link
Contributor

@baerwang baerwang commented Dec 16, 2025

#218

Summary by CodeRabbit

  • Chores
    • Strengthened development build checks to enforce stricter coding standards and promote more robust code practices across the project.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add `-D clippy::unwrap_used` flag to cargo clippy linting command
- Enforce stricter code quality standards by disallowing unwrap calls
- Improve error handling practices across the codebase
@coderabbitai
Copy link

coderabbitai bot commented Dec 16, 2025

Walkthrough

The Makefile's lint target is enhanced to include an additional Clippy lint flag (-D clippy::unwrap_used) that enforces stricter code quality checks by denying the use of unwrap operations.

Changes

Cohort / File(s) Change Summary
Lint Configuration
Makefile
Added -D clippy::unwrap_used flag to lint target to deny unwrap usage

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A lint flag hops into place,
No more unwraps in this space! 🐰
Clippy's watchful eye grows keen,
Safest Rust code ever seen ✨

Pre-merge checks and finishing touches

✅ 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 accurately describes the main change: adding a Clippy lint rule to deny unwrap usage in the Makefile's lint target.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@github-actions github-actions bot added the ✏️ Feature new feature label Dec 16, 2025
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.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 42cd43d and 49f1d14.

📒 Files selected for processing (1)
  • Makefile (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: build and test (ubuntu-latest)
  • GitHub Check: cargo fmt (windows-latest)
  • GitHub Check: cargo clippy (windows-latest)
  • GitHub Check: cargo clippy (macos-latest)
  • GitHub Check: build and test (macos-latest)
  • GitHub Check: cargo clippy (ubuntu-latest)
  • GitHub Check: build and test (windows-latest)
  • GitHub Check: test
  • GitHub Check: test-windows
  • GitHub Check: lint
  • GitHub Check: test-macos

lint:
@echo "Linting code..."
@cargo clippy --manifest-path ./Cargo.toml --all-features --workspace -- -D warnings
@cargo clippy --manifest-path ./Cargo.toml --all-features --workspace -- -D warnings -D clippy::unwrap_used
Copy link

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
# Search for .unwrap() calls in Rust source files
echo "=== Searching for .unwrap() usage ==="
find . -name "*.rs" -type f | head -20

echo ""
echo "=== Checking for unwrap() in Rust files ==="
rg '\.unwrap\(\)' --type rust --max-count=10 || echo "No unwrap() found or rg not available"

echo ""
echo "=== Checking for expect() in Rust files ==="
rg '\.expect\(' --type rust --max-count=10 || echo "No expect() found or rg not available"

echo ""
echo "=== Checking Makefile content around line 56 ==="
cat -n Makefile | sed -n '50,65p'

echo ""
echo "=== Looking for clippy configuration ==="
if [ -f "clippy.toml" ]; then
  echo "Found clippy.toml:"
  cat clippy.toml
else
  echo "No clippy.toml found"
fi

if [ -f "Cargo.toml" ]; then
  echo ""
  echo "Checking Cargo.toml for lints configuration:"
  grep -A 10 "\[lints" Cargo.toml || echo "No [lints] section found"
fi

Repository: arana-db/kiwi

Length of output: 50369


🏁 Script executed:

#!/bin/bash
# Check for clippy configuration
echo "=== Checking for clippy.toml ==="
if [ -f "clippy.toml" ]; then
  cat clippy.toml
else
  echo "No clippy.toml found"
fi

echo ""
echo "=== Checking Cargo.toml for lints configuration ==="
if [ -f "Cargo.toml" ]; then
  grep -A 20 "\[lints" Cargo.toml | head -30
else
  echo "No Cargo.toml found"
fi

echo ""
echo "=== Checking for allow-unwrap-in-tests in Cargo.toml ==="
if [ -f "Cargo.toml" ]; then
  grep "allow-unwrap-in-tests" Cargo.toml || echo "Not found"
else
  echo "No Cargo.toml found"
fi

echo ""
echo "=== Count unwrap() in production src code (excluding tests) ==="
rg '\.unwrap\(\)' --type rust src/ --glob '!**/tests/**' --glob '!**/benches/**' --glob '!**/test.rs' --count-all 2>/dev/null | tail -5

Repository: arana-db/kiwi

Length of output: 1475


🏁 Script executed:

#!/bin/bash
echo "=== Full Makefile around line 56 ==="
cat -n Makefile | sed -n '45,70p'

echo ""
echo "=== Check if there's a recent git commit for unwrap fixes ==="
git log --oneline -20 2>/dev/null | head -10 || echo "Git not available"

echo ""
echo "=== Verify count of production unwraps more carefully ==="
rg '\.unwrap\(\)' --type rust src/ -c 2>/dev/null | grep -v ":0$" | wc -l

Repository: arana-db/kiwi

Length of output: 1159


This lint change requires either removing all 95 instances of .unwrap() from production code first, or adding allow-unwrap-in-tests configuration to Clippy.

The codebase currently contains .unwrap() calls across 95 files in production code. Adding -D clippy::unwrap_used will immediately break the build unless all .unwrap() calls are removed or properly configured to allow only test usage.

Two approaches:

  1. Refactor production code first: Replace all .unwrap() calls with proper error handling before merging this lint change.
  2. Configure for tests only: Add allow-unwrap-in-tests = true to clippy.toml, then refactor production code separately. This allows .unwrap() in tests while denying it in library/binary code.

Also consider adding -D clippy::expect_used for consistency, since both .unwrap() and .expect() result in panics.

🤖 Prompt for AI Agents
In Makefile at line 56, the CI lint invocation disables builds because -D
clippy::unwrap_used will fail due to 95 .unwrap() occurrences; either
remove/refactor all production .unwrap()/.expect() usages before enabling this
lint, or add a clippy.toml with allow-unwrap-in-tests = true (and consider
adding deny for expect_used as well) so tests can still use unwrap while
production code is enforced; update the Makefile/lint config accordingly to
avoid breaking the build until production unwraps are fixed.

@lqxhub
Copy link
Collaborator

lqxhub commented Jan 10, 2026

@baerwang 麻烦继续处理一下CI流程错误

@baerwang
Copy link
Contributor Author

@baerwang 麻烦继续处理一下CI流程错误

我只负责ci不复杂代码修改

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✏️ Feature new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants