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

Improve code coverage through annotations #1789

Open
sarthak-19 opened this issue Jan 11, 2025 · 0 comments
Open

Improve code coverage through annotations #1789

sarthak-19 opened this issue Jan 11, 2025 · 0 comments
Assignees
Labels
Infrastructure Issues for the overall performance plugin infrastructure [Type] Enhancement A suggestion for improvement of an existing feature

Comments

@sarthak-19
Copy link
Contributor

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

@github-project-automation github-project-automation bot moved this to Not Started/Backlog 📆 in WP Performance 2024 Jan 11, 2025
@westonruter westonruter added the [Type] Enhancement A suggestion for improvement of an existing feature label Jan 12, 2025
@westonruter westonruter moved this from Not Started/Backlog 📆 to To Do 🔧 in WP Performance 2024 Jan 13, 2025
@swissspidy swissspidy changed the title Improve Low Code Coverage by Ignoring Non-Critical Code and Adding Missing @cover Annotation Improve code coverage through annotations Jan 14, 2025
@swissspidy swissspidy added the Infrastructure Issues for the overall performance plugin infrastructure label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Issues for the overall performance plugin infrastructure [Type] Enhancement A suggestion for improvement of an existing feature
Projects
Status: To Do 🔧
Development

No branches or pull requests

3 participants