plusforta / gitlab-rector
Formatter artifacts rector for gitlab
0.7.0
2026-03-17 08:27 UTC
Requires
- php: ^8.2
- nette/utils: ^4.0
- rector/rector: ^1.0.1|^2.0
- violet/streaming-json-encoder: ^1.1
Requires (Dev)
- friendsofphp/php-cs-fixer: 3.68.5
- phpstan/extension-installer: 1.4.3
- phpstan/phpstan: ^2.0
- spaze/phpstan-disallowed-calls: 4.0.1
- symfony/var-dumper: ^6.3
README
A custom output formatter for Rector that generates GitLab Code Quality compatible reports.
Note: This is a maintained fork of vanta/gitlab-rector.
Install
- Run
composer require --dev plusforta/gitlab-rector - Edit your
rector.phpconfig and registerGitlabOutputFormatter
Configuration (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 PlusForta\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__ . '/src',
])
->withRules([
ChangeNestedIfsToEarlyReturnRector::class,
RemoveAlwaysElseRector::class,
])
->registerService(GitlabOutputFormatter::class, 'gitlab', OutputFormatterInterface::class)
;
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
License
MIT