-
Notifications
You must be signed in to change notification settings - Fork 54
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
Create Autoloaded_Options_Check #28
Comments
@jjgrainger I will update AC for this issue, thanks! 🙂 |
Such a custom sniff is probably best contributed to WPCS first. We don't have precedence for any sniffs in this plugin itself I think, plus contributing it upstream ensures high visibility and code quality. |
No longer true, we now have some custom sniffs in the plugin |
There is some progress on the WPCS side: WordPress/WordPress-Coding-Standards#2473 |
Nice! |
Description
Checks the usage of the add_option and update_option functions and warns if the $autoload parameter is not set, i.e. the default $autoload value is used, which is true. Too many autoloaded options can lead to performance issues so this option should not be set to true unless necessary. No existing sniff exists but the existing WordPress.WP.EnqueuedResourceParameters sniff in the WordPress Coding Standards can be used as a starting point.
Potentially, a warning could be triggered if "yes" is passed, but the most important part is to highlight the importance of considering that parameter and what it means for performance.
Acceptance Criteria
Autoloaded_Options_Check
should be created and exists atincludes/Checker/Checks
Autoloaded_Options_Check
should extend thePHPCodesniffer_Check
abstract class which extendsCheck
interface$violation
code should bewarning
run
should be implemented from thePHPCodesniffer_Check
abstract class if neededCheck_Result $check_result
should be used from therun
method parameter to append the results$_SERVER['argv']
arguments should be passed to parentrun
method to provide PHPCS information aboutstandard
,report
andsniff
$autoload
option to true or falseTests Coverage
Autoloaded_Options_Check
class expected to extendPHPCodesniffer_Check
abstract classAutoloaded_Options_Check
class expected to be instance ofPHPCodesniffer_Check
classrun
method expected to append results of check into$check_result
The text was updated successfully, but these errors were encountered: