WordPress / WordPress/performance

Improve code coverage through annotations

Open
#1,789 12 comments 2 reactions 1 assignee View on GitHub

@sarthak-19 is already working on this.

Since Jan 12, 2025.

[Type] Enhancement Infrastructure
Dominant language
PHP
Stars
461
Forks
165
Avg merge
11h 12m
Merged PRs (30d)
28

Description

The current code coverage metrics are as follows :

Image

and can be improved by addressing the following issues:

  1. Ignore Coverage for Non-Critical Code Blocks:

    • Certain ubiquitous code blocks, such as:

      if ( ! defined( 'ABSPATH' ) ) {
          exit;
      } 
      

      These blocks can be excluded from code coverage by adding // @codeCoverageIgnoreStart and // @codeCoverageIgnoreEnd annotations.

  2. Exclude Plugin Bootstrap Files from Coverage:

    • Files like plugin bootstrap files only include logic that is already tested elsewhere.
    • Evaluate marking uninstall.php as indirectly tested and decide whether similar exclusions are needed for files like hooks.php.
  3. Add Missing @covers Annotations:

    • Ensure all tests have proper @covers annotations to map them to the code they validate. For instance:
      • \Test_OD_URL_Metric::test_constructor is missing a @covers ::get_uuid annotation.
  4. Add Missing Tests:

    • Identify areas of the codebase that are not currently tested and write additional tests to improve overall coverage.

These changes aim to focus coverage metrics on critical functionality and ensure more accurate and meaningful reports, improving code quality and maintainability.

cc : @westonruter

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.