From 63a5a4aaa338d86e69ff9233b5271cd17cabfeeb Mon Sep 17 00:00:00 2001 From: Nathanael Jones Date: Fri, 21 Aug 2026 21:03:37 +0100 Subject: [PATCH] ci: exclude tests/phpunit from DeepSource PHP analysis The PHP analyzer cannot resolve PHPUnit\Framework\TestCase, because it lives under the already-excluded vendor/**. Every assert*() call in a PHPUnit test file is therefore reported as "Call to an undefined method", so any PR that adds or edits a test file goes red on DeepSource: PHP regardless of its contents. Measured on PR #3242: 56 findings, 55 of them of this shape (33 in test_FrmStyle.php, 15 in test_FrmCreateFile.php, 5 in test_FrmStylesController.php, 2 in test_FrmMigrate.php). PR #3256 draws the same class of finding on the one test file it edits, a file that already carried assertions on master. test_patterns already lists these paths and is not sufficient: it relaxes the style and security categories but still reports bug-risk issues such as undefined methods. exclude_patterns is the only setting that stops them. PHPStan and Psalm are green on the same files because both load stubs.php explicitly (which declares WP_UnitTestCase -> WP_UnitTestCase_Base -> PHPUnit\Framework\TestCase); DeepSource has no equivalent stub-path setting. The green PHPUnit matrix is the other evidence these are artifacts: a suite cannot pass while calling undefined methods. Mirrors how every other analyzer in this repo already treats these files - phpstan.neon excludes */tests/*, phpcs.xml excludes a list of rules for tests/phpunit/*. Scoped to tests/phpunit/** rather than **/tests/**, so the JavaScript analyzer keeps covering tests/cypress (it currently passes there). Co-Authored-By: Claude Opus 5 (1M context) --- .deepsource.toml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.deepsource.toml b/.deepsource.toml index 95db5ce2c8..7205c5cdfc 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -23,7 +23,16 @@ exclude_patterns = [ "js/formidable-web-components.js", "js/frm_testing_mode.js", "js/welcome-tour.js", - "eslint-rules/**" + "eslint-rules/**", + # PHPUnit tests: the PHP analyzer cannot resolve PHPUnit\Framework\TestCase + # (it lives under the excluded vendor/**), so every assert*() call in these files + # is reported as "Call to an undefined method". PHPStan and Psalm are green on the + # same files only because both load stubs.php explicitly, which DeepSource has no + # equivalent setting for. test_patterns below is not enough: it relaxes the style + # and security categories but still reports bug-risk issues like undefined methods. + # Mirrors phpstan.neon's excludePaths (*/tests/*) and phpcs.xml's tests/phpunit/* + # rule exclusions. + "tests/phpunit/**" ] # 2. Test Patterns