Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor files_trashbin app commands #39882

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fsamapoor
Copy link
Member

Summary

I have made some adjustments to the apps/files_trashbin/lib/Command classes to improve the code readability.

The improvements in this PR include but are not limited to:

  • Using PHP8's constructor property promotion
  • Adding return types
  • Replacing return code integers with more readable strings.
  • Using early returns

Checklist

$query->delete('files_trash')
->where($query->expr()->eq('user', $query->createParameter('uid')))
->setParameter('uid', $uid);
$query->execute();

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\DB\QueryBuilder\IQueryBuilder::execute has been marked as deprecated
$userObject = $this->userManager->get($user);
$this->expireTrashForUser($userObject);
} else {
if (! $this->userManager->userExists($user)) {

Check notice

Code scanning / Psalm

PossiblyNullReference Note

Cannot call method userExists on possibly null value

$output->writeln("Remove deleted files of <info>$user</info>");
$userObject = $this->userManager->get($user);
$this->expireTrashForUser($userObject);

Check notice

Code scanning / Psalm

PossiblyNullArgument Note

Argument 1 of OCA\Files_Trashbin\Command\ExpireTrash::expireTrashForUser cannot be null, possibly null value provided

$p = new ProgressBar($output);
$p->start();
$this->userManager->callForSeenUsers(function (IUser $user) use ($p) {

Check notice

Code scanning / Psalm

PossiblyNullReference Note

Cannot call method callForSeenUsers on possibly null value
@fsamapoor fsamapoor added 3. to review Waiting for reviews technical debt labels Aug 15, 2023
@fsamapoor fsamapoor added this to the Nextcloud 28 milestone Aug 15, 2023
@fsamapoor fsamapoor requested review from a team, icewind1991, blizzz and Fenn-CS and removed request for a team August 15, 2023 18:31
@fsamapoor fsamapoor force-pushed the refactor_files_trashbin_app_commands branch from 42794ad to 35b0f7a Compare September 21, 2023 05:55
@fsamapoor
Copy link
Member Author

Conflicts resolved!

@blizzz blizzz removed their request for review September 21, 2023 08:12
@skjnldsv skjnldsv mentioned this pull request Nov 1, 2023
This was referenced Nov 6, 2023
This was referenced Nov 14, 2023
@blizzz blizzz modified the milestones: Nextcloud 28, Nextcloud 29 Nov 23, 2023
@fsamapoor fsamapoor force-pushed the refactor_files_trashbin_app_commands branch from 35b0f7a to e5e9aed Compare January 3, 2024 07:30
@AndyScherzinger AndyScherzinger force-pushed the refactor_files_trashbin_app_commands branch from e5e9aed to e085779 Compare February 27, 2024 13:29
}

return 0;
$this->config->setAppValue('files_trashbin', 'trashbin_size', (string)$parsedSize);

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IConfig::setAppValue has been marked as deprecated
Faraz Samapoor added 2 commits March 8, 2024 19:19
To improve code readability.

Signed-off-by: Faraz Samapoor <fsa@adlas.at>
To improve code readability.

Signed-off-by: Faraz Samapoor <fsa@adlas.at>
@fsamapoor fsamapoor force-pushed the refactor_files_trashbin_app_commands branch from e085779 to 754b425 Compare March 8, 2024 15:49
This was referenced Mar 12, 2024
This was referenced Mar 20, 2024
@skjnldsv skjnldsv mentioned this pull request Mar 28, 2024
81 tasks
This was referenced Apr 4, 2024
@blizzz blizzz modified the milestones: Nextcloud 29, Nextcloud 30 Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants