Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static Code Analysis in CI does not actually check any file #275

Closed
boesing opened this issue Jun 29, 2022 · 1 comment
Closed

Static Code Analysis in CI does not actually check any file #275

boesing opened this issue Jun 29, 2022 · 1 comment

Comments

@boesing
Copy link

boesing commented Jun 29, 2022

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

@shadowhand
Copy link
Collaborator

Will be fixed by #304.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants