Skip to content

Commit

Permalink
Fix some SA issues and allow tools to be run locally easily (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored Nov 14, 2020
1 parent 16f051e commit 647ef44
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 118 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.github/ export-ignore
/test/ export-ignore
/vendor-bin/ export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ jobs:
composer-${{ runner.os }}-
composer-
- name: Install dependencies with Composer
- name: Download dependencies
run: |
composer update --no-interaction --no-progress
composer update --no-interaction --no-progress --optimize-autoloader
- name: Run tests with PHPUnit
run: |
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ jobs:
composer-
- name: Download dependencies
run: composer update --no-interaction --prefer-dist --optimize-autoloader
run: |
composer update --no-interaction --no-progress --optimize-autoloader
composer bin phpstan update --no-interaction --no-progress --optimize-autoloader
- name: PHPStan
uses: docker://oskarstark/phpstan-ga:0.12.49
with:
entrypoint: /composer/vendor/bin/phpstan
args: analyze --no-progress
- name: Run PHPStan
run: |
vendor/bin/phpstan analyze --no-progress
psalm:
name: Psalm
Expand Down Expand Up @@ -84,10 +84,11 @@ jobs:
composer-${{ runner.os }}-
composer-
- name: Install dependencies with composer
- name: Download dependencies
run: |
composer require --dev psalm/phar:3.18.2 --no-update
composer update --no-interaction --no-progress --no-suggest
composer update --no-interaction --no-progress --optimize-autoloader
composer bin psalm update --no-interaction --no-progress --optimize-autoloader
- name: Run vimeo/psalm
run: ./vendor/bin/psalm.phar --config=psalm.xml --shepherd --show-info=false --stats
- name: Run Psalm
run: |
vendor/bin/psalm.phar --no-progress --output-format=github
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build: test ## Runs test targets
build: test static ## Runs test targets

coverage: vendor/autoload.php ## Collects coverage with phpunit
vendor/bin/phpunit --coverage-text --coverage-clover=.build/logs/clover.xml

test: vendor/autoload.php ## Runs tests with phpunit
vendor/bin/phpunit

static: vendor/autoload.php ## Runs static analyzers
vendor/bin/phpstan analyze
vendor/bin/psalm.phar

baseline: vendor/autoload.php ## Generate baseline files
vendor/bin/phpstan analyze --generate-baseline
vendor/bin/psalm.phar --update-baseline

clean: rm -rf vendor composer.lock .build ## Cleans up build and vendor files

vendor/autoload.php:
composer update --no-interaction --prefer-dist
composer update --no-interaction
composer bin all update --no-interaction
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"require-dev": {
"ext-intl": "*",
"bamarni/composer-bin-plugin": "^1.4.1",
"phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.4.2"
},
"autoload": {
Expand Down
80 changes: 0 additions & 80 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ parameters:
count: 1
path: src/Faker/Calculator/Luhn.php

-
message: "#^Method Faker\\\\Factory\\:\\:findProviderClassname\\(\\) should return string but return statement is missing\\.$#"
count: 1
path: src/Faker/Factory.php

-
message: "#^Method Faker\\\\Guesser\\\\Name\\:\\:guessFormat\\(\\) should return callable but return statement is missing\\.$#"
count: 1
path: src/Faker/Guesser/Name.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
Expand Down Expand Up @@ -115,16 +105,6 @@ parameters:
count: 2
path: src/Faker/ORM/Doctrine/EntityPopulator.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: src/Faker/ORM/Doctrine/EntityPopulator.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: src/Faker/ORM/Doctrine/EntityPopulator.php

-
message: "#^Call to method getAssociationNames\\(\\) on an unknown class Doctrine\\\\Common\\\\Persistence\\\\Mapping\\\\ClassMetadata\\.$#"
count: 1
Expand Down Expand Up @@ -265,16 +245,6 @@ parameters:
count: 2
path: src/Faker/ORM/Mandango/EntityPopulator.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: src/Faker/ORM/Mandango/EntityPopulator.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: src/Faker/ORM/Mandango/EntityPopulator.php

-
message: "#^Parameter \\$mandango of method Faker\\\\ORM\\\\Mandango\\\\EntityPopulator\\:\\:execute\\(\\) has invalid typehint type Mandango\\\\Mandango\\.$#"
count: 2
Expand Down Expand Up @@ -440,16 +410,6 @@ parameters:
count: 1
path: src/Faker/ORM/Propel/ColumnTypeGuesser.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: src/Faker/ORM/Propel/EntityPopulator.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: src/Faker/ORM/Propel/EntityPopulator.php

-
message: "#^Parameter \\$columnMap of method Faker\\\\ORM\\\\Propel\\\\EntityPopulator\\:\\:isColumnBehavior\\(\\) has invalid typehint type ColumnMap\\.$#"
count: 2
Expand Down Expand Up @@ -645,16 +605,6 @@ parameters:
count: 1
path: src/Faker/ORM/Propel2/ColumnTypeGuesser.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: src/Faker/ORM/Propel2/EntityPopulator.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: src/Faker/ORM/Propel2/EntityPopulator.php

-
message: "#^Parameter \\$columnMap of method Faker\\\\ORM\\\\Propel2\\\\EntityPopulator\\:\\:isColumnBehavior\\(\\) has invalid typehint type Propel\\\\Runtime\\\\Map\\\\ColumnMap\\.$#"
count: 2
Expand Down Expand Up @@ -740,16 +690,6 @@ parameters:
count: 1
path: src/Faker/ORM/Spot/EntityPopulator.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: src/Faker/ORM/Spot/EntityPopulator.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: src/Faker/ORM/Spot/EntityPopulator.php

-
message: "#^Call to method entity\\(\\) on an unknown class Spot\\\\Mapper\\.$#"
count: 1
Expand Down Expand Up @@ -1025,16 +965,6 @@ parameters:
count: 1
path: src/Faker/Provider/ja_JP/Text.php

-
message: "#^Method Faker\\\\Provider\\\\kk_KZ\\\\Person\\:\\:getCenturyByYear\\(\\) never returns null so it can be removed from the return typehint\\.$#"
count: 1
path: src/Faker/Provider/kk_KZ/Person.php

-
message: "#^Method Faker\\\\Provider\\\\kk_KZ\\\\Person\\:\\:getCenturyByYear\\(\\) should return int\\|null but return statement is missing\\.$#"
count: 1
path: src/Faker/Provider/kk_KZ/Person.php

-
message: "#^PHPDoc tag @param has invalid value \\(string \\[male\\|female\\]\\)\\: Unexpected token \"\\[\", expected variable at offset 221$#"
count: 1
Expand Down Expand Up @@ -1175,16 +1105,6 @@ parameters:
count: 1
path: src/Faker/Provider/pl_PL/Company.php

-
message: "#^Static property Faker\\\\Provider\\\\pl_PL\\\\Person\\:\\:\\$title \\(string\\) does not accept default value of type array\\<int, string\\>\\.$#"
count: 1
path: src/Faker/Provider/pl_PL/Person.php

-
message: "#^Parameter \\#1 \\$array of static method Faker\\\\Provider\\\\Base\\:\\:randomElement\\(\\) expects array, string given\\.$#"
count: 1
path: src/Faker/Provider/pl_PL/Person.php

-
message: "#^Static call to instance method Faker\\\\Provider\\\\pl_PL\\\\Person\\:\\:title\\(\\)\\.$#"
count: 2
Expand Down
23 changes: 1 addition & 22 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.18.2@19aa905f7c3c7350569999a93c40ae91ae4e1626">
<files psalm-version="4.1.1@16bfbd9224698bd738c665f33039fade2a1a3977">
<file src="src/Faker/Calculator/Luhn.php">
<InvalidReturnStatement occurrences="1">
<code>0</code>
Expand All @@ -8,16 +8,6 @@
<code>string</code>
</InvalidReturnType>
</file>
<file src="src/Faker/Factory.php">
<InvalidNullableReturnType occurrences="1">
<code>string</code>
</InvalidNullableReturnType>
</file>
<file src="src/Faker/Guesser/Name.php">
<InvalidNullableReturnType occurrences="1">
<code>callable</code>
</InvalidNullableReturnType>
</file>
<file src="src/Faker/ORM/CakePHP/EntityPopulator.php">
<UndefinedClass occurrences="1">
<code>TableRegistry</code>
Expand Down Expand Up @@ -245,12 +235,6 @@
</InvalidReturnType>
</file>
<file src="src/Faker/Provider/pl_PL/Person.php">
<InvalidArgument occurrences="1">
<code>static::$title</code>
</InvalidArgument>
<InvalidPropertyAssignmentValue occurrences="1">
<code>array('mgr','inż.', 'dr', 'doc.')</code>
</InvalidPropertyAssignmentValue>
<NonStaticSelfCall occurrences="2">
<code>static::title()</code>
<code>static::title()</code>
Expand All @@ -259,11 +243,6 @@
<code>DateTime</code>
</UndefinedDocblockClass>
</file>
<file src="src/Faker/Provider/pt_BR/check_digit.php">
<InvalidArrayAccess occurrences="1">
<code>$numbers[$length-$i]</code>
</InvalidArrayAccess>
</file>
<file src="src/Faker/Provider/sl_SI/Person.php">
<NonStaticSelfCall occurrences="2">
<code>static::lastName()</code>
Expand Down
2 changes: 1 addition & 1 deletion src/Faker/Provider/pl_PL/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Person extends \Faker\Provider\Person
*
* Unisex academic degree
*
* @var string
* @var string[]
*/
protected static $title = array('mgr','inż.', 'dr', 'doc.');

Expand Down
1 change: 1 addition & 0 deletions src/Faker/Provider/pt_BR/check_digit.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
function check_digit($numbers)
{
$numbers = (string) $numbers;
$length = strlen($numbers);
$second_algorithm = $length >= 12;
$verifier = 0;
Expand Down
10 changes: 10 additions & 0 deletions vendor-bin/phpstan/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"require": {
"php": "^7.1 || ^8.0",
"phpstan/phpstan": "0.12.55",
"phpstan/phpstan-deprecation-rules": "0.12.5"
},
"config": {
"preferred-install": "dist"
}
}
9 changes: 9 additions & 0 deletions vendor-bin/psalm/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"require": {
"php": "^7.1 || ^8.0",
"psalm/phar": "4.1.1"
},
"config": {
"preferred-install": "dist"
}
}

0 comments on commit 647ef44

Please sign in to comment.