-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: add php sniffer for contact methods #1594
Conversation
feat: refactor add_contact and put async sign up behind a flag
In the last PR this method was forgotten
…ector feat: add methods that were in mailchimp data connector
This reverts commit 83e9ed1.
feat: update method calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super cool!
One issue caught by the linter is from src/blocks/subscribe/index.php, which doesn't call the forbidden method from a class. This causes the sniffer to throw a misleading error:
FILE: /home/circleci/project/src/blocks/subscribe/index.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
501 | ERROR | Method
| | Newspack_Newsletters_Subscription::add_contact()
| | should not be called from class
| | NewspackNewslettersContactsMethodsSniff. These methods
| | are for internal use only. Use methods in
| | Newspack_Newsletters_Contacts class instead.
| | (..NewspackNewslettersContactsMethods.ForbiddenContactsMethods)
----------------------------------------------------------------------
Given it includes the filename, it's not too bad, but is there a way to catch that and adjust the messaging?
Thanks! Yes, we could get the filename and add to the error message if we are not inside a class. But looking at it, I think it makes more sense to make it simpler and more generic. 99425a4 does it |
We forgot to merge this to the epic before merging the epic to trunk and now, because of Squash, it was easier to rebuild this PR in a new branch -> #1611 |
All Submissions:
Changes proposed in this Pull Request:
In the effort of consolidating our data flows, we want to enforce that every contact update goes through the same route, starting at
Newspack_Newsletters_Contacts
class to make sure we have the propper logging.However, we can't make all the internal methods private or protected.
This PHP Sniffer helps us avoid adding any new code that will bypass our intended flow. We'll need to add this sniffers to other Newspack plugins as well. - TBD how to do that
How to test the changes in this Pull Request:
./vendor/bin/phpcs
PS - the linting errors in the CI job are expected until we merge #1574
Other information: