feat: 🧑‍💻 add rector
All checks were successful
repod / xml (push) Successful in 11s
repod / php (push) Successful in 1m7s
repod / nodejs (push) Successful in 1m6s
repod / release (push) Has been skipped

This commit is contained in:
Michel Roux 2024-11-10 13:18:53 +01:00
parent 66cb15ee32
commit 25af5bdf54
14 changed files with 174 additions and 27 deletions

View File

@ -12,12 +12,14 @@
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './vendor-bin/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix",
"psalm": "psalm --threads=1 --no-cache --show-info=true"
"psalm": "psalm --threads=1 --no-cache --show-info=true",
"rector": "rector && composer cs:fix"
},
"require-dev": {
"nextcloud/ocp": "^30.0.2",
"roave/security-advisories": "dev-latest",
"nextcloud/coding-standard": "^1.3.2",
"rector/rector": "^1.2.10",
"roave/security-advisories": "dev-latest",
"vimeo/psalm": "^5.26.1"
},
"config": {

133
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "2bded493404c793fc0cfceedfeccc38c",
"content-hash": "1b3b97dd0074d6decb4ce7f570ef7d4e",
"packages": [],
"packages-dev": [
{
@ -1049,23 +1049,23 @@
},
{
"name": "phpdocumentor/type-resolver",
"version": "1.9.0",
"version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d"
"reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/1fb5ba8d045f5dd984ebded5b1cc66f29459422d",
"reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a",
"reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a",
"shasum": ""
},
"require": {
"doctrine/deprecations": "^1.0",
"php": "^7.3 || ^8.0",
"phpdocumentor/reflection-common": "^2.0",
"phpstan/phpdoc-parser": "^1.18"
"phpstan/phpdoc-parser": "^1.18|^2.0"
},
"require-dev": {
"ext-tokenizer": "*",
@ -1101,9 +1101,9 @@
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.9.0"
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.10.0"
},
"time": "2024-11-03T20:11:34+00:00"
"time": "2024-11-09T15:12:26+00:00"
},
{
"name": "phpstan/phpdoc-parser",
@ -1152,6 +1152,64 @@
},
"time": "2024-10-13T11:25:22+00:00"
},
{
"name": "phpstan/phpstan",
"version": "1.12.8",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "f6a60a4d66142b8156c9da923f1972657bc4748c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/f6a60a4d66142b8156c9da923f1972657bc4748c",
"reference": "f6a60a4d66142b8156c9da923f1972657bc4748c",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
}
],
"time": "2024-11-06T19:06:49+00:00"
},
{
"name": "psr/clock",
"version": "1.0.0",
@ -1353,6 +1411,65 @@
},
"time": "2021-07-14T16:41:46+00:00"
},
{
"name": "rector/rector",
"version": "1.2.10",
"source": {
"type": "git",
"url": "https://github.com/rectorphp/rector.git",
"reference": "40f9cf38c05296bd32f444121336a521a293fa61"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/40f9cf38c05296bd32f444121336a521a293fa61",
"reference": "40f9cf38c05296bd32f444121336a521a293fa61",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0",
"phpstan/phpstan": "^1.12.5"
},
"conflict": {
"rector/rector-doctrine": "*",
"rector/rector-downgrade-php": "*",
"rector/rector-phpunit": "*",
"rector/rector-symfony": "*"
},
"suggest": {
"ext-dom": "To manipulate phpunit.xml via the custom-rule command"
},
"bin": [
"bin/rector"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
"keywords": [
"automation",
"dev",
"migration",
"refactoring"
],
"support": {
"issues": "https://github.com/rectorphp/rector/issues",
"source": "https://github.com/rectorphp/rector/tree/1.2.10"
},
"funding": [
{
"url": "https://github.com/tomasvotruba",
"type": "github"
}
],
"time": "2024-11-08T13:59:10+00:00"
},
{
"name": "roave/security-advisories",
"version": "dev-latest",

View File

@ -16,6 +16,7 @@ use OCP\AppFramework\Services\IInitialState;
class Application extends App implements IBootstrap
{
public const APP_ID = 'repod';
private const GPODDERSYNC_ID = 'gpoddersync';
public function __construct() {
@ -40,7 +41,7 @@ class Application extends App implements IBootstrap
if (!$gpoddersync) {
try {
$appManager->enableApp(self::GPODDERSYNC_ID);
} catch (AppPathNotFoundException $e) {
} catch (AppPathNotFoundException) {
}
}

View File

@ -37,8 +37,8 @@ class EpisodesController extends Controller
$client = $this->clientService->newClient();
$feed = $client->get($url);
$episodes = $this->episodeActionReader->parseRssXml((string) $feed->getBody());
usort($episodes, fn (EpisodeActionExtraData $a, EpisodeActionExtraData $b) => $b->getPubDate() <=> $a->getPubDate());
$episodes = array_values(array_intersect_key($episodes, array_unique(array_map(fn (EpisodeActionExtraData $episode) => $episode->getGuid(), $episodes))));
usort($episodes, fn (EpisodeActionExtraData $a, EpisodeActionExtraData $b): int => $b->getPubDate() <=> $a->getPubDate());
$episodes = array_values(array_intersect_key($episodes, array_unique(array_map(fn (EpisodeActionExtraData $episode): string => $episode->getGuid(), $episodes))));
return new JSONResponse($episodes, $feed->getStatusCode());
}

View File

@ -55,7 +55,7 @@ class OpmlController extends Controller
foreach ($subscriptions as $subscription) {
try {
$podcast = $this->podcastDataReader->getCachedOrFetchPodcastData($subscription->getUrl(), $this->userService->getUserUID());
} catch (\Exception $e) {
} catch (\Exception) {
continue;
}

View File

@ -11,15 +11,13 @@ use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IRequest;
use OCP\Util;
class PageController extends Controller
{
public function __construct(
IRequest $request,
private IConfig $config
IRequest $request
) {
parent::__construct(Application::APP_ID, $request);
}

View File

@ -36,7 +36,7 @@ class PodcastController extends Controller
if ($this->cacheFactory->isLocalCacheAvailable()) {
try {
$podcast = $this->podcastDataReader->tryGetCachedPodcastData($url);
} catch (\Exception $e) {
} catch (\Exception) {
}
}
@ -51,7 +51,7 @@ class PodcastController extends Controller
if ($this->cacheFactory->isLocalCacheAvailable()) {
try {
$this->podcastDataReader->trySetCachedPodcastData($url, $podcast);
} catch (\Exception $e) {
} catch (\Exception) {
}
}

View File

@ -28,7 +28,7 @@ use OCA\GPodderSync\Core\EpisodeAction\EpisodeAction;
* action: ?EpisodeActionType
* }
*/
class EpisodeActionExtraData implements \JsonSerializable
class EpisodeActionExtraData implements \JsonSerializable, \Stringable
{
public function __construct(
private string $title,
@ -120,7 +120,7 @@ class EpisodeActionExtraData implements \JsonSerializable
'size' => $this->size,
'pubDate' => $this->pubDate,
'duration' => $this->duration,
'action' => $this->action ? $this->action->toArray() : null,
'action' => $this->action instanceof EpisodeAction ? $this->action->toArray() : null,
];
}

View File

@ -107,7 +107,7 @@ class EpisodeActionReader extends CoreEpisodeActionReader
if (isset($pubDate)) {
try {
$pubDate = new \DateTime($pubDate);
} catch (\Exception $e) {
} catch (\Exception) {
$pubDate = null;
}
}

View File

@ -94,8 +94,8 @@ class FyydService implements IPodProvider
if (array_key_exists('data', $langJson) && is_array($langJson['data'])) {
$language = in_array($userLang, $langJson['data']) ? $userLang : 'en';
}
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), $e->getTrace());
} catch (\Exception $exception) {
$this->logger->error($exception->getMessage(), $exception->getTrace());
}
$podcastClient = $this->clientService->newClient();

View File

@ -36,7 +36,7 @@ class MultiPodService implements IPodProvider
}
}
usort($podcasts, fn (PodcastData $a, PodcastData $b) => $b->getFetchedAtUnix() <=> $a->getFetchedAtUnix());
usort($podcasts, fn (PodcastData $a, PodcastData $b): int => $b->getFetchedAtUnix() <=> $a->getFetchedAtUnix());
return array_values(
array_intersect_key(

View File

@ -30,7 +30,7 @@ class SearchProvider implements IProvider
}
public function getOrder(string $route, array $routeParameters): int {
if (0 === strpos($route, Application::APP_ID.'.')) {
if (str_starts_with($route, Application::APP_ID.'.')) {
// Active app, prefer my results
return -1;
}

View File

@ -27,7 +27,7 @@ class UserService
public function getCountryCode(): string {
$isoCodes = explode('_', $this->getIsoCode());
return isset($isoCodes[1]) ? $isoCodes[1] : 'us';
return $isoCodes[1] ?? 'us';
}
public function getLangCode(): string {

29
rector.php Normal file
View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withPaths([
__DIR__.'/lib',
])
->withPhpSets(php80: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
privatization: true,
instanceOf: true,
earlyReturn: true,
strictBooleans: true,
rectorPreset: true,
phpunitCodeQuality: true,
doctrineCodeQuality: true,
symfonyCodeQuality: true,
symfonyConfigs: true,
twig: true,
phpunit: true,
)
;