webmozarts / assert

Assertions to validate method input/output with nice error messages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Static Code Analysis in CI does not actually check any file

boesing opened this issue · comments

I am currently working on adding a few new psalm-assert features.
While doing so, I got plenty of psalm issues when properly executing it locally.

You can actually verify that no file is being scanned at all by checking the GHA output:

https://github.com/webmozarts/assert/runs/6752858658?check_suite_focus=true

Run ci/vendor/bin/psalm --threads=4
Scanning files...
Analyzing files...
░
------------------------------
No errors found!
------------------------------
Checks took 1.97 seconds and used 148.91[6](https://github.com/webmozarts/assert/runs/6752858658?check_suite_focus=true#step:5:7)MB of memory
Psalm was unable to infer types in the codebase

This should look like:

Run ci/vendor/bin/psalm --threads=4
Scanning files...
Analyzing files...

░░░░░░░░░E░░░░░░░░░░░░░░░░░░░░░░░░░E░░░░░░░░░░░░░░░░E░░░░░░E 60 / 97 (61%)
░░░░░░░░░░░░░░░░E░░░░░░░░░░E░░░░░░░░░

ERROR: InvalidArgument - tests/static-analysis/assert-count.php:51:22 - Argument 1 of Webmozart\Assert\Assert::allCount expects iterable<mixed, Countable|array<array-key, mixed>>, iterable<mixed, Countable|array<array-key, mixed>|null> provided (see https://psalm.dev/004)
    Assert::allCount($value, $number);


ERROR: InvalidArgument - tests/static-analysis/assert-maxLength.php:56:26 - Argument 1 of Webmozart\Assert\Assert::allMaxLength expects iterable<mixed, string>, iterable<mixed, null|string> provided (see https://psalm.dev/004)
    Assert::allMaxLength($value, $max);


ERROR: InvalidArgument - tests/static-analysis/assert-notRegex.php:50:25 - Argument 1 of Webmozart\Assert\Assert::allNotRegex expects iterable<mixed, string>, iterable<mixed, null|string> provided (see https://psalm.dev/004)
    Assert::allNotRegex($value, $pattern);


ERROR: InvalidArgument - tests/static-analysis/assert-propertyExists.php:62:31 - Argument 1 of Webmozart\Assert\Assert::allPropertyExists expects iterable<mixed, class-string|object>, iterable<mixed, class-string|null|object> provided (see https://psalm.dev/004)
    Assert::allPropertyExists($classOrObject, $property);


ERROR: InvalidArgument - tests/static-analysis/assert-regex.php:50:22 - Argument 1 of Webmozart\Assert\Assert::allRegex expects iterable<mixed, string>, iterable<mixed, null|string> provided (see https://psalm.dev/004)
    Assert::allRegex($value, $pattern);


ERROR: InvalidReturnType - tests/static-analysis/assert-throws.php:45:12 - The declared return type 'iterable<mixed, Closure>' for Webmozart\Assert\Tests\StaticAnalysis\allNullOrThrows is incorrect, got 'iterable<mixed, Closure|null>' (see https://psalm.dev/011)
 * @return iterable<Closure>


ERROR: InvalidReturnStatement - tests/static-analysis/assert-throws.php:51:12 - The inferred type 'iterable<mixed, Closure|null>' does not match the declared return type 'iterable<mixed, Closure>' for Webmozart\Assert\Tests\StaticAnalysis\allNullOrThrows (see https://psalm.dev/128)
    return $value;


------------------------------
7 errors found
------------------------------
Psalm can automatically fix 1 of these issues.
Run Psalm again with 
--alter --issues=InvalidReturnType --dry-run
to see what it can fix.
------------------------------

Checks took 1.01 seconds and used 175.763MB of memory
Psalm was able to infer types for 115.3747% of the codebase

I've generated the output above by running the following command in the current master branch at 11cb2199493b2f8a3b53e7f19068fc6aac760991:

ci/vendor/bin/psalm --config=psalm.xml bin tests/static-analysis