Skip to content

Commit

Permalink
Merge pull request #446 from woocommerce/dev/retire-phpcs-diff
Browse files Browse the repository at this point in the history
Retire `phpcs-diff`
  • Loading branch information
eason9487 authored Jul 1, 2024
2 parents ba8d8e5 + db107f7 commit 360c351
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 96 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/php-coding-standards-diff.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/php-coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PHP Coding Standards

on:
push:
branches:
- trunk
paths:
- "**.php"
- .github/workflows/php-coding-standards.yml
pull_request:
paths:
- "**.php"
- .github/workflows/php-coding-standards.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
phpcs:
name: PHP coding standards
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Prepare PHP
uses: woocommerce/grow/prepare-php@actions-v2
with:
php-version: 7.4
tools: cs2pr

- name: Log PHPCS debug information
run: vendor/bin/phpcs -i

- name: Run PHPCS on all files
run: vendor/bin/phpcs ./* -q --report=checkstyle | cs2pr
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Google Analytics for WooCommerce

[![PHP Coding Standards](https://github.com/woocommerce/woocommerce-google-analytics-integration/actions/workflows/php-coding-standards.yml/badge.svg)](https://github.com/woocommerce/woocommerce-google-analytics-integration/actions/workflows/php-coding-standards.yml)
[![PHP Unit Tests](https://github.com/woocommerce/woocommerce-google-analytics-integration/actions/workflows/php-unit-tests.yml/badge.svg)](https://github.com/woocommerce/woocommerce-google-analytics-integration/actions/workflows/php-unit-tests.yml)
[![JavaScript Linting](https://github.com/woocommerce/woocommerce-google-analytics-integration/actions/workflows/js-linting.yml/badge.svg)](https://github.com/woocommerce/woocommerce-google-analytics-integration/actions/workflows/js-linting.yml)
[![Build](https://github.com/woocommerce/woocommerce-google-analytics-integration/actions/workflows/build.yml/badge.svg)](https://github.com/woocommerce/woocommerce-google-analytics-integration/actions/workflows/build.yml)
Expand Down Expand Up @@ -56,7 +57,7 @@ To remove the Docker container and images (this will **delete everything** in th
1. Run `composer install` (_if you haven't done so already_)
2. Run `npm run lint:php`

Alternatively, run `npm run lint:php:diff` to run coding standards checks agains the current git diff. An explanation of output can be [found here](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage#printing-progress-information) e.g. what are the S's?
An explanation of output can be [found here](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage#printing-progress-information) e.g. what are the S's?

## Docs

Expand Down
18 changes: 0 additions & 18 deletions bin/phpcs-diff.sh

This file was deleted.

3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^v0.7",
"wp-coding-standards/wpcs": "^3.0",
"exussum12/coverage-checker": "^1.0",
"phpunit/phpunit": "^9.5",
"yoast/phpunit-polyfills": "^1.1.0"
},
Expand All @@ -24,4 +23,4 @@
"autoload": {
"psr-4": { "GoogleAnalyticsIntegration\\Tests\\": "tests/" }
}
}
}
52 changes: 3 additions & 49 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion includes/class-wc-google-analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function init_form_fields() {
public function show_options_info() {
$this->method_description .= "<div class='notice notice-info'><p>" . __( 'Please allow Google Analytics 24 hours to start displaying results.', 'woocommerce-google-analytics-integration' ) . '</p></div>';

// phpcs:disable WordPress.Security.NonceVerification.Recommended
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_REQUEST['woocommerce_google_analytics_ga_ecommerce_tracking_enabled'] ) && true === (bool) $_REQUEST['woocommerce_google_analytics_ga_ecommerce_tracking_enabled'] ) {
$this->method_description .= "<div class='notice notice-info'><p>" . __( 'Please note, for transaction tracking to work properly, you will need to use a payment gateway that redirects the customer back to a WooCommerce order received/thank you page.', 'woocommerce-google-analytics-integration' ) . '</div>';
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"makepot": "wpi18n makepot --domain-path languages --pot-file $npm_package_name.pot --type plugin --main-file $npm_package_name.php --exclude node_modules,tests,docs,assets/js/src",
"lint:js": "wp-scripts lint-js",
"lint:php": "vendor/bin/phpcs",
"lint:php:diff": "./bin/phpcs-diff.sh",
"archive": "composer archive --file=$npm_package_name --format=zip",
"postarchive": "rm -rf $npm_package_name && unzip $npm_package_name.zip -d $npm_package_name && rm $npm_package_name.zip && zip -r $npm_package_name.zip $npm_package_name && rm -rf $npm_package_name",
"build": "NODE_ENV=production wp-scripts build && npm run makepot && npm run archive",
Expand Down
11 changes: 8 additions & 3 deletions tests/class-unittestsbootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// phpcs:ignoreFile

namespace GoogleAnalyticsIntegration;

Expand Down Expand Up @@ -51,7 +50,9 @@ public function init() {
* Show errors.
*/
public function set_show_errors() {
// phpcs:ignore WordPress.PHP.IniSet.display_errors_Disallowed
ini_set( 'display_errors', 'on' );
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_error_reporting, WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting
error_reporting( E_ALL );
}

Expand All @@ -69,8 +70,12 @@ public function set_path_props() {
* Set server props
*/
public function set_server_props() {
$_SERVER['REMOTE_ADDR'] = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '';
$_SERVER['SERVER_NAME'] = isset( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : 'ga_integration_test';
if ( ! isset( $_SERVER['REMOTE_ADDR'] ) ) {
$_SERVER['REMOTE_ADDR'] = '';
}
if ( ! isset( $_SERVER['SERVER_NAME'] ) ) {
$_SERVER['SERVER_NAME'] = 'ga_integration_test';
}
}

/**
Expand Down

0 comments on commit 360c351

Please sign in to comment.