Skip to content

Create Autoloaded_Options_Check #28

Open

Description

@mehulkaklotar

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

Activity

  1. added
    [Type] EnhancementA suggestion for improvement of an existing feature
    ChecksAudit/test of the particular part of the plugin
    InfrastructureIssues for the overall plugin infrastructure
    and removed
    InfrastructureIssues for the overall plugin infrastructure
    on Nov 23, 2022
  2. moved this from Backlog to Definition in Plugin Checkon Nov 29, 2022
  3. moved this from Definition to Backlog in Plugin Checkon Nov 29, 2022
  4. moved this from Backlog to Definition in Plugin Checkon Dec 9, 2022
  5. self-assigned this
    on Dec 9, 2022
  6. moved this from Definition to AC Review in Plugin Checkon Dec 9, 2022
  7. removed their assignment
    on Dec 9, 2022
  8. moved this from AC Review to Definition in Plugin Checkon Feb 6, 2023
  9. vishalkakadiya commented on Feb 7, 2023

    @vishalkakadiya

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

  10. swissspidy commented on Jul 29, 2024

    @swissspidy
    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.

  11. swissspidy commented on Sep 26, 2024

    @swissspidy
    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

  12. swissspidy commented on Oct 2, 2024

    @swissspidy
    Member

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

  13. davidperezgar commented on Oct 2, 2024

    @davidperezgar
    Member

    Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ChecksAudit/test of the particular part of the plugin[Team] PerformanceIssues owned by Performance Team[Type] EnhancementA suggestion for improvement of an existing feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions