Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/bin/phpcs-branch.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace WordPressOrg\Bin\PHPCS_Changed;

function run_phpcs( $file, $bin_dir ) {
exec( "$bin_dir/phpcs $file -snq", $output, $exec_exit_status );
exec( "$bin_dir/phpcs $file --standard=./phpcs-clean.xml.dist -snq", $output, $exec_exit_status );
echo implode( "\n", $output );
return $exec_exit_status;
}
Expand All @@ -27,10 +27,10 @@ function run_phpcs_changed( $file, $git, $base_branch, $bin_dir ) {
exec( "$git diff $base_branch $file > $name.diff" );

exec( "$git show $base_branch:$file > $name.test.php" );
exec( "$bin_dir/phpcs $name.test.php --standard=./phpcs.xml.dist --report=json -snq > $name.orig.phpcs" );
exec( "$bin_dir/phpcs $name.test.php --standard=./phpcs-clean.xml.dist --report=json -snq > $name.orig.phpcs" );

exec( "cat $file > $name.test.php" );
exec( "$bin_dir/phpcs $name.test.php --standard=./phpcs.xml.dist --report=json -snq > $name.phpcs" );
exec( "$bin_dir/phpcs $name.test.php --standard=./phpcs-clean.xml.dist --report=json -snq > $name.phpcs" );

$cmd = "$bin_dir/phpcs-changed --diff $name.diff --phpcs-orig $name.orig.phpcs --phpcs-new $name.phpcs";
exec( $cmd, $output, $exec_exit_status );
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- '**.php'
- phpcs.xml.dist
- phpcs-clean.xml.dist
- composer.json
- .github/workflows/phpcs.yml
- .github/bin/phpcs-branch.php
Expand Down
35 changes: 35 additions & 0 deletions phpcs-clean.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" ?>
<ruleset name="WordPress.org Coding Standards (Clean)">
<description>Full WordPress Coding Standards, applied to changed lines and new files only (via .github/bin/phpcs-branch.php). No sniff exclusions — new code is held to the stock standard.</description>

<!-- Show sniff codes in all reports -->
<arg value="ps" />
<arg name="colors" />

<!-- Exclude 3rd-party files -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/plugins/plugin-directory/libs/*</exclude-pattern>
<exclude-pattern>*/plugins/theme-directory/lib/*</exclude-pattern>
<exclude-pattern>*/plugins/wpf-stripe/stripe-php/*</exclude-pattern>

<!-- Exclude generated wp-scripts asset files. -->
<exclude-pattern>*/plugins/*/build/index.asset.php</exclude-pattern>

<!-- Exclude JS/CSS files. -->
<exclude-pattern>*.js[x]?</exclude-pattern>
<exclude-pattern>*.[s]?css</exclude-pattern>

<!-- Scan all (php) files in the current folder and subfolders -->
<file>.</file>
<arg name="extensions" value="php" />

<!-- WordPress.org runs recent versions of WordPress. -->
<config name="minimum_wp_version" value="6.9"/>

<!-- Check for PHP cross-version compatibility. -->
<config name="testVersion" value="8.4-"/>
<rule ref="PHPCompatibilityWP"/>

<rule ref="WordPress"/>
</ruleset>
Loading