WordPress / WordPress/plugin-check
Create Autoloaded_Options_Check
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 362
- Forks
- 126
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 22
Description
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_Checkshould be created and exists atincludes/Checker/Checks - Class
Autoloaded_Options_Checkshould extend thePHPCodesniffer_Checkabstract class which extendsCheckinterface - Property
$violationcode should bewarning - Method
runshould be implemented from thePHPCodesniffer_Checkabstract class if needed Check_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- Custom sniff to detect the usage of
$autoloadoption to true or false
Tests 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the existing checks under includes/Checker/Checks and the WordPress.WP.EnqueuedResourceParameters sniff named in the issue, then review PHPCodesniffer_Check and Check_Result usage. Implement the Autoloaded_Options_Check acceptance criteria, including detection of the $autoload argument and warning results, and verify the stated class and run-method coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100