From ba7930ff4209374c2817738e408eeeedcf42fa7b Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Tue, 16 Jun 2020 10:06:57 +0100 Subject: [PATCH] Updated static analysis tooling (#2694) --- .github/workflows/checks.yml | 2 +- .github/workflows/static.yml | 10 +++++----- Makefile | 19 +++++++++++++++++++ phpstan-baseline.neon | 20 -------------------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index fdac56ce3..4a248d146 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Roave BC Check uses: docker://nyholm/roave-bc-check-ga diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 0558d935f..8948130b6 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -10,13 +10,13 @@ jobs: phpstan: name: PHPStan runs-on: ubuntu-latest - + steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: PHPStan - uses: docker://oskarstark/phpstan-ga + uses: OskarStark/phpstan-ga@0.12.28 env: REQUIRE_DEV: true with: @@ -28,9 +28,9 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: PHP-CS-Fixer - uses: docker://oskarstark/php-cs-fixer-ga + uses: OskarStark/php-cs-fixer-ga@2.16.3.1 with: args: --dry-run --diff-format udiff diff --git a/Makefile b/Makefile index a58682615..387a46d2e 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,11 @@ help: @echo " docs-show to view the Sphinx docs" @echo " tag to modify the version, update changelog, and chag tag" @echo " package to build the phar and zip files" + @echo " static to run phpstan and php-cs-fixer on the codebase" + @echo " static-phpstan to run phpstan on the codebase" + @echo " static-phpstan-update-baseline to regenerate the phpstan baseline file" + @echo " static-codestyle-fix to run php-cs-fixer on the codebase, writing the changes" + @echo " static-codestyle-check to run php-cs-fixer on the codebase" start-server: stop-server node tests/server.js &> /dev/null & @@ -56,4 +61,18 @@ tag: package: php build/packager.php +static: static-phpstan static-codestyle-check + +static-phpstan: + docker run --rm -it -e REQUIRE_DEV=true -v ${PWD}:/app -w /app oskarstark/phpstan-ga:0.12.28 analyze $(PHPSTAN_PARAMS) + +static-phpstan-update-baseline: + $(MAKE) static-phpstan PHPSTAN_PARAMS="--generate-baseline" + +static-codestyle-fix: + docker run --rm -it -v ${PWD}:/app -w /app oskarstark/php-cs-fixer-ga:2.16.3.1 --diff-format udiff $(CS_PARAMS) + +static-codestyle-check: + $(MAKE) static-codestyle-fix CS_PARAMS="--dry-run" + .PHONY: docs burgomaster coverage-show view-coverage diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 747e2f637..6f81f2857 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -165,11 +165,6 @@ parameters: count: 1 path: src/Cookie/CookieJar.php - - - message: "#^Method GuzzleHttp\\\\Cookie\\\\CookieJar\\:\\:count\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/Cookie/CookieJar.php - - message: "#^Method GuzzleHttp\\\\Cookie\\\\CookieJar\\:\\:getIterator\\(\\) return type has no value type specified in iterable type Traversable\\\\.$#" count: 1 @@ -320,21 +315,11 @@ parameters: count: 1 path: src/Exception/BadResponseException.php - - - message: "#^Method GuzzleHttp\\\\Exception\\\\BadResponseException\\:\\:__construct\\(\\) has parameter \\$message with no typehint specified\\.$#" - count: 1 - path: src/Exception/BadResponseException.php - - message: "#^Method GuzzleHttp\\\\Exception\\\\ConnectException\\:\\:__construct\\(\\) has parameter \\$handlerContext with no value type specified in iterable type array\\.$#" count: 1 path: src/Exception/ConnectException.php - - - message: "#^Method GuzzleHttp\\\\Exception\\\\ConnectException\\:\\:__construct\\(\\) has parameter \\$message with no typehint specified\\.$#" - count: 1 - path: src/Exception/ConnectException.php - - message: "#^Property GuzzleHttp\\\\Exception\\\\RequestException\\:\\:\\$handlerContext type has no value type specified in iterable type array\\.$#" count: 1 @@ -345,11 +330,6 @@ parameters: count: 1 path: src/Exception/RequestException.php - - - message: "#^Method GuzzleHttp\\\\Exception\\\\RequestException\\:\\:__construct\\(\\) has parameter \\$message with no typehint specified\\.$#" - count: 1 - path: src/Exception/RequestException.php - - message: "#^Method GuzzleHttp\\\\Exception\\\\RequestException\\:\\:create\\(\\) has parameter \\$ctx with no value type specified in iterable type array\\.$#" count: 1