Skip to content

fix: handle absence of Cargo.toml in metadata retrieval#21

Merged
Bechma merged 1 commit intocyberfabric:mainfrom
Bechma:bugfix-docs-metadata
Mar 26, 2026
Merged

fix: handle absence of Cargo.toml in metadata retrieval#21
Bechma merged 1 commit intocyberfabric:mainfrom
Bechma:bugfix-docs-metadata

Conversation

@Bechma
Copy link
Copy Markdown
Collaborator

@Bechma Bechma commented Mar 26, 2026

Summary by CodeRabbit

  • Refactor
    • Reduced unnecessary processing by early-checking for required project configuration, improving responsiveness in module handling.
    • Streamlined in-file module filtering to operate directly on parsed structures, yielding more efficient module resolution and slightly faster file processing.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f2bc3e94-bbb6-4902-9a4f-879fc548be9d

📥 Commits

Reviewing files that changed from the base of the PR and between e9a33dc and 5596a38.

📒 Files selected for processing (2)
  • crates/module-parser/src/metadata.rs
  • crates/module-parser/src/source.rs
✅ Files skipped from review due to trivial changes (2)
  • crates/module-parser/src/source.rs
  • crates/module-parser/src/metadata.rs

📝 Walkthrough

Walkthrough

Two small changes: resolve_source_from_metadata now returns early if path/Cargo.toml is missing, avoiding metadata queries; resolve_in_file inlines top-level item filtering for the empty-segments (leaf) case instead of using a separate helper.

Changes

Cohort / File(s) Summary
Cargo.toml Existence Check
crates/module-parser/src/metadata.rs
Add an early Ok(None) return when Cargo.toml is not present at path/Cargo.toml, skipping query parsing and cargo_metadata::MetadataCommand execution.
Inline Filtering Refactor
crates/module-parser/src/source.rs
Remove the filtered_file helper and apply filtering directly to the parsed syn::File (parsed.items = ...) in the segments.is_empty() branch, then render via render_file(&parsed).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I nibbled a patch under moonlit beams,
Found Cargo absent, so skipped some dreams,
Filtered the leaves right where they grow,
No helper burrowed, the code can flow —
Hop, patch, rejoice! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: handle absence of Cargo.toml in metadata retrieval' directly and clearly summarizes the main change: adding a short-circuit check for missing Cargo.toml files in the metadata resolution function.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown
Contributor

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/module-parser/src/metadata.rs`:
- Line 54: The guard that checks for a manifest currently uses
path.join("Cargo.toml").exists(), which treats a directory named Cargo.toml as
valid; change this to use path.join("Cargo.toml").is_file() so the code only
proceeds when the manifest is an actual file. Update the expression in
metadata.rs where the manifest guard is performed (the code using the path
variable and "Cargo.toml") to call is_file() instead of exists(), preserving the
surrounding control flow and error handling.
🪄 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: 16abdd66-5760-4584-afc2-d7668b7292c9

📥 Commits

Reviewing files that changed from the base of the PR and between 44d9b74 and e9a33dc.

📒 Files selected for processing (2)
  • crates/module-parser/src/metadata.rs
  • crates/module-parser/src/source.rs

Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
@Bechma Bechma force-pushed the bugfix-docs-metadata branch from e9a33dc to 5596a38 Compare March 26, 2026 10:23
@Bechma Bechma merged commit 2d2a32a into cyberfabric:main Mar 26, 2026
2 checks passed
@Bechma Bechma deleted the bugfix-docs-metadata branch March 26, 2026 11:13
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