Conversation
Signed-off-by: Grant Ramsay <seapagan@gmail.com>
Signed-off-by: Grant Ramsay <seapagan@gmail.com>
Signed-off-by: Grant Ramsay <seapagan@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughDocs: added Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
TIP This summary will be updated as you push new changes. Give us feedback
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/utils/file.rs (1)
407-422: Consider lazy evaluation ofget_file_detailsfor performance.
get_file_detailsperforms system calls to resolve user/group names, but the result is only needed when checking theexecutableflag for regular files. For symlinks and directories, it's wasted work.♻️ Proposed optimisation
fn colorize_name_by_metadata( safe_name: &str, metadata: &fs::Metadata, ) -> String { - let details = get_file_details(metadata); - if metadata.is_symlink() { format!("{color_cyan}{safe_name}") } else if metadata.is_dir() { format!("{color_blue}{safe_name}") - } else if details.executable { + } else if is_executable(metadata) { format!("{style_bold}{color_green}{safe_name}") } else { format!("{color_reset}{safe_name}") } } + +#[cfg(unix)] +fn is_executable(metadata: &fs::Metadata) -> bool { + metadata.permissions().mode() & 0o111 != 0 +} + +#[cfg(windows)] +fn is_executable(_metadata: &fs::Metadata) -> bool { + false +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils/file.rs` around lines 407 - 422, In colorize_name_by_metadata, avoid calling get_file_details unconditionally; remove the eager let details = get_file_details(metadata) and instead call get_file_details(metadata) lazily only when needed (i.e., in the branch that handles regular files) to avoid unnecessary system calls for symlinks and directories; change the branches to first check metadata.is_symlink() and metadata.is_dir(), then in the else branch call get_file_details(metadata) and inspect details.executable to decide between the bold/green and reset formats, keeping the same returned String format and using the existing function name colorize_name_by_metadata and helper get_file_details.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/utils/file.rs`:
- Around line 407-422: In colorize_name_by_metadata, avoid calling
get_file_details unconditionally; remove the eager let details =
get_file_details(metadata) and instead call get_file_details(metadata) lazily
only when needed (i.e., in the branch that handles regular files) to avoid
unnecessary system calls for symlinks and directories; change the branches to
first check metadata.is_symlink() and metadata.is_dir(), then in the else branch
call get_file_details(metadata) and inspect details.executable to decide between
the bold/green and reset formats, keeping the same returned String format and
using the existing function name colorize_name_by_metadata and helper
get_file_details.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8b86f82b-d27d-49c5-af64-fefeab8d39e4
📒 Files selected for processing (6)
README.mdTODO.mddocs/src/usage.mdsrc/utils/file.rstests/crate/file.rstests/integration.rs
💤 Files with no reviewable changes (1)
- TODO.md
Signed-off-by: Grant Ramsay <seapagan@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/utils/file.rs (1)
416-421: Avoid recomputing full file details just to detect executability.At Line [416], calling
get_file_details(metadata)repeats extra metadata/user/group work already done earlier in this code path. This can add avoidable overhead in large directory listings.♻️ Suggested refactor
- let details = get_file_details(metadata); - - if details.executable { + let executable = metadata.permissions().mode() & 0o111 != 0; + if executable { format!("{style_bold}{color_green}{safe_name}") } else { format!("{color_reset}{safe_name}") }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils/file.rs` around lines 416 - 421, Don't call get_file_details(metadata) just to check executability; instead derive the executable flag directly from the provided metadata (e.g., inspect metadata.permissions().mode() on Unix or use the platform-appropriate permission check) and use that boolean in place of details.executable. Update the code around the format branch that currently calls get_file_details(metadata) (referencing get_file_details and the local metadata variable) to compute a simple is_executable boolean from metadata and use that to pick the green bold vs reset formatting, avoiding the expensive full get_file_details call.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/utils/file.rs`:
- Around line 441-445: The code is calling fs::symlink_metadata(&target_path)
which returns the symlink's own metadata; replace this with
fs::metadata(&target_path) so the resolved target's metadata (following any
intermediate symlinks) is used when calling colorize_name_by_metadata on
display_target; update the call site where symlink_metadata is used (around
display_target / target_path) to use fs::metadata and keep the same error
handling (map(...).unwrap_or(display_target)) so non-existent targets still fall
back to the original display_target.
---
Nitpick comments:
In `@src/utils/file.rs`:
- Around line 416-421: Don't call get_file_details(metadata) just to check
executability; instead derive the executable flag directly from the provided
metadata (e.g., inspect metadata.permissions().mode() on Unix or use the
platform-appropriate permission check) and use that boolean in place of
details.executable. Update the code around the format branch that currently
calls get_file_details(metadata) (referencing get_file_details and the local
metadata variable) to compute a simple is_executable boolean from metadata and
use that to pick the green bold vs reset formatting, avoiding the expensive full
get_file_details call.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Signed-off-by: Grant Ramsay <seapagan@gmail.com>
Summary
-I/--gitignoreand-V/--versionoptions and fix the--no-iconsspellingWhy
This makes symlink output match the intended behavior for target coloring and brings the usage docs back in sync with the current CLI flags.
Summary by CodeRabbit
New Features
-I/--gitignoreto dim Git-ignored entries-V/--versionto print version and exitBug Fixes
--no-iconsDocumentation
Tests