meta: resolve fixable clippy warning#484
Conversation
WalkthroughSmall, focused edits across multiple modules: promote several methods to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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: 1
🧹 Nitpick comments (2)
src/nixos.rs (1)
332-332: Address the formatting issue flagged by CI.The clippy fix is correct—using
unwrap_or_elseonOptionis more idiomatic thanmap_or_else. However, the CI pipeline has flagged a formatting difference on this line. Runcargo fmtto fix the newline handling aroundunwrap_or_else.Also, the parentheses around
(get_nh_os_flake_env()?)are unnecessary:- let installable = (get_nh_os_flake_env()?).unwrap_or_else(|| self.common.installable.clone()); + let installable = + get_nh_os_flake_env()?.unwrap_or_else(|| self.common.installable.clone());src/home.rs (1)
319-320: Address the formatting issue flagged by CI.The logic is correct, but the CI pipeline flagged a formatting difference at this location. Run
cargo fmtto fix the conditional block formatting (space/newline handling around theifcondition).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/commands.rs(3 hunks)src/generations.rs(2 hunks)src/home.rs(2 hunks)src/installable.rs(2 hunks)src/logging.rs(1 hunks)src/nixos.rs(1 hunks)src/util.rs(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Check formating & lints
src/nixos.rs
[error] 329-329: Diff in formatting detected by cargo fmt. Method call formatting differs (unwrap_or_else newline handling).
src/generations.rs
[error] 173-173: Diff in formatting detected by cargo fmt. #[must_use] attribute formatting differs from the expected style.
src/home.rs
[error] 316-316: Diff in formatting detected by cargo fmt. Conditional block formatting differs (space/newline handling).
⏰ 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). (5)
- GitHub Check: Test NH on Darwin
- GitHub Check: Test NH on Linux
- GitHub Check: Build NH on Darwin
- GitHub Check: Build NH on Linux
- GitHub Check: profile
🔇 Additional comments (8)
src/installable.rs (2)
60-60: LGTM!Using
clone()instead ofto_string()forStringtypes is more idiomatic and slightly more efficient, as it avoids theDisplaytrait indirection.
289-289: LGTM!Consistent with the change at line 60—using
clone()onStringis the correct approach.src/logging.rs (1)
32-44: LGTM!The match arm formatting is consistent, and error propagation via
?is correctly maintained across all log levels.src/util.rs (1)
17-22: LGTM!Adding
EqalongsidePartialEqis correct for this simple enum. This satisfiesclippy::derive_partial_eq_without_eqand enables usingNixVariantin hash-based collections or otherEq-requiring contexts.src/home.rs (1)
135-139: LGTM!Moving
out_pathinstead of cloning is correct here—the variable is not used after this assignment in the else branch, so the clone was redundant.src/generations.rs (1)
72-83: Const-ifyingField::column_infois safe and idiomaticThe function body is fully const-friendly (pure match over
selfandColumnWidthswith string literals), so making itconst fnis sound and widens where it can be used without changing runtime behavior.src/commands.rs (2)
132-147: UsingSelfinElevationStrategy::resolvekeeps patterns conciseSwitching match arms from
ElevationStrategy::...toSelf::...is purely stylistic, idiomatic, and does not change behavior.
225-237:const fnforCommand::dry/show_outputlooks correctBoth methods only toggle boolean fields on a by-value
selfand return it, which is const-friendly and keeps all existing call sites working while enabling potential const-context usage.
Performance Comparison
|
Exactly what it says, I ran `cargo clippy --fix`, briefly checked the generated code to make sure it looked reasonable, and that's what I'm committing.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/home.rs (1)
291-327: Automatic configuration detection logic is sound; consider minor DRY/refactorThe new equality check against
Some("true")plus thebreakon success makes the auto-detection both clearer and safer (no risk of extendingattributemultiple times if more than one candidate matches). This also aligns with the explicit configuration check above.You now have nearly identical “run
nix evaland check for== Some("true")” blocks in both the explicit and automatic branches; consider factoring this into a small helper (e.g.,fn has_attr(...) -> Result<bool>) to reduce duplication and keep future clippy fixes localized.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/commands.rs(3 hunks)src/generations.rs(2 hunks)src/home.rs(2 hunks)src/installable.rs(2 hunks)src/logging.rs(1 hunks)src/nixos.rs(1 hunks)src/util.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
- src/installable.rs
- src/generations.rs
- src/commands.rs
- src/util.rs
- src/nixos.rs
- src/logging.rs
⏰ 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). (6)
- GitHub Check: Test NH on Linux
- GitHub Check: Test NH on Darwin
- GitHub Check: profile
- GitHub Check: Build NH on Linux
- GitHub Check: Build NH on Darwin
- GitHub Check: treewide-checks
🔇 Additional comments (1)
src/home.rs (1)
135-139: Ownership change onout_pathlooks correctUsing
out_pathdirectly in theNonebranch (instead of cloning) is fine here: all prior uses only borrow it, and it’s not used aftertarget_profileis constructed, so this removes an unnecessary clone without changing behavior.
Exactly what it says, I ran
cargo clippy --fix, briefly checked the generated code to make sure it looked reasonable, and that's what I'm committing. This reduces the number of clippy warnings I see by about 10.Sanity Checking
nix fmtto format my Nix codecargo fmtto format my Rust codecargo clippyand fixed any new linter warnings.logic
description.
x86_64-linuxaarch64-linuxx86_64-darwinaarch64-darwinAdd a 👍 reaction to pull requests you find important.
Summary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.