Skip to content

🧹 [Code Health] Reduce deep nesting in src/apply/ modules#116

Merged
ffalcinelli merged 2 commits into
mainfrom
refactor/reduce-nesting-in-apply-modules-11313654856211681211
May 31, 2026
Merged

🧹 [Code Health] Reduce deep nesting in src/apply/ modules#116
ffalcinelli merged 2 commits into
mainfrom
refactor/reduce-nesting-in-apply-modules-11313654856211681211

Conversation

@ffalcinelli
Copy link
Copy Markdown
Owner

🎯 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, and components.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 test successfully 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

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>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

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

codecov Bot commented May 31, 2026

Codecov Report

❌ Patch coverage is 99.38462% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.07%. Comparing base (a7fb1b8) to head (5851a1e).

Files with missing lines Patch % Lines
src/apply/idps.rs 97.05% 1 Missing ⚠️
src/apply/roles.rs 97.50% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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>
@ffalcinelli ffalcinelli merged commit 113c547 into main May 31, 2026
9 checks passed
@ffalcinelli ffalcinelli deleted the refactor/reduce-nesting-in-apply-modules-11313654856211681211 branch May 31, 2026 11:05
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