🧹 [Code Health] Reduce deep nesting in src/apply/ modules#116
Conversation
Refactored the application logic across all resource modules in `src/apply/` to reduce deep nesting. Replaced the outer `if async_fs::try_exists(&dir).await?` blocks with early returns (`if !async_fs::try_exists... return Ok(())`). Replaced the `if path.extension().is_some_and(|ext| ext == "yaml")` checks inside the `while let` loops with early `continue` statements. This flattens the execution flow, reducing indentation by at least two levels, which significantly improves readability and maintainability without altering the behavior. Co-authored-by: ffalcinelli <1167082+ffalcinelli@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #116 +/- ##
==========================================
+ Coverage 93.02% 93.07% +0.05%
==========================================
Files 33 33
Lines 2264 2267 +3
==========================================
+ Hits 2106 2110 +4
+ Misses 158 157 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Replaces `!path.extension().is_some_and(|ext| ext == "yaml")` with `path.extension().is_none_or(|ext| ext != "yaml")` across all modules in `src/apply/` to resolve `clippy::nonminimal_bool` warnings and simplify the boolean expression. Co-authored-by: ffalcinelli <1167082+ffalcinelli@users.noreply.github.com>
🎯 What: The deep nesting issue (>= 6 levels of indentation) was addressed across all resource applicator modules in
src/apply/(roles.rs,groups.rs,clients.rs,idps.rs,users.rs,scopes.rs,flows.rs,actions.rs, andcomponents.rs).💡 Why: Deeply nested code is difficult to read, track execution flow, and maintain. Flattening the logic by returning early when a directory doesn't exist and continuing early when a file isn't a YAML file drastically reduces cognitive overhead.
✅ Verification: Ran
cargo testsuccessfully across the entire workspace to ensure the refactoring didn't introduce any regressions or modify existing behavior.✨ Result: Indentation levels in the core logic loop of all
apply_*functions have been reduced by 2 levels, leading to much cleaner and more readable code.PR created automatically by Jules for task 11313654856211681211 started by @ffalcinelli