style: fix two clippy warnings#2237
Conversation
There was a problem hiding this comment.
Code Review
This pull request simplifies code in the TUI crate by refactoring a closure to a direct function reference in runtime_log.rs and replacing a format! macro with a string literal in config.rs. The reviewer noted that the .to_string() call on the string literal in config.rs is redundant and can be omitted to avoid an unnecessary allocation.
| return CommandResult::error(format!( | ||
| "base_url must be saved with --save; client base URL is loaded from config on startup. Restart and re-open your session after saving." | ||
| )); | ||
| return CommandResult::error("base_url must be saved with --save; client base URL is loaded from config on startup. Restart and re-open your session after saving.".to_string()); |
There was a problem hiding this comment.
The .to_string() call is redundant here because CommandResult::error accepts a &str (or impl Into<String>) directly, as seen in other parts of this file (e.g., lines 34, 438, and 463). Passing the string literal directly is more idiomatic and avoids an unnecessary allocation.
return CommandResult::error("base_url must be saved with --save; client base URL is loaded from config on startup. Restart and re-open your session after saving.");
Hmbown
left a comment
There was a problem hiding this comment.
Both clippy fixes are behavior-preserving: removing a useless on a string literal and eta-reducing a redundant closure. Clean.
APPROVE.
Hmbown
left a comment
There was a problem hiding this comment.
Both clippy fixes are behavior-preserving: removing a useless format!() on a string literal and eta-reducing a redundant closure. APPROVE.
Summary
Run "cargo clippy" find two warnings, use "cargo clippy --fix" fix them.
Testing
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-featurescargo test --workspace --all-featuresChecklist
Greptile Summary
This PR applies two mechanical clippy lint fixes generated by
cargo clippy --fix, with no behavioral changes.config.rs: Removes a redundantformat!()call wrapping a plain string literal, replacing it with.to_string()directly on the literal (clippy::useless_format).runtime_log.rs: Eta-reduces a closure|h| resolve(h)to pass the local closureresolvedirectly intoand_then, eliminating a needless wrapper (clippy::redundant_closure).Confidence Score: 5/5
Both changes are purely cosmetic clippy fixes with identical runtime behavior — safe to merge.
The two edits are exact semantic equivalents of the code they replace: removing a no-op format! wrapper and inlining a single-argument closure pass-through. Neither touches logic, data flow, or any externally visible behavior.
No files require special attention.
Important Files Changed
format!("literal")with"literal".to_string()— a correct one-line clippy lint fix with no semantic change.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[set_config_value: base_url branch] --> B{persist?} B -- yes --> C[persist_root_string_key] C -- Ok --> D[CommandResult::message] C -- Err --> E["CommandResult::error(format!(...))"] B -- no --> F["CommandResult::error('base_url must be saved...'.to_string())"] G[log_directory] --> H{HOME env set?} H -- yes --> I[resolve HOME] H -- no --> J{USERPROFILE env set?} J -- yes --> K[resolve USERPROFILE] J -- no --> L["dirs::home_dir().and_then(resolve)"]Reviews (1): Last reviewed commit: "style: fix two clippy warnings" | Re-trigger Greptile