Skip to content

Commit

Permalink
build(ci): Add Rector into static analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Czarnecki committed Jan 2, 2024
1 parent 4ff99e4 commit 8c86060
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Coding Standards"

on:
pull_request:
push:
branches:
- "master"

jobs:
coding-standards:
name: "Coding Standards"
runs-on: "ubuntu-20.04"

strategy:
matrix:
php-version:
- "7.4"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: "cs2pr"
extensions: pdo_sqlite

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: "Run PHP_CodeSniffer"
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
4 changes: 4 additions & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ jobs:

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"

- name: "Run a static analysis with rector/rector"
run: "vendor/bin/rector --dry-run"
if: ${{ matrix.php-version == 8.2 }}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"phpstan/phpstan": "^1.0.2",
"phpunit/phpunit": "^9.0 || ^10.0",
"psr/container": "^1.0 || ^2.0",
"rector/rector": "^0.18.13",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/expression-language": "^5.4 || ^6.0 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0",
Expand Down
13 changes: 13 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig) {
$rectorConfig->paths([
__DIR__ . '/src',
]);
$rectorConfig->sets([LevelSetList::UP_TO_PHP_74]);
};

0 comments on commit 8c86060

Please sign in to comment.