Skip to content

refactor: flatten nesting with early returns#2564

Merged
CarlSchwan merged 1 commit intomasterfrom
refactor/early-returns
May 7, 2026
Merged

refactor: flatten nesting with early returns#2564
CarlSchwan merged 1 commit intomasterfrom
refactor/early-returns

Conversation

@miaulalala
Copy link
Copy Markdown
Collaborator

Summary

  • Data::setOffsetFromSince(): inverted the two nested guard conditions into early returns, and extracted the repeated fallback DB fetch into a private getFirstKnownActivityHeader() helper — reducing nesting from 3 levels to 1
  • MailQueueHandler::getAffectedUsers(): added an early return in the $restrictEmails !== null branch and extracted the duplicated result-fetching loop into a private fetchAffectedUsers() helper, removing ~10 lines of copy-pasted code

No behaviour changes. All existing tests pass.

Test plan

  • testSetOffsetFromSince (15 tests, 106 assertions) — green
  • MailQueueHandlerTest (10 tests, 93 assertions) — green

🤖 Generated with Claude Code

@miaulalala miaulalala requested a review from artonge May 6, 2026 21:35
@miaulalala miaulalala self-assigned this May 6, 2026
@miaulalala miaulalala added this to the Nextcloud 34 milestone May 6, 2026
@miaulalala miaulalala requested a review from susnux May 6, 2026 21:36
- Data::setOffsetFromSince(): invert guards with early returns and extract
  the repeated fallback fetch into getFirstKnownActivityHeader()
- MailQueueHandler::getAffectedUsers(): early return in the restrictEmails
  branch and extract the duplicated result loop into fetchAffectedUsers()

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@miaulalala miaulalala force-pushed the refactor/early-returns branch from 19c3dfe to b5fd2ff Compare May 6, 2026 21:37
@cypress
Copy link
Copy Markdown

cypress Bot commented May 6, 2026

Activity    Run #3701

Run Properties:  status check passed Passed #3701  •  git commit f7d3ce4286: refactor: flatten nesting with early returns
Project Activity
Branch Review refactor/early-returns
Run status status check passed Passed #3701
Run duration 02m 00s
Commit git commit f7d3ce4286: refactor: flatten nesting with early returns
Committer Anna
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 1
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 9
View all changes introduced in this branch ↗︎

@miaulalala miaulalala requested a review from skjnldsv May 6, 2026 21:44
@miaulalala miaulalala force-pushed the refactor/early-returns branch from 535df72 to b5fd2ff Compare May 6, 2026 21:52
@CarlSchwan CarlSchwan merged commit b5fd2ff into master May 7, 2026
107 checks passed
@CarlSchwan CarlSchwan deleted the refactor/early-returns branch May 7, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants