vanta / gitlab-rector
Formatter artifacts rector for gitlab
Installs: 7 020
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 0
Forks: 2
Open Issues: 0
Requires
- php: ^8.2
- nette/utils: ^4.0
- rector/rector: ^1.0.1
- violet/streaming-json-encoder: ^1.1
Requires (Dev)
- ergebnis/phpstan-rules: ^2.0
- friendsofphp/php-cs-fixer: ^3.22
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- spaze/phpstan-disallowed-calls: ^2.15
- symfony/var-dumper: ^6.3
README
Install
- call command
composer require --dev vanta/gitlab-rector
- edit config rector.php and add GitlabOutputFormatter
Config if rector >= 1.0.1
<?php declare(strict_types=1); use Rector\Config\RectorConfig; use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector; use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Vanta\Integration\Rector\GitlabOutputFormatter; use Rector\Caching\ValueObject\Storage\FileCacheStorage; use Rector\ChangesReporting\Contract\Output\OutputFormatterInterface; return RectorConfig::configure() ->withCache( cacheDirectory: 'var', cacheClass: FileCacheStorage::class ) ->withTypeCoverageLevel(10) ->withDeadCodeLevel(10) ->withPreparedSets(codeQuality: true, codingStyle: true) ->withAttributesSets(symfony: true, doctrine: true) ->withPaths([ __DIR__ . '/fixture', ]) ->withRules([ ChangeNestedIfsToEarlyReturnRector::class, RemoveAlwaysElseRector::class, ]) ->registerService(GitlabOutputFormatter::class, 'gitlab', OutputFormatterInterface::class) ;
Config if rector >=0.18
<?php declare(strict_types=1); use Rector\ChangesReporting\Contract\Output\OutputFormatterInterface; use Rector\Config\RectorConfig; use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector; use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Rector\Set\ValueObject\SetList; use Vanta\Integration\Rector\GitlabOutputFormatter; return static function (RectorConfig $config): void { $config->paths([ __DIR__ . '/fixture', ]); $config->cacheDirectory('var'); $config->bind(GitlabOutputFormatter::class); $config->tag(GitlabOutputFormatter::class, [OutputFormatterInterface::class]); $config->rules([ ChangeNestedIfsToEarlyReturnRector::class, RemoveAlwaysElseRector::class, ]); $config->sets([ SetList::CODE_QUALITY, ]); };
Config if rector <0.18
<?php declare(strict_types=1); use Rector\Config\RectorConfig; use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector; use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Rector\Set\ValueObject\SetList; use Vanta\Integration\Rector\GitlabOutputFormatter; return static function (RectorConfig $config): void { $config->paths([ __DIR__ . '/fixture', ]); $config->cacheDirectory('var'); $config->services() ->defaults() ->autowire() ->autoconfigure() ->set(GitlabOutputFormatter::class) ; $config->rules([ ChangeNestedIfsToEarlyReturnRector::class, RemoveAlwaysElseRector::class, ]); $config->sets([ SetList::CODE_QUALITY, ]); }
Usage in ci:
lint-rector: stage: lint script: - vendor/bin/rector --dry-run --output-format=gitlab > rector-report.json artifacts: reports: codequality: rector-report.json when: always