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
- Class
Autoloaded_Options_Check should be created and exists at includes/Checker/Checks
- Class
Autoloaded_Options_Check should extend the PHPCodesniffer_Check abstract class which extends Check interface
- Property
$violation code should be warning
- Method
run should be implemented from the PHPCodesniffer_Check abstract class if needed
Check_Result $check_result should be used from the run method parameter to append the results
$_SERVER['argv'] arguments should be passed to parent run method to provide PHPCS information about standard, report and sniff
- Custom sniff to detect the usage of
$autoload option to true or false
Tests Coverage
Autoloaded_Options_Check class expected to extend PHPCodesniffer_Check abstract class
Autoloaded_Options_Check class expected to be instance of PHPCodesniffer_Check class
run method expected to append results of check into $check_result
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_Checkshould be created and exists atincludes/Checker/ChecksAutoloaded_Options_Checkshould extend thePHPCodesniffer_Checkabstract class which extendsCheckinterface$violationcode should bewarningrunshould be implemented from thePHPCodesniffer_Checkabstract class if neededCheck_Result $check_resultshould be used from therunmethod parameter to append the results$_SERVER['argv']arguments should be passed to parentrunmethod to provide PHPCS information aboutstandard,reportandsniff$autoloadoption to true or falseTests Coverage
Autoloaded_Options_Checkclass expected to extendPHPCodesniffer_Checkabstract classAutoloaded_Options_Checkclass expected to be instance ofPHPCodesniffer_Checkclassrunmethod expected to append results of check into$check_result