-
-
Notifications
You must be signed in to change notification settings - Fork 331
Static Analyzer (PHPStan) Integration #671
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
base: master
Are you sure you want to change the base?
Conversation
7df86c9 to
861d949
Compare
861d949 to
4fbfde3
Compare
659e30c to
dbfeee5
Compare
dbfeee5 to
e923793
Compare
e923793 to
ef3729b
Compare
ef3729b to
e701ccb
Compare
e701ccb to
8d47c4d
Compare
|
Hey, I'm not sure how I feel about this, hence the delay in responding. I can see how this can be helpful, but on the other hand also very annoying with false positives, especially in the slightly unconventional Clockwork code-base. Anyway, before we can think about trying this, we need to solve two big problems:
Thanks for the PR tho. |
Specifically that is - phpstan/phpstan - the linter itself - phpstan/extension-installer - convenience package for loading extensions - spaze/phpstan-disallowed-calls - an extension that checks for some additional flaws
8d47c4d to
0c16484
Compare
The baseline lists the existing flaws that were found. This has two uses: - We can use a high sensitivity for scanning, without having to fix all issues right away. - It still prevents new issues from coming up and also tracks resolved issues.
This should prevent regressions in code flaws detected by PHPStan. Also, PHPStan complains when the baseline is not advanced after fixing a flaw. This should prevent a flaw from reappearing later on.
0c16484 to
a96df53
Compare
|
About how to deal with third-party dependencies, I have no idea. I never worked on a similar codebase that had so many "optional" parts. The approach I took here was to simply restrict scanning to the core components and ignore the optional ones. I could imagine running multiple scans with different third-party dependencies installed, but I have no clear idea how to manage that. The scanning level 9 isn't actually a problem. Yes, it finds lots of issues, but it doesn't raise them as errors. Instead, they first get matched against the known ones in the baseline. That way, you will only receive notifications for code that is touched by your own changes, and that isn't much in practice. I just updated the PR, there were some changes to the code it scanned. Still, I'm also not fully satisfied by the use of a baseline in the code. What I prefer is the Code Quality feature of GitLab, which manages the baseline for you as part of its CI/CD. That relieves you from any manual baseline management and it integrates in the code review. |
|
Take a look at UlrichEckhardt#6. This makes any baseline completely redundant, because that is now managed by GitHub's infrastructure and properly integrated into the PRs. I think that this could be the way to go. What do you think? |
Greetings,
this PR integrates PHPStan into the Clockwork sources. The analyzer is automatically executed on every push using a Github action. As alternatives to PHPStan, there would be Psalm and perhaps SonarQube. I have worked with Psalm before and it works similarly to PHPStan. About SonarQube, I can't say much, but it seems to have a much larger scope. In particular, it provides a multi-language (not just PHP) framework and also includes support for making code reviews.
If you look at the README, there is a section on how to work with PHPStan, also the commit messages should contain some interesting context infos.
As for what drove me to develop this
Cheers!
Uli