Automattic / VIP-Coding-Standards

PHP_CodeSniffer ruleset to enforce WordPress VIP coding standards.
https://wpvip.com/documentation/how-to-install-php-code-sniffer-for-wordpress-com-vip/
Other
236 stars 40 forks source link

Review the WordPressVIPMinimum.Functions.RestrictedFunctions sniff #518

Open jrfnl opened 4 years ago

jrfnl commented 4 years ago

Review the WordPressVIPMinimum.Functions.RestrictedFunctions sniff for the following in as far as relevant to that sniff:

Other:

Sniff basics, but changes need to be lined up for next major release:

Once PHPCS/PHPCSUtils supports this:

jrfnl commented 4 years ago

Review notes

From https://github.com/Automattic/VIP-Coding-Standards/pull/561#issue-457419501:

The parent is_targetted_token() method has diverged quite a bit from what is in the method in this class. Rather than address this now, I propose to address this once the improved/namespace and use context aware abstracts in PHPCSUtils are available as this sniff would benefit from switching over to such abstract.

Other than that for the custom code in the is_targetted_token() method, some additional checks could be put in place to guard against both false positives as well as false negatives.

Currently the custom code checks for a particular variable name for an object. However:

Planning / timing

For the switch over to the different parent class, I think it would be opportune to do this relatively quickly after the abstract becomes available as the sniff is looking for a large list of functions and these check would all benefit from the namespace awareness.

For adding additional checks for the object variable, IMO, this can be low priority as effectively the custom code is currently only used for one function check $wp_rewrite->flush_rules().