Problem/Motivation
With PHPStan we ignore errors either through the baseline (that track in which specific file an error occurs) or as global ignore patterns in phpstan.neon.dist.
The problem with the latter ones is that NEW code, failing the checks, can be added to the codebase. This wouldn't occur if there were baseline entries for the existing failures - those will stay until cleaned but no new failure could be introduced.
Proposed resolution
When there is no reason to allow new code to introduce new PHPStan errors, remove global ignore patterns and introduce baselines entries instead.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3260928
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3260928-move-more-phpstan
changes, plain diff MR !1731
Comments
Comment #3
mondrakeThis is introducing approx. 1300 additional baseline entries, for 7 global patterns removed.
Comment #4
mglamanWe should also discuss these:
These are rules in phpstan-drupal I added to help with common code review problems in plugin managers. We could see about removing them from default config or improving them. Like maybe the cache tag thing is a nit and unneeded
Comment #5
mondrakeComment #6
mallezieWould we need some sort of plan to make sure we can get rid of those 1300+ added errors. My main worry here would be we add those, it takes a huge amount of time to fix them, and blocks us from going up to even level 1 (which adds another 1000 items). In theory a 1000+ items baseline is no problem, except it's more difficult to easily spot patterns on what to fix first.
Are there parts here which we can easily fix now, which can reduce a lot of problems. (for the current baseline the deprecated REQUEST TIME is 60% of it for example).
As you mentioned one of the reasons to do this was stop the bleeding of #3260785: [meta] Fix return.missing PHPStan L0 errors. But instead of only committing (and thus enabling that rule) when all items are fixed, we might commit that with the low hanging fruit fixed, and the rule enable, and still add half of the items to the baseline (everything which is not the same simple one line adjustment).
Comment #7
mondrakeI am afraid there are no low hanging fruits in #3260785: [meta] Fix return.missing PHPStan L0 errors. It’s a bunch of more than 300 errors, each potentially with a BC break effect, because if you correct the error than you won’t any more returning null, which even if incorrect, may have been captured by calling code and no longer will. So this issue is about stopping introducing more broken code upfront, then allowing taking the correction path, which will be long… level 1 is quite far ATM.
Comment #8
mallezieOffcourse those changes are more difficult in Drupal due to BC, thanks for reminding this.
One other thing to note when having a large baseline, is that this might introduce more conflicts in the baseline file when multiple patches are pending. Although this might only be an issue on real phpstan cleanup issues, not that much in other patches.
I do fully agree otherwise here, and patch looks good.
Comment #9
mondrakeUpdated baseline
Comment #10
neclimdulHm... we seem to have a different approach to this. I was in the process of doing the exact opposite of the changes in the patch. Bundling up the generic rules so they could be linked to an task issue for addressing them.
Your point is well made about catching changes but the wall enormous wall of items in the baseline doesn't provide a way organize efforts around fixing them and make it very difficult to review the fixable outliers.
Comment #11
mondrakeComment #12
mondrakeSorry I messed up previous commits with a level-1 baseline, now back to level-0.
Comment #13
mondrakeRerolled
Comment #14
alexpottThis needs a reroll because of new things introduced since it was last run - plus #3274016: Remove \Drupal\Core\Test\AssertMailTrait::verboseEmail() from Drupal 10 has landed so the baseline will be a bit smaller.
Comment #15
mondrakewill do later today if no one beats me at that
Comment #16
mondrakeUpdated baseline.
Comment #17
alexpottI think we should proceed here - this will prevent us from making more mistakes like removing TestBase::verbose() but leaving a usage in.
Committed 57a7de3 and pushed to 10.0.x. Thanks!
Comment #20
neclimdulWait, where was the review on this? Self RTBC and commit? I still think this is the wrong approach.
Comment #21
neclimdulI'll just open a new issue with what I think is the correct approach.
Comment #22
mondrake? why you think this is self RTBC? See #8
Comment #23
neclimdulI see 2 pages of changes between and the last RTBC without any reviews other then my objection to the approach which was never addressed. Maybe the merge requests are just handled a bit different but it felt like a self RTBC to me.
Comment #24
xjm@neclimdul Can you link the followup issue here?