Skip to content

Enforce "Tested up to" exclusively in the readme file - #1465

Merged
davidperezgar merged 5 commits into
trunkfrom
enforce-tested-up
Sep 5, 2026
Merged

Enforce "Tested up to" exclusively in the readme file#1465
davidperezgar merged 5 commits into
trunkfrom
enforce-tested-up

Conversation

@davidperezgar

@davidperezgar davidperezgar commented Sep 4, 2026

Copy link
Copy Markdown
Member

Description

Fixes #1464

Replaces the mismatch-only validation in Plugin_Readme_Check::check_tested_up_to_mismatch() with a presence check: an error is now reported whenever the main plugin PHP file declares a Tested up to header, regardless of whether the readme value is missing, equal, or different.

Why

Tested up to is readme metadata and must live in readme file only (reference). Previously, Plugin Check only flagged this field when the header and readme values differed, which validated the duplicated declaration whenever both values happened to match — leaving two sources of truth that can silently drift in a future release.

Changes

  • includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php

    • check_tested_up_to_mismatch() now bails only if the plugin header has no Tested up to value (or is a single-file plugin).
    • Reports a new error code plugin_header_tested_up_to_not_allowed attached to the main plugin file whenever the header declares Tested up to:
      • If the readme value differs, the message shows both values.
      • If the readme value matches, the message explains that duplication can silently drift.
      • If the readme has no value at all, a generic removal instruction is shown.
    • In all cases, the message instructs authors to remove the Tested up to line from the plugin header and keep it only in readme.txt.
    • Removed the old mismatched_tested_up_to_header error code.
  • tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php

    • Updated test_run_with_mismatch, test_run_with_match, test_run_with_header_only, test_run_with_readme_only, test_run_with_single_file_plugin, and test_run_with_no_readme to assert against the new plugin_header_tested_up_to_not_allowed code and the new expected behavior (including the previously "no error" match case, which now correctly reports an error).

Existing fixtures under tests/phpunit/testdata/plugins/test-plugin-tested-up-to-* are reused as-is; only the assertions changed to reflect the new rule.

Acceptance criteria

  • Matching Tested up to in both readme and header → 1 error.
  • Differing values → 1 error, message includes both values.
  • Header-only declaration → 1 error.
  • Readme-only declaration → no error.
  • Rule remains scoped to directory plugins (single-file plugins are skipped, unchanged).

Testing

Ran the updated Plugin_Readme_Check_Tests suite locally via npm run test-php -- --filter Plugin_Readme_Check_Tests.

Open WordPress Playground Preview

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: davidperezgar <davidperez@git.wordpress.org>
Co-authored-by: frantorres <frantorres@git.wordpress.org>
Co-authored-by: ernilambar <nilambar@git.wordpress.org>
Co-authored-by: marceltannich <mardroid@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Comment thread includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php Outdated
@ernilambar

Copy link
Copy Markdown
Member

Two minor nits:

  1. Stale method namecheck_tested_up_to_mismatch() no longer checks for a mismatch, it now reports on presence alone. Consider renaming to something like check_tested_up_to_in_header() to match the new behavior.
  2. Stale test for mismatched_tested_up_to_headerPlugin_Header_Fields_Check_Tests::test_run_with_mismatched_tested_up_to() and test_run_with_matching_tested_up_to() still assert against the old mismatched_tested_up_to_header code, which no longer exists anywhere in the codebase after this change.

@davidperezgar

Copy link
Copy Markdown
Member Author

Done!

Comment thread includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php Outdated

@marceltannich marceltannich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this in Playground with both matching and different Tested up to values in the plugin header and readme, and both cases behave as expected.

The changes and test coverage look good to me. I only left one small inline comment, but nothing blocking.

@davidperezgar

Copy link
Copy Markdown
Member Author

Thanks @marceltannich for your review! I'm going to update the comment.

@davidperezgar
davidperezgar merged commit f62f5c3 into trunk Sep 5, 2026
37 of 50 checks passed
@davidperezgar
davidperezgar deleted the enforce-tested-up branch September 5, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce Tested up to exclusively in the readme file

4 participants