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

build: Add rector #3248

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"psalm:update-baseline": "psalm --threads=$(nproc) --no-cache --update-baseline",
"psalm:fix": "psalm --no-cache --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
"test:unit": "phpunit -c tests/phpunit.xml",
"test:unit:coverage": "XDEBUG_MODE=coverage phpunit -c tests/phpunit.xml"
"test:unit:coverage": "XDEBUG_MODE=coverage phpunit -c tests/phpunit.xml",
"rector": "rector && composer cs:fix"
},
"config": {
"allow-plugins": {
Expand Down
2 changes: 1 addition & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function boot(IBootContext $context): void {
$context->injectFn(function (IMountProviderCollection $mountProviderCollection, CacheListener $cacheListener, Group\Manager $groupManager): void {
$mountProviderCollection->registerProvider($this->getMountProvider());

$groupManager->listen('\OC\Group', 'postDelete', function (IGroup $group) {
$groupManager->listen('\OC\Group', 'postDelete', function (IGroup $group): void {
$this->getFolderManager()->deleteGroup($group->getGID());
});
$cacheListener->listen();
Expand Down
6 changes: 3 additions & 3 deletions lib/Command/ExpireGroup/ExpireGroupVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ protected function configure(): void {
}

protected function execute(InputInterface $input, OutputInterface $output): int {
$this->expireManager->listen(GroupVersionsExpireManager::class, 'enterFolder', function (array $folder) use ($output) {
$this->expireManager->listen(GroupVersionsExpireManager::class, 'enterFolder', function (array $folder) use ($output): void {
$output->writeln("<info>Expiring version in '{$folder['mount_point']}'</info>");
});
$this->expireManager->listen(GroupVersionsExpireManager::class, 'deleteVersion', function (IVersion $version) use ($output) {
$this->expireManager->listen(GroupVersionsExpireManager::class, 'deleteVersion', function (IVersion $version) use ($output): void {
$id = $version->getRevisionId();
$file = $version->getSourceFileName();
$output->writeln("<info>Expiring version $id for '$file'</info>");
});

$this->expireManager->listen(GroupVersionsExpireManager::class, 'deleteFile', function ($id) use ($output) {
$this->expireManager->listen(GroupVersionsExpireManager::class, 'deleteFile', function ($id) use ($output): void {
$output->writeln("<info>Cleaning up versions for no longer existing file with id $id</info>");
});

Expand Down
4 changes: 2 additions & 2 deletions lib/Command/Scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
return -1;
}

$scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($output, &$statsRow) {
$scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($output, &$statsRow): void {
$output->writeln("\tFile\t<info>/$path</info>", OutputInterface::VERBOSITY_VERBOSE);
$statsRow[2]++;
// abortIfInterrupted doesn't exist in nc14
Expand All @@ -101,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}
});

$scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($output, &$statsRow) {
$scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($output, &$statsRow): void {
$output->writeln("\tFolder\t<info>/$path</info>", OutputInterface::VERBOSITY_VERBOSE);
$statsRow[1]++;
// abortIfInterrupted doesn't exist in nc14
Expand Down
18 changes: 18 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/lib',
__DIR__ . '/tests',
])
->withSkip([
__DIR__ . '/tests/stubs',
])
->withTypeCoverageLevel(0);
5 changes: 5 additions & 0 deletions vendor-bin/rector/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require-dev": {
"rector/rector": "^1.2"
}
}
136 changes: 136 additions & 0 deletions vendor-bin/rector/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading