Skip to content

Commit b33b804

Browse files
committed
add code analyiis workflow
1 parent 570e9e9 commit b33b804

File tree

6 files changed

+163
-1
lines changed

6 files changed

+163
-1
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Code Analysis
2+
3+
on:
4+
pull_request: null
5+
push:
6+
branches:
7+
- main
8+
9+
env:
10+
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
11+
COMPOSER_ROOT_VERSION: "dev-main"
12+
13+
jobs:
14+
code_analysis:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
actions:
19+
-
20+
name: 'PHPStan'
21+
run: composer phpstan --ansi
22+
23+
-
24+
name: 'Composer Validate'
25+
run: composer validate --ansi
26+
27+
-
28+
name: 'Rector'
29+
run: composer rector --ansi
30+
31+
-
32+
name: 'Coding Standard'
33+
run: composer fix-cs --ansi
34+
35+
-
36+
name: 'PHP Linter'
37+
run: vendor/bin/parallel-lint src tests
38+
39+
-
40+
name: 'Check Commented Code'
41+
run: vendor/bin/easy-ci check-commented-code src tests --ansi
42+
43+
-
44+
name: 'Check Active Classes'
45+
run: vendor/bin/easy-ci check-active-class src --ansi
46+
47+
name: ${{ matrix.actions.name }}
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- uses: actions/checkout@v3
52+
# see https://github.com/shivammathur/setup-php
53+
- uses: shivammathur/setup-php@v2
54+
with:
55+
php-version: 8.1
56+
coverage: none
57+
58+
# composer install cache - https://github.com/ramsey/composer-install
59+
- uses: "ramsey/composer-install@v2"
60+
61+
- run: ${{ matrix.actions.run }}

composer.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
"php": ">=8.1",
77
"nette/utils": "^3.2"
88
},
9+
"require-dev": {
10+
"php-parallel-lint/php-parallel-lint": "^1.3",
11+
"phpstan/extension-installer": "^1.2",
12+
"rector/rector": "^0.15.10",
13+
"symplify/easy-ci": "^11.1",
14+
"symplify/easy-coding-standard": "^11.1",
15+
"symplify/easy-testing": "^11.1",
16+
"symplify/phpstan-extensions": "^11.1",
17+
"symplify/phpstan-rules": "11.2.3.72",
18+
"tomasvotruba/unused-public": "^0.0.34"
19+
},
920
"autoload": {
1021
"psr-4": {
1122
"Symplify\\RuleDocGenerator\\": "src"
@@ -16,6 +27,20 @@
1627
"dev-main": "11.2-dev"
1728
}
1829
},
30+
"scripts": {
31+
"check-cs": "vendor/bin/ecs check --ansi",
32+
"fix-cs": "vendor/bin/ecs check --fix --ansi",
33+
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify",
34+
"rector": "vendor/bin/rector process --dry-run --ansi"
35+
},
1936
"minimum-stability": "dev",
20-
"prefer-stable": true
37+
"prefer-stable": true,
38+
"config": {
39+
"sort-packages": true,
40+
"platform-check": false,
41+
"allow-plugins": {
42+
"cweagans/composer-patches": true,
43+
"phpstan/extension-installer": true
44+
}
45+
}
2146
}

easy-ci.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Symplify\EasyCI\Config\EasyCIConfig;
6+
7+
return static function (EasyCIConfig $easyCIConfig): void {
8+
$easyCIConfig->typesToSkip([
9+
]);
10+
};

ecs.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Symplify\EasyCodingStandard\Config\ECSConfig;
6+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
7+
8+
return static function (ECSConfig $ecsConfig): void {
9+
$ecsConfig->paths([
10+
__DIR__ . '/ecs.php',
11+
__DIR__ . '/rector.php',
12+
__DIR__ . '/easy-ci.php',
13+
__DIR__ . '/src',
14+
]);
15+
16+
$ecsConfig->sets([
17+
SetList::COMMON,
18+
SetList::PSR_12,
19+
]);
20+
};

phpstan.neon

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
parameters:
2+
level: 8
3+
4+
paths:
5+
- src
6+
- tests
7+
8+
excludePaths:
9+
- '*/tests/**/Source/*'
10+
- '*/tests/**/Fixture/*'
11+
- '*/tests/**/data/*'
12+
13+
unused_public:
14+
methods: true
15+
properties: true
16+
constants: true
17+
18+
ignoreErrors:

rector.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\PHPUnit\Set\PHPUnitSetList;
7+
use Rector\Set\ValueObject\LevelSetList;
8+
use Rector\Set\ValueObject\SetList;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->sets([
12+
SetList::CODE_QUALITY,
13+
SetList::DEAD_CODE,
14+
LevelSetList::UP_TO_PHP_81,
15+
SetList::CODING_STYLE,
16+
SetList::TYPE_DECLARATION,
17+
SetList::NAMING,
18+
SetList::PRIVATIZATION,
19+
SetList::EARLY_RETURN,
20+
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
21+
]);
22+
23+
$rectorConfig->paths([
24+
__DIR__ . '/src',
25+
]);
26+
27+
$rectorConfig->importNames();
28+
};

0 commit comments

Comments
 (0)