Add PHPStan CI check and pre-push hook, PG-4897 [no_release] - #229
Open
snake14 wants to merge 4 commits into
Open
Add PHPStan CI check and pre-push hook, PG-4897 [no_release]#229snake14 wants to merge 4 commits into
snake14 wants to merge 4 commits into
Conversation
The level-1 phpstan.neon existed but nothing enforced it; the code passes level 5 with targeted ignores for two invariants the analysis cannot see and one finding in an immutable released update file.
Uncommitted local changes were analyzed and could block a push for files the push doesn't contain. Also corrects the hook's log label.
Pushing another local branch, or several refs at once, analysed the checked-out branch instead of what was actually pushed.
A plugin cloned outside a Matomo checkout cannot be checked, which is no reason to block its pushes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Enforces the PHPStan static analysis this plugin already had configured: a
phpstan.neonexisted at level 1 but no CI check or git hook ran it. This adds the same setup used by other Matomo plugins (e.g. plugin-Slack, plugin-LoginLdap): a GitHub Actions check on every pull request, plus an optional pre-push git hook that analyses changed files (enable it withgit config core.hooksPath .git-hooks-matomo).The analysis level is raised from 1 to 5, the highest level the existing code passes (level 6 reports 104 errors). No behaviour changes: the two findings in
API.phpare a same-shape invariant between two DataTables that the analysis cannot see, theRecordBuildersfinding is a compatibility guard for Matomo < 5.2.0-b6 that the declared support range still needs, and the finding in the releasedUpdates/5.1.0.phpis ignored via a path-scoped config entry because released update files are immutable history. New files are held to level 9 and modified files to level 5 by the hook, matching the other plugins.Issue No
PG-4897
Steps to Replicate the Issue
composer run phpstan -- -c plugins/MarketingCampaignsReporting/phpstan.neon.Checklist