Skip to content

Commit 3b7843b

Browse files
arraypressclaude
andcommitted
Keep the test suite out of everybody's plugin
Composer installs a package from a git archive, and git archive honours export-ignore. Most of these libraries had no .gitattributes at all, so tests/, .github/ and the phpcs configuration were being installed into the vendor directory of every plugin that depends on them. That is not only untidy. A plugin's vendor tree gets scanned: by WordPress.org on submission, and by security plugins on the live site. A test suite is full of what a scanner reports -- stubbed core functions, fixture credentials, and in two of these libraries a call to PHP's runtime code interpreter, which is the first thing any of them looks for. src/, assets/, templates/, data/, composer.json and the README ship. Nothing else does. Checked with `git archive --worktree-attributes` rather than assumed. phpcs now refuses that interpreter outright. The sniff already existed and was already installed; it is a warning by default, and a warning does not fail CI, which is how it got in. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tk8y5eZa3CHVVSM6nVxsJw
1 parent 89d3da9 commit 3b7843b

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎.gitattributes‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# What reaches somebody's site.
2+
#
3+
# Composer installs a package from a git archive, and git archive honours
4+
# export-ignore, so everything listed here stops at the repository. That
5+
# matters more than tidiness: a plugin's vendor directory is scanned, by
6+
# WordPress.org on submission and by security plugins on the live site, and
7+
# a test suite full of stubbed core functions is not what anyone wants found
8+
# in there.
9+
#
10+
# src/, assets/, templates/, data/, composer.json and the README ship.
11+
# Everything that only matters while working on the library does not.
12+
13+
# The suite, and the stubbed core functions it runs against
14+
/tests export-ignore
15+
/phpunit.xml export-ignore
16+
/phpunit.xml.dist export-ignore
17+
/.phpunit.result.cache export-ignore
18+
/.phpunit.cache export-ignore
19+
20+
# Continuous integration
21+
/.github export-ignore
22+
23+
# Coding standards
24+
/phpcs.xml export-ignore
25+
/phpcs.xml.dist export-ignore
26+
/phpcs-format.xml.dist export-ignore
27+
/phpstan.neon export-ignore
28+
29+
# Repository furniture
30+
/.gitattributes export-ignore
31+
/.gitignore export-ignore
32+
/.editorconfig export-ignore
33+
/composer.lock export-ignore
34+
/.DS_Store export-ignore
35+
36+
# Long-form documentation and demonstrations. The README ships.
37+
/examples export-ignore
38+
/example export-ignore
39+
/EXAMPLES.md export-ignore
40+
/CHANGELOG.md export-ignore
41+
/SECURITY.md export-ignore

‎phpcs.xml.dist‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,15 @@
4444
<exclude-pattern>src/Traits/TabManager.php</exclude-pattern>
4545
</rule>
4646

47+
<!--
48+
No runtime code interpreter, anywhere that ships. It is a construct
49+
WordPress security scanners report on sight, and a plugin's vendor
50+
directory does get scanned: by WordPress.org on submission, and by
51+
security plugins on the live site. The sniff is only a warning by
52+
default, and a warning does not fail CI.
53+
-->
54+
<rule ref="Squiz.PHP.Eval">
55+
<type>error</type>
56+
</rule>
57+
4758
</ruleset>

0 commit comments

Comments
 (0)