Implement includes, config file support & .distignore parsing (#1108, #1159)#1181
Implement includes, config file support & .distignore parsing (#1108, #1159)#1181faisalahammad wants to merge 4 commits into
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Thanks for your contribution! |
…rt, and .distignore parsing (WordPress#1108, WordPress#1159)
- Rewrite tests to use WP_UnitTestCase (fixes PHP 8.0 CI failure) - Delete isolated-bootstrap.php (broken mock approach) - Fix Plugin_Check_Command: remove extra blank lines (reviewer feedback) - Fix Plugin_Check_Command: load_filters_from_config() not just distignore - Fix Plugin_Request_Utility: @SInCE 1.1.0 -> 1.9.0 on include methods - Fix Plugin_Request_Utility: remove duplicate docblock, trailing whitespace - Fix Plugin_Request_Utility: inline comment punctuation, alignment - Fix Abstract_File_Check: alignment, single quotes for string - Fix docs/CLI.md: remove leading : on continuation lines - Add .gitignore entry for wp-tests-config.php
c3410b8 to
71d32a2
Compare
faisalahammad
left a comment
There was a problem hiding this comment.
Changes Applied
Fixes for CI failures (blocking review)
-
Rewrote all tests to use
WP_UnitTestCase(wasPHPUnit\Framework\TestCasewith broken mock bootstrap)Plugin_Request_Utility_Config_Tests.php— 17 tests covering config, distignore, regex, and integrationAbstract_File_Check_Include_Tests.php— 6 tests covering include/exclude file filteringInclude_Test_File_Check.php— test helper class (testdata)- Deleted:
isolated-bootstrap.php, old test files
-
Fixed config loading bug — CLI was calling
load_distignore_filters()instead ofload_filters_from_config(), so.plugin-check.jsonwas never loaded from CLI path
Reviewer feedback
- Removed extra blank lines in
Plugin_Check_Command.php(mukeshpanchal27 review)
Code quality
Plugin_Request_Utility.php: Fixed@since 1.1.0→@since 1.9.0, removed duplicate docblock, fixed trailing whitespace, fixed inline comment punctuation, addedphpcs:ignoreforfile_get_contentsAbstract_File_Check.php: Fixed variable alignment and string quotes (PHPCS)docs/CLI.md: Removed leading:on continuation lines
Verification
- ✅ PHPUnit: 504/504 tests pass (1396 assertions)
- ✅ PHPCS: 0 errors
- ✅ Rebased on trunk (v2.0.0) — branch is now up to date
Add @SuppressWarnings annotations for NPathComplexity and CyclomaticComplexity on get_files() (includes/exclude filtering adds inherent branching) and TooManyPublicMethods on Plugin_Request_Utility (config/distignore/include support requires public API surface). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
There is an issue with this PR. We cannot create automatic exclusions from the .distignore, .gitignore and .plugin-check.json files. These should be flagged by a command in wpcli. Remember that we load this plugin in the automatic scanner for new and updated plugins in wordpress.org, and we don't want users to be able to change the scanner's behaviour. I understand that you could remove the self-automatic checks, but they must be set. |
…onfig flag Plugin authors could ship .distignore or .plugin-check.json to silently exclude files from checks. The WordPress.org automated plugin-check scanner runs on every new/updated plugin, so author-controlled config loading broke the scanner's trust model. Address @davidperezgar's blocker (comment 4697859757): - Add explicit --use-config CLI flag, off by default - Extract gate to testable maybe_load_plugin_config() static method - Remove unconditional load_filters_from_config() call from admin (admin reverts to trunk behavior) - Add 6 PHPUnit tests covering gate (flag false, flag true, missing files, empty fixtures, no config files) - Document flag in docs/CLI.md and CLI help text Refs WordPress#1181
|
Thanks for the blocker feedback — addressed in commit Changes
How this addresses the blockerDefault behavior now matches trunk — Manual Verification
Refs #1181 |
|
Thanks! Update the versions of the classes to 2.1.0 |
Description
This PR introduces comprehensive enhancements to how the Plugin Check tool filters files. It adds support for CLI include options, configuration files (
.plugin-check.json), and automatic.distignoreparsing. This addresses both #1108 (CLI includes) and #1159 (Admin UI exclusions via backend logic).Why This Change Is Needed
Currently, the tool only supports excluding files/directories via CLI flags. There is no way to:
tests/,node_modules/, etc.) by reading.distignore.How It Solves The Issue
1. New CLI Options
Added
--include-filesand--include-directoriesto thecheckcommand.--include-directoriesworks recursively.2. Configuration File Support
The tool now looks for a
.plugin-check.jsonfile in the plugin root.Example:
{ "exclude-directories": ["tests", "vendor"], "include-files": ["plugin.php"] }3.
.distignoreSupportIf a
.distignorefile exists, its patterns are automatically parsed and added to the exclusion list.*.md,build/).4. Hybrid Priority System
To ensure predictable behavior, we implemented a strict priority order:
.plugin-check.json).distignore(if present).git,node_modules)Verification
I have added comprehensive unit tests to verify:
Run the new tests:
Before vs After
Before:
User has to manually type long exclude strings every time:
After:
User can just run:
(And the tool automatically respects
.distignoreand.plugin-check.json)OR user can check just one file:
Checklist