Initialize CodeM8 project#1
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a Rust crate that parses CLI flags, discovers files, normalizes and classifies lines, detects duplicate blocks, renders a report, and wires the binary, workflows, and project guidance. ChangesRust duplicate-code reporting
Sequence Diagram(s)sequenceDiagram
participant CLI as src/main.rs
participant Library as src/lib.rs
participant Discovery as src/discovery.rs
participant Line as src/line.rs
participant Duplicate as src/duplicate.rs
participant Report as src/report.rs
participant Writer as stdout
CLI->>Library: run(args, current_dir, writer)
Library->>Discovery: discover_source_files(...)
Discovery-->>Library: Vec<SourceFile>
Library->>Line: process_source_files(...)
Line-->>Library: Vec<ProcessedFile>
Library->>Duplicate: detect_duplicate_blocks(...)
Duplicate-->>Library: Vec<DuplicateBlock>
Library->>Report: render_duplicate_report(...)
Report-->>Library: String
Library->>Writer: write_all(rendered bytes)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
18-19: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueOptional: harden the checkout step.
Static analysis flags two supply-chain hygiene items here: the checkout token is persisted by default, and the action is referenced by tag rather than a commit SHA. Since
contents: readalready limits the token scope, this is low risk, but pinning to a hash and disabling credential persistence is good practice.🔒 Suggested hardening
- name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@<pinned-commit-sha> # v4 + with: + persist-credentials: false🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/ci.yml around lines 18 - 19, Harden the checkout step in the workflow by updating the actions/checkout reference in the Checkout repository step to a pinned commit SHA instead of a tag, and disable persisted credentials for that step. Use the existing Checkout repository action entry in the CI workflow as the location to apply these supply-chain safeguards.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/coderabbit-review.yml:
- Around line 28-74: The stdin-piped Node script in the workflow uses top-level
await, which breaks on older Node runtimes because heredoc input is treated as
CommonJS by default. Update the script block that contains fetchReviews,
latestReview, and the review checks by wrapping the whole logic in an async IIFE
(or another async entrypoint) so it runs without requiring --input-type=module.
Keep the existing fetchReviews recursion and CodeRabbit review-state checks
unchanged, just move them inside the async wrapper.
In `@src/discovery.rs`:
- Line 1: The explicit-file handling in discovery should deduplicate resolved
paths before creating SourceFile entries, since the same file can currently be
added twice and processed multiple times. Update the logic in the discovery flow
that resolves explicit files and builds SourceFile values so each unique
resolved file is emitted only once, preserving existing behavior for
non-duplicates while preventing repeated processing in src/lib.rs and related
callers.
In `@src/duplicate.rs`:
- Around line 22-28: `OccurrenceKey::cmp` is missing `file_path`, so `Ord` is
not aligned with the derived `Eq` and `BTreeSet` can incorrectly merge distinct
occurrences. Update the ordering in `OccurrenceKey` to compare `file_path` as
well as `file_path_key`, `start_line`, and `end_line`, using the same fields
that define equality so de-duplication stays consistent.
- Around line 121-153: The overlap check in expand_pair is too weak because it
only rejects identical LineRef values, so same-file expansions can still produce
overlapping candidate ranges and false positives. Update expand_pair to detect
and reject overlapping ranges when left.file_index equals right.file_index,
using the left_start/left_end and right_start/right_end bounds before building
CandidateBlock, while keeping the existing exact-same-line guard.
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 18-19: Harden the checkout step in the workflow by updating the
actions/checkout reference in the Checkout repository step to a pinned commit
SHA instead of a tag, and disable persisted credentials for that step. Use the
existing Checkout repository action entry in the CI workflow as the location to
apply these supply-chain safeguards.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: c3df5e3b-e828-474d-9ada-941a5385592d
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (15)
.github/workflows/ci.yml.github/workflows/coderabbit-review.ymlCargo.tomlREADME.mdsrc/cli.rssrc/discovery.rssrc/duplicate.rssrc/error.rssrc/language.rssrc/lib.rssrc/line.rssrc/main.rssrc/model.rssrc/paths.rssrc/report.rs
|
@CodeRabbit resume |
✅ Action performedReviews resumed. |
|
@CodeRabbit resume |
✅ Action performedReviews resumed. |
|
@CodeRabbit do you approve this pull request? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== AGENTS.md =="
sed -n '1,220p' AGENTS.md
echo
echo "== Cargo.lock presence =="
fd '^Cargo\.lock$' .
echo
echo "== Outline: src/lib.rs =="
ast-grep outline src/lib.rs --view expanded || true
echo
echo "== src/lib.rs =="
sed -n '1,240p' src/lib.rs
echo
echo "== Outline: src/discovery.rs =="
ast-grep outline src/discovery.rs --view expanded || true
echo
echo "== src/discovery.rs (1-260) =="
sed -n '1,260p' src/discovery.rs
echo
echo "== Outline: src/duplicate.rs =="
ast-grep outline src/duplicate.rs --view expanded || true
echo
echo "== src/duplicate.rs (1-420) =="
sed -n '1,420p' src/duplicate.rs
echo
echo "== .github/workflows/coderabbit-review.yml =="
sed -n '1,220p' .github/workflows/coderabbit-review.yml
echo
echo "== .github/workflows/ci.yml =="
sed -n '1,220p' .github/workflows/ci.ymlLength of output: 33967
I checked the CLI/report wiring in I wasn’t able to execute the Rust verification commands in this sandbox, so this approval is based on code inspection rather than a local run of [approve] |
|
@CodeRabbit approve |
✅ Action performedComments resolved. Approval is disabled; enable |
|
@CodeRabbit resume |
✅ Action performedReviews resumed. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/duplicate.rs`:
- Around line 313-344: The test in detect_duplicate_blocks should verify sorting
by weight rather than encounter order. In sorts_duplicate_blocks_by_weight,
adjust the fixture so the lighter duplicate block appears first and is separated
by unique lines, while the heavier duplicate block is encountered later; then
keep asserting that detect_duplicate_blocks returns the heavier block at
blocks[0] and that its weight is at least blocks[1].weight.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4fdea58c-a683-4da5-80b0-2328cffb6236
📒 Files selected for processing (6)
.coderabbit.yamlsrc/cli.rssrc/discovery.rssrc/duplicate.rssrc/line.rssrc/paths.rs
✅ Files skipped from review due to trivial changes (1)
- .coderabbit.yaml
🚧 Files skipped from review as they are similar to previous changes (4)
- src/paths.rs
- src/line.rs
- src/discovery.rs
- src/cli.rs
Summary by CodeRabbit