Skip to content

Commit

Permalink
Upgraded static analyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Dec 26, 2021
1 parent 4f55a7d commit 95b1eb0
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 253 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@
/psalm.xml export-ignore
/CHANGELOG.md export-ignore
/README.md export-ignore
/rector.php export-ignore
43 changes: 2 additions & 41 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: '8.0'
tools: composer:2.1
coverage: none

Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: '8.0'
tools: composer:2.1
coverage: none

Expand All @@ -68,42 +68,3 @@ jobs:

- name: Execute Psalm
run: vendor/bin/psalm.phar --no-progress --output-format=github

rector:
name: Rector
runs-on: ubuntu-20.04

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:2.1, cs2pr
coverage: none

- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress

- name: Install PHPUnit
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer bin phpunit update --no-interaction --no-progress

- name: Install Rector
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer bin rector update --no-interaction --no-progress

- name: Execute Rector
run: vendor/bin/rector process --dry-run --output-format=checkstyle | cs2pr
24 changes: 9 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
install:
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:7.4-base update
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:7.4-base bin all update
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.0-base update
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.0-base bin all update

phpunit:
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:7.4-cli
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:8.0-cli

phpstan-analyze:
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:7.4-cli analyze
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.0-cli analyze

phpstan-baseline:
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:7.4-cli analyze --generate-baseline
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.0-cli analyze --generate-baseline

psalm-analyze:
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:7.4-cli
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.0-cli

psalm-baseline:
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:7.4-cli --set-baseline=psalm-baseline.xml
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.0-cli --set-baseline=psalm-baseline.xml

psalm-show-info:
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:7.4-cli --show-info=true
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.0-cli --show-info=true

rector-dry-run:
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/rector --rm registry.gitlab.com/grahamcampbell/php:7.4-cli process --dry-run

rector-fix:
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/rector --rm registry.gitlab.com/grahamcampbell/php:7.4-cli process

test: phpunit phpstan-analyze psalm-analyze rector-dry-run
test: phpunit phpstan-analyze psalm-analyze

clean:
@rm -rf .phpunit.result.cache composer.lock vendor vendor-bin/*/composer.lock vendor-bin/*/vendor
15 changes: 15 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ parameters:
count: 1
path: src/Api/AbstractApi.php

-
message: "#^Parameter \\#2 \\$resource of method Http\\\\Message\\\\MultipartStream\\\\MultipartStreamBuilder\\:\\:addResource\\(\\) expects Psr\\\\Http\\\\Message\\\\StreamInterface\\|resource\\|string, mixed given\\.$#"
count: 1
path: src/Api/AbstractApi.php

-
message: "#^Property Gitlab\\\\Api\\\\AbstractApi\\:\\:\\$perPage is never written, only read\\.$#"
count: 1
path: src/Api/AbstractApi.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: src/HttpClient/Util/QueryStringBuilder.php

-
message: "#^Variable method call on Gitlab\\\\Api\\\\AbstractApi\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ parameters:
paths:
- src
ignoreErrors:
- "#Anonymous function should have native return typehint#"
- '#Only booleans are allowed in an if condition#'
- '#PHPDoc tag \@var above a method has no effect.#'
7 changes: 1 addition & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.3.1@2feba22a005a18bf31d4c7b9bdb9252c73897476">
<files psalm-version="4.x-dev@">
<file src="src/Api/AbstractApi.php">
<InvalidArgument occurrences="1"/>
</file>
<file src="src/HttpClient/Util/JsonArray.php">
<UndefinedFunction occurrences="1">
<code>\get_debug_type($data)</code>
</UndefinedFunction>
</file>
<file src="src/ResultPager.php">
<InaccessibleProperty occurrences="1">
<code>$clone-&gt;perPage</code>
Expand Down
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<issueHandlers>
<PossiblyInvalidDocblockTag errorLevel="info" />
</issueHandlers>
<projectFiles>
<directory name="src" />
</projectFiles>
Expand Down
170 changes: 0 additions & 170 deletions rector.php

This file was deleted.

12 changes: 6 additions & 6 deletions vendor-bin/phpstan/composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"require": {
"php": "^7.2.5 || ^8.0",
"phpstan/phpstan": "0.12.82",
"phpstan/phpstan-deprecation-rules": "0.12.6",
"phpstan/phpstan-strict-rules": "0.12.9",
"thecodingmachine/phpstan-strict-rules": "0.12.1",
"ergebnis/phpstan-rules": "0.15.3"
"php": "^8.0.2",
"phpstan/phpstan": "1.2.0",
"phpstan/phpstan-deprecation-rules": "1.0.0",
"phpstan/phpstan-strict-rules": "1.1.0",
"thecodingmachine/phpstan-strict-rules": "1.0.0",
"ergebnis/phpstan-rules": "1.0.0"
},
"config": {
"preferred-install": "dist"
Expand Down
4 changes: 2 additions & 2 deletions vendor-bin/phpunit/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"php": "^7.2.5 || ^8.0",
"phpunit/phpunit": "^8.5.15 || ^9.5.4"
"php": "^7.2.5 || ^8.0.2",
"phpunit/phpunit": "^8.5.22 || ^9.5.11"
},
"config": {
"preferred-install": "dist"
Expand Down
4 changes: 2 additions & 2 deletions vendor-bin/psalm/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"php": "^7.2.5 || ^8.0",
"psalm/phar": "4.6.3"
"php": "^8.0.2",
"psalm/phar": "4.16.1"
},
"config": {
"preferred-install": "dist"
Expand Down
9 changes: 0 additions & 9 deletions vendor-bin/rector/composer.json

This file was deleted.

1 change: 1 addition & 0 deletions vendor-bin/update/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}

0 comments on commit 95b1eb0

Please sign in to comment.