Skip to content
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

Open
mehulkaklotar opened this issue Nov 21, 2022 · 5 comments
Open

Create Autoloaded_Options_Check #28

mehulkaklotar opened this issue Nov 21, 2022 · 5 comments
Labels
Checks Audit/test of the particular part of the plugin [Team] Performance Issues owned by Performance Team [Type] Enhancement A suggestion for improvement of an existing feature

Comments

@mehulkaklotar
Copy link
Member

mehulkaklotar commented Nov 21, 2022

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
@mehulkaklotar mehulkaklotar added [Type] Enhancement A suggestion for improvement of an existing feature Checks Audit/test of the particular part of the plugin Infrastructure Issues for the overall plugin infrastructure and removed Infrastructure Issues for the overall plugin infrastructure labels Nov 23, 2022
@mehulkaklotar mehulkaklotar self-assigned this Dec 9, 2022
@mehulkaklotar mehulkaklotar removed their assignment Dec 9, 2022
@vishalkakadiya vishalkakadiya self-assigned this Feb 7, 2023
@vishalkakadiya
Copy link

@jjgrainger I will update AC for this issue, thanks! 🙂

@swissspidy
Copy link
Member

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.

@swissspidy
Copy link
Member

We don't have precedence for any sniffs in this plugin itself

No longer true, we now have some custom sniffs in the plugin

@swissspidy
Copy link
Member

There is some progress on the WPCS side: WordPress/WordPress-Coding-Standards#2473

@davidperezgar
Copy link
Member

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Checks Audit/test of the particular part of the plugin [Team] Performance Issues owned by Performance Team [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

5 participants