Skip to content

refactor: flatten nesting with early returns in FilesHooks and ViewInfoCache#2565

Merged
CarlSchwan merged 2 commits intomasterfrom
refactor/early-returns-2
May 7, 2026
Merged

refactor: flatten nesting with early returns in FilesHooks and ViewInfoCache#2565
CarlSchwan merged 2 commits intomasterfrom
refactor/early-returns-2

Conversation

@miaulalala
Copy link
Copy Markdown
Collaborator

Summary

  • FilesHooks::unShare(): inverted compound guard into an early return to un-nest the share-type dispatch; added 5 tests covering the guard paths (non-file/folder nodeType, deleted node) and all three dispatch branches (TYPE_USER, TYPE_GROUP, TYPE_LINK)
  • FilesHooks::unShareSelf(): same guard-inversion treatment
  • ViewInfoCache::findInfoById(): replaced nested try-catch blocks and a $notFound boolean flag with sequential try-catch blocks and early returns for the success paths

No behaviour changes. All existing tests pass.

Test plan

  • New testUnShare* tests (5 tests) — green
  • FilesHooksTest full suite (62 tests, 517 assertions) — green
  • ViewInfoCacheTest — green

🤖 Generated with Claude Code

miaulalala added 2 commits May 6, 2026 23:37
- 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>
…foCache

- FilesHooks::unShare(): invert guard clause to early return; add tests
  covering the guard (non-file/folder nodeType, deleted node) and all
  dispatch branches (TYPE_USER, TYPE_GROUP, TYPE_LINK)
- FilesHooks::unShareSelf(): same guard-inversion treatment
- ViewInfoCache::findInfoById(): replace nested try-catch and $notFound
  flag with sequential try-catch blocks and early returns

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cypress
Copy link
Copy Markdown

cypress Bot commented May 6, 2026

Activity    Run #3702

Run Properties:  status check passed Passed #3702  •  git commit acc5bb6069: refactor: flatten nesting with early returns in FilesHooks and ViewInfoCache
Project Activity
Branch Review refactor/early-returns-2
Run status status check passed Passed #3702
Run duration 02m 05s
Commit git commit acc5bb6069: refactor: flatten nesting with early returns in FilesHooks and ViewInfoCache
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 ↗︎

@CarlSchwan CarlSchwan merged commit 733082f into master May 7, 2026
100 of 107 checks passed
@CarlSchwan CarlSchwan deleted the refactor/early-returns-2 branch May 7, 2026 08:31
@miaulalala
Copy link
Copy Markdown
Collaborator Author

/backport to stable33

@miaulalala
Copy link
Copy Markdown
Collaborator Author

/backport to stable32

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